我正在尝试使用 AWS s3select 功能来查询镶木地板文件。根据文档,它是受支持的,但我尝试了各种配置,但无法正常工作。在我已注释掉的每个 InputSerialization 尝试中,我都列出了我在尝试该版本时收到的错误。有人可以告诉我如何正确配置它吗?
import boto3
S3_BUCKET = 'myBucket'
KEY_LIST = "'0123','6789'"
S3_FILE = 'myFolder/myFile.parquet'
s3 = boto3.client('s3')
r = s3.select_object_content(
Bucket=S3_BUCKET,
Key=S3_FILE,
ExpressionType='SQL',
Expression="select \"Record\" from s3object s where s.\"Key\" in [" + KEY_LIST + "]",
# InputSerialization={}, # (MissingRequiredParameter) when calling the SelectObjectContent operation: InputSerialization is required
# InputSerialization={'CompressionType': { 'NONE' }}, # Invalid type for parameter InputSerialization.CompressionType, value: {'NONE'}, type: <class 'set'>, valid types: <class 'str'>
# InputSerialization={'Parquet': {}}, # Unknown parameter in InputSerialization: "Parquet", must be one of: CSV, CompressionType, JSON
# InputSerialization={'CompressionType': { 'Snappy' }}, # Invalid type for parameter InputSerialization.CompressionType, value: {'Snappy'}, type: <class 'set'>, valid types: <class 'str'>
OutputSerialization={'JSON': {}},
)
for event in r['Payload']:
if 'Records' in event:
records = event['Records']['Payload'].decode('utf-8')
print(records)