当我尝试加载一个多分区的镶木地板文件时,由于缺少用空值填充架构的数据,某些架构被无效推断。我认为在 pyarrow.parquet.ParquetDataset 中指定架构可以解决这个问题,但我不知道如何构建正确的 pyarrow.parquet.Schema 类型的架构。一些示例代码:
import pyarrow as pa
import pa.parquet as pq
test_schema = pa.schema([pa.field('field1', pa.string()), pa.field('field2', pa.float64())])
paths = ['test_root/partition1/file1.parquet', 'test_root/partition2/file2.parquet']
dataset = pq.ParquetDataset(paths, schema=schema)
和错误:
AttributeError: 'pyarrow.lib.Schema' object has no attribute 'to_arrow_schema'
但我找不到任何关于如何构建 pyarrow.parquet.Schema 架构的文档(如文档(https://arrow.apache.org/docs/python/generated/pyarrow.parquet.ParquetDataset.html),并且有只做了一个 pyarrow.lib.Schema 给出了上述错误。
相关分类