Created
December 24, 2020 08:51
-
-
Save koonagi/d89ff4eb35738326b4c340a9c243d192 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# != 4 ]; then | |
echo "+++ Argument Error +++" | |
echo Usage: ./s3select_cli.sh "<s3_bucket_name>" "<s3_Object_key>" "<file_format Parquet|CSV>" "<SQL>" | |
echo Example: ./s3select_cli.sh nyc-tlc misc/uber_nyc_data.csv CSV "select * from s3object limit 10" | |
exit 1 | |
fi | |
BucketName=$1 | |
KeyName=$2 | |
Format=$3 | |
SQL=$4 | |
aws s3api select-object-content --bucket ${BucketName} --key "${KeyName}" --expression "${SQL}" --expression-type 'SQL' --input-serialization '{"'${Format}'": {}, "CompressionType": "NONE"}' --output-serialization '{"CSV": {}}' "tmp_output.csv" && cat tmp_output.csv && rm tmp_output.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment