将 json 写入 parquet 对象以使用 Lambda Python 放入 S3

Write a json to a parquet object to put into S3 with Lambda Python

我想使用 Amazon Lambda (python) 将 json 对象写入 parquet 中的 S3!

但是我无法将 fastparquet 库与 boto3 连接起来,因为第一个库有一个写入文件的方法,而 boto3 期望将一个对象放入 S3 存储桶

有什么建议吗?

fastparquet 示例

fastparque.write('test.parquet', df, compression='GZIP', file_scheme='hive')

Boto3 示例

 client = authenticate_s3()
        response = client.put_object(Body=Body, Bucket=Bucket, Key=Key)

Body 将对应于 parquet 内容!它将允许写入 S3

您可以使用 write 方法的 open_with 参数将任何数据帧写入 S3(参见 fastparquet's doc

import s3fs
from fastparquet import write

s3 = s3fs.S3FileSystem()
myopen = s3.open
write(
    'bucket-name/filename.parq.gzip',
    frame,
    compression='GZIP',
    open_with=myopen
)