【发布时间】:2021-07-15 22:28:20
【问题描述】:
我真正想做的是(在 Python 中):
import pyarrow.parquet as pq
# Note the 'columns' predicate...
table = pq.read_table('gs://my_bucket/my_blob.parquet', columns=['a', 'b', 'c'])
首先,我认为 PyArrow 从 V3.0.0 开始不支持 gs://。 所以只好修改代码使用fsspec接口:https://arrow.apache.org/docs/python/filesystems.html
import pyarrow.parquet as pq
import gcsfs
fs = gcsfs.GCSFileSystem(project='my-google-project')
with fs.open('my_bucket/my_blob.parquet', 'rb') as file:
table = pq.read_table(file.read(), columns=['a', 'b', 'c'])
这是否实现了谓词下推(我对此表示怀疑,因为我已经用 file.read() 准备好整个文件),还是有更好的方法来实现?
【问题讨论】:
-
你试过
table = pq.read_table(file, columns=['a', 'b', 'c'])(没有read)。read_table支持“类文件对象”作为参数
标签: google-cloud-storage parquet pyarrow apache-arrow gcsfuse