Athena SQL Querying
Analytics Amazon Athena
Delivery Constraint & Opportunity Analysis · Updated 1 month, 2 weeks ago
Content
Skill: Athena SQL Querying
Capability Domain: Analytics
Technology Stack: Amazon Athena
Linked Activities: Present the Catalog via Athena
Recipe
- One workgroup: Scope Contract
athena_workgroup(defaultops-lake-analysts),EnforceWorkGroupConfigurationon, scan cap 5GB to start. - Glue crawler tables are the contract views (
github_issues, …). Named Athena queries are proofs (LIMIT 10), not a second catalog.scripts/create_athena_views.pyafter crawlers READY; skip views with no Glue table. - Backfill envelope is
{backfill, kind, repo, payload: {…}}. Queryjson_extract_scalar(raw_json, '$.payload.number'),$.payload.closed_at,$.payload.state— not top-level GitHub fields. Prefer the snapshot that hasclosed_atwhen deduping by issue number. - Query results → athena-results bucket, 7-day lifecycle.
- Always filter on
source/dt.SELECT *on an unpartitioned scan blows the cap.
Pitfalls
- AWS login refresh is not Athena AccessDenied. Local Jupyter/
awswranglercan fail withAccessDeniedExceptiononCreateOAuth2Token, thenLoginRefreshRequired: "The refresh token has expired" / "Please reauthenticate usingaws login". Wrangler never reachedStartQueryExecution. This is credential session expiry, not lake IAM / workgroup deny. Procedure: (1) terminalaws login(or this org's equivalentaws sso login); (2) confirmaws sts get-caller-identitymatchesdocs/lake-scope-contract.yamlaws_account(live opsdl:411113550285); (3) Restart the Jupyter kernel, then Restart & Run All — boto3 clients in a running kernel keep the dead token; (4) the login credential provider also needspip install 'botocore[crt]'(opsdlrequirements-eda.txt). - Treating crawler tables as incomplete until CREATE VIEW — the table name already matches the contract view.
- Querying
$.numberinstead of$.payload.numberon backfill rows. - Shipping
gitlab_commitsas a default when the contract is GitHub-only. - Correlated EXISTS/UNNEST subqueries in Athena (feature filters belong in Python after the SQL returns).
Details
- Capability Domain:
- Analytics
- Technology Stack:
- Amazon Athena
- Created:
- 2 months ago
- Updated:
- 1 month, 2 weeks ago
Playbook
Activities Using This Skill 2
- Present the Catalog via Athena Build the Operational Data Lake Pipeline
- Map the BizDevTestSecOps Value Stream Constraint and Flow Analysis