AWS Data Lakehouse
CloudFormation Quick Deploy
Existing Bucket

IAM Access Keys

Query
Views
Resetting Your Data Lake
Last updated
Was this helpful?


Last updated
Was this helpful?
Was this helpful?
# configure AWS credential chain
export AWS_ACCESS_KEY_ID=AKIA4WWOSMD6PEXAMPLE
export AWS_SECRET_ACCESS_KEY=<REDACTED>
export AWS_REGION=us-east-1
export BUCKET=my-grax-bucket
export ORG=00D46000001EXAMPLEQUERY="SELECT COUNT(*) FROM object_account"
aws athena start-query-execution \
--query-string $QUERY \
--query-execution-context Database=default \
--result-configuration OutputLocation=s3://$BUCKET/athena-results \
--output text
654059a8-8455-4ecf-b539-3a694847aa15
aws athena get-query-results --query-execution-id 654059a8-8455-4ecf-b539-3a694847aa15{
"ResultSet": {
"Rows": [
{
"Data": [
{
"VarCharValue": "_col0"
}
]
},
{
"Data": [
{
"VarCharValue": "126178"
}
]
}
]
}
}QUERY="SELECT Id, Name FROM object_account LIMIT 1"
aws athena start-query-execution \
--query-string $QUERY \
--query-execution-context Database=default \
--result-configuration OutputLocation=s3://$BUCKET/athena-results \
--output text
f7717a2a-19ef-4b81-9d1a-858abb847a6a
aws athena get-query-results --query-execution-id f7717a2a-19ef-4b81-9d1a-858abb847a6a{
"ResultSet": {
"Rows": [
{
"Data": [
{
"VarCharValue": "Id"
},
{
"VarCharValue": "Name"
}
]
},
{
"Data": [
{
"VarCharValue": "0014600000zEXAMPLE"
},
{
"VarCharValue": "Example Acct"
}
]
}
]
}
}QUERY="CREATE OR REPLACE VIEW object_account_live AS
WITH max_idseq AS (
SELECT id AS mid, MAX(grax__idseq) AS max_idseq
FROM object_account
GROUP BY 1
),
live AS (
SELECT *
FROM object_account o
JOIN max_idseq m ON m.mid = o.id
AND grax__idseq = max_idseq
AND grax__deleted IS NULL
)
SELECT * FROM live
"
aws athena start-query-execution \
--query-string $QUERY \
--query-execution-context Database=default \
--result-configuration OutputLocation=s3://$BUCKET/athena-results \
--output textQUERY="SELECT COUNT(*) FROM object_account_live"
aws athena start-query-execution \
--query-string $QUERY \
--query-execution-context Database=default \
--result-configuration OutputLocation=s3://$BUCKET/athena-results \
--output text
e8a35172-27c2-418b-911b-7cd470837797
aws athena get-query-results --query-execution-id e8a35172-27c2-418b-911b-7cd470837797{
"ResultSet": {
"Rows": [
{
"Data": [
{
"VarCharValue": "_col0"
}
]
},
{
"Data": [
{
"VarCharValue": "23157"
}
]
}
]
}
}aws s3 rm --recursive s3://$BUCKET/parquet/v2/org=00D46000001EXAMPLE/