【发布时间】:2021-12-13 02:28:00
【问题描述】:
我有一个镶木地板文件,其中 ListArray 列中有一个结构字段,其中结构内字段的数据类型从 int 更改为带有一些新数据的浮点数。
为了合并新旧数据,我一直在使用pq.read_table 读取活动和历史镶木地板文件,然后使用pa.concat_table 合并并写入新文件。
因此,为了在连接之前使两个表的架构兼容,我执行以下操作:
active = pq.read_table("path\to\active\parquet")
active_schema = active.schema
hist = pq.read_table("path\to\hist\parquet")
hist = hist.cast(target_schema=active_schema)
combined = pa.concat_tables([active, hist])
但我在投射时收到以下错误:
ArrowNotImplementedError: Unsupported cast from struct<code: string, unit_price: struct<amount: int64, currency: string>, line_total: struct<amount: int64, currency: string>, reversal: bool, include_for: list<item: string>, quantity: int64, seats: int64, units: int64, percentage: int64> to struct using function cast_struct
基于此,我似乎无法进行演员表。
所以我的问题是,如何合并这些数据集/如何更新旧表上的架构?如果可能的话,我会尽量留在箭头/镶木地板生态系统中。
【问题讨论】:
-
不幸的是,将结构转换为类似的结构类型但具有不同的字段类型尚未实现(请参阅issues.apache.org/jira/browse/ARROW-1888 以获得功能请求)。我认为目前唯一可能的解决方法是提取结构列,分别转换字段,从中重新创建结构列并用它更新表。
标签: python pyarrow apache-arrow