PluginBench
Skill
Pass
Audit score 90

querying-data-lake

aws/agent-toolkit-for-aws

Execute SQL queries on Amazon Athena across Glue, S3 Tables, and Redshift catalogs with workgroup management and cost tracking.

What is querying-data-lake?

Runs and manages Athena SQL queries across default and federated data catalogs. Use this when you need to execute SELECT, INSERT, UPDATE, DELETE, or other SQL statements on your data lake, profile tables, check workgroup status, or query specific catalogs. It handles workgroup selection, statement classification for safety, and reports execution cost and data scanned.

  • Execute SELECT, SHOW, DESCRIBE, EXPLAIN queries on Athena across Glue, S3 Tables, and Redshift catalogs
  • Run destructive statements (INSERT, UPDATE, DELETE, DROP, ALTER, CREATE) with user confirmation
  • Profile tables with schema discovery and sample row inspection
  • Select and manage Athena workgroups with automatic output location handling
  • Report query cost, data scanned, and execution duration
  • Handle federated catalog queries with appropriate warnings for cross-catalog joins and Redshift scans

How to install querying-data-lake

npx skills add https://github.com/aws/agent-toolkit-for-aws --skill querying-data-lake
Prerequisites
  • AWS credentials configured with access to Athena and target catalogs
  • AWS region specified or available in environment
  • Athena workgroup with configured output S3 location
Claude Code
Cursor
Windsurf
Cline

How to use querying-data-lake

  1. 1.Provide SQL text, a named query name, workgroup name, catalog name, or 'profile TABLE_NAME' as argument
  2. 2.Confirm your AWS region when prompted
  3. 3.Allow the skill to select an appropriate workgroup and display its output location
  4. 4.For fuzzy table references, the skill will delegate to finding-data-lake-assets to resolve the exact database.table
  5. 5.Review the resolved table and schema before execution
  6. 6.Confirm the output S3 location before running non-trivial queries
  7. 7.For destructive statements (INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, TRUNCATE, MERGE), explicitly approve execution
  8. 8.Review results including cost, data scanned, and execution duration

Use cases

Good for
  • Run ad-hoc SQL analysis on data in your S3-backed data lake
  • Query federated Redshift tables without moving data
  • Profile an unfamiliar table to understand its schema and content before building analytical queries
  • Execute named queries stored in Athena
  • Check workgroup status and view recent query history
Who it's for
  • Data analysts querying Athena
  • Data engineers managing data lake queries
  • SQL developers executing federated queries across multiple catalogs
  • Anyone needing to profile or explore tables in Athena

querying-data-lake FAQ

When should I use this skill vs. finding-data-lake-assets?

Use this skill to execute queries. Use finding-data-lake-assets when you need to locate a specific table by business concept or fuzzy name. This skill will delegate to finding-data-lake-assets automatically if you provide a vague table reference.

What happens if I query a Redshift-federated table?

The skill will warn you that Redshift-federated queries cannot use partition pruning and will scan the full table. You must confirm before execution.

Do I need to specify a catalog name in my SQL?

For the default Glue catalog, use database.table. For federated catalogs (Redshift, S3 Tables), use datasource.database.table or the appropriate catalog-qualified path. The skill will guide you based on your target.

What if my query fails with an output-location error?

The selected workgroup may not have an output location configured. The skill will list available workgroups and let you choose a different one with a valid output location.

Are INSERT, UPDATE, DELETE statements allowed?

Yes, but the skill classifies them as destructive and requires explicit user confirmation before execution to prevent accidental data loss.

Full instructions (SKILL.md)

Source of truth, from aws/agent-toolkit-for-aws.


name: querying-data-lake description: >- 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). version: 1 argument-hint: '[SQL-query|query-name|workgroup-name|catalog-name|''profile TABLE_NAME'']'

Query Data Lake

Execute SQL queries on Amazon Athena across default and federated catalogs (Glue, S3 Tables, Redshift) with workgroup selection, statement classification, and error recovery.

Overview

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:

  • You MUST accept a single optional argument: SQL text, a named-query name, a workgroup name, a catalog name, or profile TABLE_NAME
  • You MUST accept the argument as direct text or a pointer to a file containing SQL
  • You MUST ask the user for the target AWS region if not already set
  • You MUST confirm the output S3 location before executing any non-trivial query
  • You MUST respect the user's decision to abort at any step

Common Tasks

1. Verify Dependencies

Check for required tools and AWS access before running queries.

Constraints:

  • You MUST verify AWS MCP server tools are available (aws___call_aws) and run queries through them when present; fall back to AWS CLI only if the MCP server is unavailable
  • You MUST NOT fall back to shell or Bash for query execution — results must be captured via the MCP tool or aws athena CLI so output location and cost are tracked
  • You MUST confirm credentials with aws sts get-caller-identity and inform the user about any missing tools

2. Resolve Workgroup

Check caller identity, list workgroups, auto-select the best one (see workgroup-selection.md).

Constraints:

  • You MUST select a workgroup before submitting any query (prevents output-location errors)
  • You MUST present the selected workgroup and its output location to the user
  • You MUST NOT auto-escalate to a different workgroup on failure without user confirmation

