Athena(AWSのデータ分析サービス)のSQLクエリを実行・管理します。デフォルトカタログおよびフェデレーテッドカタログ(Glue、S3 Tables、Redshift)に対応しています。 次のような場合に使用: 「データをクエリしたい」「SQLを実行したい」「Athenaクエリ」「テーブルを分析したい」「SQLクエリ」「ワークグループのステータスを確認したい」「テーブルのプロファイルを見たい」「Redshiftカタログをクエリしたい」「S3 Tablesをクエリしたい」 **使用しないでください:** - 特定のデータ資産を探す場合(データレイク資産検索機能を使用) - カタログ全体の監査(データカタログ参照機能を使用) - データのインポート(データレイクへのデータ取り込み機能を使用)
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).
デフォルトカタログおよびフェデレーテッドカタログ(Glue、S3 Tables、Redshift)に対して Amazon Athena 上で SQL クエリを実行します。ワークグループの選択、ステートメントの分類、エラーリカバリに対応しています。
デフォルトカタログおよびフェデレーテッドカタログをまたいで Athena SQL クエリを実行・管理します。ワークグループを選択し、対象アセットを解決(あいまいな参照は finding-data-lake-assets に委譲)し、ステートメントの安全性を分類し、コストとスキャンデータ量を報告します。
サンドボックス実行および監査ログには AWS MCP サーバーを使用してください。MCP サーバーが利用できない場合は、同等の AWS CLI コマンドを直接実行できます。
次のような場合に使用: SQL テキスト、名前付きクエリ名、ワークグループ名、カタログ名、または profile TABLE_NAME のいずれかを引数として渡してクエリを実行したいとき。
パラメータ取得に関する制約:
profile TABLE_NAME)クエリ実行前に、必要なツールと AWS アクセスを確認します。
制約:
aws___call_aws)が利用可能かどうかを確認し、利用可能な場合はそれを通じてクエリを実行すること。MCP サーバーが利用できない場合のみ AWS CLI にフォールバックすることaws athena CLI 経由で取得することaws sts get-caller-identity でクレデンシャルを確認し、不足しているツールがある場合はユーザーに通知すること呼び出し元 ID を確認し、ワークグループを一覧表示して、最適なものを自動選択します(workgroup-selection.md 参照)。
制約:
ユーザーがテーブルを名前、ビジネス概念(「四半期レポート」「販売データ」など)、S3 パス、またはテーブルを指定せずカタログのみで参照している場合は、finding-data-lake-assets に委譲して具体的な database.table(デフォルト以外の場合はカタログも含む)を返します。
制約:
athena list-data-catalogs を使用したり get-tables を反復したりしてはならない — フェデレーテッドカタログが漏れ、トークンの無駄遣いになるためdatabase.table)またはそのまま実行したい生の SQL を提供した場合のみ、このステップをスキップしてよいfinding-data-lake-assets が別のカタログを返した場合を除き、デフォルトの Glue カタログを使用すること分析クエリを実行する場合は、最終クエリを構築する前に対象テーブルをプロファイリングしてください。
プロファイリングの一環として、サンプル行(SELECT ... LIMIT 5)を必ず表示すること。
テーブルの参照方法はカタログの種類によって異なります:
database.table(単一カタログのクエリではカタログプレフィックスを省略)。クロスカタログクエリでは、デフォルトカタログのテーブルを "awsdatacatalog".database.table と修飾するdatasource.database.table"catalog/subcatalog".database.tableSQL ステートメントを実行前に分類します:
| ステートメント | 動作 |
|---|---|
SELECT、SHOW、DESCRIBE、EXPLAIN |
安全 — そのまま実行 |
INSERT、UPDATE、DELETE、DROP、ALTER、CREATE、TRUNCATE、MERGE |
破壊的操作 — ユーザーに警告し、明示的な確認を求める |
| 判断できない場合 | 破壊的操作として扱い、確認する |
ツール呼び出しの例(AWS MCP サーバー経由):
aws___call_aws(command="aws athena start-query-execution --work-group <WORKGROUP_NAME> --query-string '<sql>' --query-execution-context Database=<db>")
フェデレーテッドカタログまたは S3 Tables カタログの場合は、実行コンテキストに Catalog=<CATALOG_PATH> も設定すること(例: Catalog=s3tablescatalog/<BUCKET_NAME>)。
制約:
コスト、スキャンデータ量、処理時間、実用的なインサイトとともに結果を提示します。 失敗した場合は利用可能なワークグループを一覧表示し、どのワークグループで再試行するかをユーザーが選択できるようにします。
以下の順序で解決し、最初に一致した時点で停止します:
SELECT、SHOW、DESCRIBE、INSERT など)を含む → SQL テキストとして直接実行profile TABLE_NAME → 包括的なテーブルプロファイリングを実行(query-patterns.md 参照)exploring-data-catalog に委譲してデータベースとテーブルを列挙LIMIT を提案する| エラー | 原因 | 対処法 |
|---|---|---|
| 大文字小文字混在による Redshift 識別子エラー | Redshift フェデレーテッドの名前は小文字のみ | 識別子を小文字に変換する |
CatalogId バリデーションエラー |
ARN がカタログ名の代わりに渡された | ARN ではなくカタログ名を渡す |
クロスカタログの information_schema が何も返さない |
カタログ修飾子の欠落 | カタログ修飾パスを使用する: "catalog".information_schema.tables |
| 出力場所エラーでクエリ失敗 | ワークグループに出力場所が設定されていない | 出力場所が設定された別のワークグループを選択するか、出力場所を設定する |
| 確認なしに破壊的ステートメントが実行された | ステートメント分類がスキップされた | INSERT/UPDATE/DELETE/DROP/ALTER/CREATE/TRUNCATE/MERGE は必ず分類し、ユーザーに確認を求める |
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).
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)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 |
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。