I am trying to use AWS s3select feature to query a parquet file. According to the documentation it's supported but I have tried various configurations and can't get it to work. In each of the InputSerialization attempts I've shown commented-out, I've listed the error I'm receiving when I try that version. Can someone show me how to properly configure this?
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)
I needed to upgrade my boto3 install to the latest version. After upgrading to 1.9.7, this version worked: