【发布时间】:2023-01-20 11:48:28
【问题描述】:
我正在尝试将 pandas Dataframe 写入与 Impala 中的表兼容的镶木地板文件,但我正在努力寻找解决方案。
我的 df 有 3 列
code int64
number float
name object
当我将它创建到镶木地板文件中并将其加载到 impala 中时,python 模式被保留并且它失败了。我希望镶木地板使用以下模式保存:
code int
number decimal(36,18)
name string
我试过这个:
env_schema = """
code int
number decimal(36,18)
name string
"""
df.to_parquet(f'path', index=False, schema=env_schema)
但出现以下错误:
Argument 'schema' has incorrect type (expected pyarrow.lib.Schema, got str)
有谁知道我怎么能做到这一点?谢谢
【问题讨论】:
标签: python apache-spark impala pyarrow