3. Resolve the Target Asset

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:

  • You MUST NOT attempt to resolve fuzzy asset references with athena list-data-catalogs or by iterating get-tables — those miss federated catalogs and waste tokens
  • You SHOULD skip this step only when the user provides a fully-qualified reference (exact database.table) or raw SQL they want executed as-is
  • You MUST state the resolved asset explicitly before building the query: "Found [table] in [catalog]. Using this for the query."
  • You SHOULD default to the default Glue catalog unless the user mentions "federated", "Redshift", "S3 Tables", or finding-data-lake-assets returns a different catalog

4. Discover Schema

For 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.

5. Build Query

Table addressing depends on catalog type:

  • Default Glue catalog: database.table (omit the catalog prefix for single-catalog queries). In cross-catalog queries, qualify default-catalog tables with "awsdatacatalog".database.table.
  • Registered data source: datasource.database.table
  • Unregistered Glue catalog: "catalog/subcatalog".database.table

6. Classify and Execute

Classify the SQL statement before executing:

StatementBehavior
SELECT, SHOW, DESCRIBE, EXPLAINSafe — execute
INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, TRUNCATE, MERGEDestructive — warn the user and require explicit confirmation
UnsureTreat 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:

  • You MUST warn the user before executing when the target is Redshift-federated ("No partition pruning — every query scans the full table")
  • You MUST warn the user before executing a cross-catalog join ("Cross-catalog joins incur network overhead and may be slow")
  • You MUST confirm the output S3 location before executing
  • You MUST explain which tool is being called before executing
  • You MUST respect the user's decision to abort

7. Present and Recover

Present results with cost, data scanned, duration, and actionable insights. On failure, list available workgroups and let the user choose which to retry with.

Argument Routing

Resolve in this order; stop at the first match:

  1. Contains SQL keywords (SELECT, SHOW, DESCRIBE, INSERT, etc.) — SQL text, execute directly
  2. profile TABLE_NAME — run comprehensive table profiling (see query-patterns.md)
  3. Matches a known named query — look up and execute
  4. Matches a known workgroup — show workgroup status and recent queries
  5. Matches a known catalog — delegate to exploring-data-catalog to enumerate databases and tables
  6. No args — show recent query activity and available tables

Principles

  • Always select workgroup before executing (prevents output-location errors)
  • Profile unfamiliar tables before running analytical queries
  • Present cost alongside results so users build cost awareness
  • Suggest LIMIT for exploratory queries on large tables
  • Never ask domain questions with obvious answers, but always confirm security-relevant actions (workgroup switches, output location changes, non-SELECT statements)

Troubleshooting

ErrorCauseFix
Redshift identifier error with mixed caseRedshift-federated names are lowercase onlyLowercase the identifier
CatalogId validation failureARN passed instead of catalog namePass the catalog name, not the ARN
Cross-catalog information_schema returns nothingMissing catalog qualifierUse catalog-qualified path: "catalog".information_schema.tables
Query fails with output-location errorWorkgroup has no output location configuredSelect a different workgroup with an output location, or configure one
Destructive statement executed without confirmationStatement classification skippedAlways classify INSERT/UPDATE/DELETE/DROP/ALTER/CREATE/TRUNCATE/MERGE and confirm with the user

Additional Resources

Related skills

More from aws/agent-toolkit-for-aws and the wider catalog.

ROrouting-traffic-with-route53-and-cloudfront logo

routing-traffic-with-route53-and-cloudfront

aws/agent-toolkit-for-aws

Configures Amazon Route 53 to route traffic to a CloudFront distribution using a custom domain. Use when setting up DNS alias records, alternate domain names (CNAMEs), ACM certificates for HTTPS, and IPv6 support for CloudFront.

1.3k installsAudited
SEsecuring-s3-buckets logo

securing-s3-buckets

aws/agent-toolkit-for-aws

Create and secure S3 buckets following AWS best practices for access control, encryption, monitoring, and remediation.

1.5k installsAudited
SEsetting-up-cloudtrail-multi-region logo

setting-up-cloudtrail-multi-region

aws/agent-toolkit-for-aws

Enables a multi-region AWS CloudTrail trail with S3 log storage, CloudWatch Logs integration, and CloudWatch Logs Insights queries for security monitoring and compliance auditing. Use when setting up centralized API activity logging across all AWS regions.

1.2k installsAudited
SEsetting-up-cloudwatch-alarm-notifications logo

setting-up-cloudwatch-alarm-notifications

aws/agent-toolkit-for-aws

Set up encrypted SNS topics and subscriptions for CloudWatch alarm notifications with proper security controls.

1.3k installsAudited
SEsetting-up-ec2-instance-profiles logo

setting-up-ec2-instance-profiles

aws/agent-toolkit-for-aws

Configures EC2 instances to securely call AWS services by creating and attaching IAM roles via instance profiles, eliminating hardcoded credentials. Use when an EC2 instance needs permissions to access AWS services like S3, DynamoDB, SQS, or CloudWatch through temporary credentials.

1.3k installsAudited
STstoring-and-querying-vectors logo

storing-and-querying-vectors

aws/agent-toolkit-for-aws

Cost-effective vector storage and semantic search with Amazon S3 Vectors

1.5k installsAudited