Analytics Skills
Chapter 55 of 118
Execute and manage Athena SQL queries across default and federated catalogs (Glue, S3 Tables, Redshift).
4 minutes · 847 words · 14 sections
Execute SQL queries on Amazon Athena across default and federated catalogs (Glue, S3 Tables, Redshift) with workgroup selection, statement classification, and error recovery.
Executes and manages Athena SQL queries across default and federated catalogs. Selects a workgroup, resolves target assets (delegating fuzzy references to finding-data-lake-assets), classifies statements for safety, and reports cost and data scanned. Use the AWS MCP server for sandboxed execution and audit logging; the same AWS CLI commands work directly when the MCP server is not available.
Constraints for parameter acquisition:
profile TABLE_NAMECheck for required tools and AWS access before running queries.
Constraints:
aws___call_aws) and run queries through them when present; fall back to AWS CLI only if the MCP server is unavailableaws athena CLI so output location and cost are trackedaws sts get-caller-identity and inform the user about any missing toolsCheck caller identity, list workgroups, auto-select the best one (see workgroup-selection.md (opens in a new tab)).
Constraints:
If the user refers to a table by name, by business concept (“our quarterly report”, “the sales data”), by S3 path, or by catalog without specifying the table, delegate to finding-data-lake-assets to return the concrete database.table (and catalog if non-default).
Constraints:
athena list-data-catalogs or by iterating get-tables — those miss federated catalogs and waste tokensdatabase.table) or raw SQL they want executed as-isfinding-data-lake-assets returns a different catalogFor analytical queries, You SHOULD profile the target table before building the final query. You MUST show sample rows (SELECT ... LIMIT 5) as part of profiling.
Table addressing depends on catalog type:
database.table (omit the catalog prefix for single-catalog queries). In cross-catalog queries, qualify default-catalog tables with "awsdatacatalog".database.table.datasource.database.table"catalog/subcatalog".database.tableClassify the SQL statement before executing:
| Statement | Behavior |
|---|---|
SELECT, SHOW, DESCRIBE, EXPLAIN | Safe — execute |
INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, TRUNCATE, MERGE | Destructive — warn the user and require explicit confirmation |
| Unsure | Treat as destructive; confirm |
Example tool call (via AWS MCP server):
aws___call_aws(command="aws athena start-query-execution --work-group <WORKGROUP_NAME> --query-string '<sql>' --query-execution-context Database=<db>")For federated or S3 Tables catalogs, also set Catalog=<CATALOG_PATH> in the execution context (e.g. Catalog=s3tablescatalog/<BUCKET_NAME>).
Constraints:
Present results with cost, data scanned, duration, and actionable insights. On failure, list available workgroups and let the user choose which to retry with.
Resolve in this order; stop at the first match:
SELECT, SHOW, DESCRIBE, INSERT, etc.) — SQL text, execute directlyprofile TABLE_NAME — run comprehensive table profiling (see query-patterns.md (opens in a new tab))exploring-data-catalog to enumerate databases and tablesLIMIT for exploratory queries on large tables| Error | Cause | Fix |
|---|---|---|
| Redshift identifier error with mixed case | Redshift-federated names are lowercase only | Lowercase the identifier |
CatalogId validation failure | ARN passed instead of catalog name | Pass the catalog name, not the ARN |
Cross-catalog information_schema returns nothing | Missing catalog qualifier | Use catalog-qualified path: "catalog".information_schema.tables |
| Query fails with output-location error | Workgroup has no output location configured | Select a different workgroup with an output location, or configure one |
| Destructive statement executed without confirmation | Statement classification skipped | Always classify INSERT/UPDATE/DELETE/DROP/ALTER/CREATE/TRUNCATE/MERGE and confirm with the user |
Install this repository
npx skills add aws/agent-toolkit-for-aws/plugin marketplace add aws/agent-toolkit-for-awsSkills install per repository, not per chapter — the CLI has no documented per-skill form, so we do not print one.
Execute and manage Athena SQL queries across default and federated catalogs (Glue, S3 Tables, Redshift). Triggers on phrases like: query data, run SQL, athena query, analyze table, SQL query, workgroup status, profile table, query Redshift catalog, query S3 Tables. Do NOT use for finding specific data assets (use finding-data-lake-assets), full catalog audits (use exploring-data-catalog), importing data (use ingesting-into-data-lake).
The verbatim description from this skill’s front matter — the string an agent matches on to decide whether to load it.
skills/specialized-skills/analytics-skills/querying-data-lake/SKILL.mdmain, last pushed 10 August 2026.SKILL.md, not by matching a directory convention. 16 distinct layouts observed: plugins/aws-agents-for-devsecops/skills/*/SKILL.md, plugins/aws-agents/skills/*/SKILL.md, plugins/aws-core/skills/*/SKILL.md, skills/core-skills/*/SKILL.md, skills/specialized-skills/analytics-skills/*/SKILL.md, skills/specialized-skills/database-skills/*/SKILL.md, skills/specialized-skills/ec2-skills/*/SKILL.md, skills/specialized-skills/migration-and-modernization-skills/*/SKILL.md, skills/specialized-skills/networking-and-content-delivery-skills/*/SKILL.md, skills/specialized-skills/operations-skills/*/SKILL.md, skills/specialized-skills/resilience-skills/*/SKILL.md, skills/specialized-skills/security-and-identity-skills/*/SKILL.md, skills/specialized-skills/serverless-skills/*/SKILL.md, skills/specialized-skills/storage-skills/*/SKILL.md, skills/specialized-skills/system-table-skills/*/SKILL.md, skills/specialized-skills/web-and-mobile-development/*/SKILL.md.h1 and no skipped levels:.claude-plugin/marketplace.json by Amazon Web Services, declaring 4 plugins. It is read for editorial metadata only — never as the skill index, which is always the repository tree./aws/agent-toolkit-for-aws.md, and each chapter at its own .md URL.2 files · 9 KB
Everything this skill ships beside its prose. All of it is set here, as subchapters of chapter 55.
Documentation the agent loads on demand, rather than up front.