I have the following function call that works
def s3_select():
client = boto3.client("s3")
bucket = "test"
key = "test.json"
expression_type = "SQL"
expression = """SELECT * FROM S3Object"""
input_serialization = {"JSON": {"Type": "Document"}}
output_serialization = {"JSON": {}}
response = client.select_object_content(
Bucket=bucket,
Key=key,
ExpressionType=expression_type,
Expression=expression,
InputSerialization=input_serialization,
OutputSerialization=output_serialization
)
for event in response["Payload"]:
print(event)
Instead of pulling in the entire content of my json in S3, how do I modify my expression, to just pull some field in the json.
Example if my test.json contains a key called TEST_KEY
How can my expression change to just pull TEST_KEY from the json file?
For the case you've detailed, all you'd have to change is your expression, like
expression = """SELECT s.TEST_KEY FROM S3Object s"""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With