You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Polars中忽略PyArrow时间戳转换错误?

解决Polars读取Delta表时的时间戳精度丢失错误

直接通过pl.read_delta的pyarrow_options传递参数

Polars的read_delta底层依赖PyArrow处理Delta表读取,你可以通过pyarrow_options传入PyArrow的cast_options参数,设置safe=False来跳过精度检查,和Pandas的safe=False效果一致:

import polars as pl

df = pl.read_delta(
    "path/to/your/delta_table",
    pyarrow_options={
        "cast_options": {"safe": False}
    }
)

备选方案:先通过PyArrow读取再转Polars

如果上述参数不生效,可以先使用PyArrow直接读取Delta表并设置safe=False,再转换为Polars DataFrame:

import pyarrow.dataset as ds
import polars as pl

# PyArrow读取Delta表,跳过精度检查
arrow_table = ds.dataset("path/to/your/delta_table", format="delta").to_table(
    cast_options={"safe": False}
)
# 转换为Polars DataFrame
df = pl.from_arrow(arrow_table)

内容的提问来源于stack exchange,提问作者user23406368

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 23:57:01