Mandala
Tools

Athena

Run SQL queries on data in Amazon S3 using AWS Athena

Usage Instructions

Integrate AWS Athena into workflows. Execute SQL queries against data in S3, check query status, retrieve results, manage named queries, and list executions. Requires AWS access key and secret access key.

Tools

athena_start_query

Start an SQL query execution in AWS Athena

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
queryStringstringYesSQL query string to execute
databasestringNoDatabase name within the catalog
catalogstringNoData catalog name (default: AwsDataCatalog)
outputLocationstringNoS3 output location for query results (e.g., s3://bucket/path/)
workGroupstringNoWorkgroup to execute the query in (default: primary)

Output

ParameterTypeDescription
queryExecutionIdstringUnique ID of the started query execution

athena_get_query_execution

Get the status and details of an Athena query execution

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
queryExecutionIdstringYesQuery execution ID to check

Output

ParameterTypeDescription
queryExecutionIdstringQuery execution ID
querystringSQL query string
statestringQuery state (QUEUED, RUNNING, SUCCEEDED, FAILED, CANCELLED)
stateChangeReasonstringReason for state change (e.g., error message)
statementTypestringStatement type (DDL, DML, UTILITY)
databasestringDatabase name
catalogstringData catalog name
workGroupstringWorkgroup name
submissionDateTimenumberQuery submission time (Unix epoch ms)
completionDateTimenumberQuery completion time (Unix epoch ms)
dataScannedInBytesnumberAmount of data scanned in bytes
engineExecutionTimeInMillisnumberEngine execution time in milliseconds
queryPlanningTimeInMillisnumberQuery planning time in milliseconds
queryQueueTimeInMillisnumberTime the query spent in queue in milliseconds
totalExecutionTimeInMillisnumberTotal execution time in milliseconds
outputLocationstringS3 location of query results

athena_get_query_results

Retrieve the results of a completed Athena query execution

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
queryExecutionIdstringYesQuery execution ID to get results for
maxResultsnumberNoMaximum number of rows to return (1-999)
nextTokenstringNoPagination token from a previous request

Output

ParameterTypeDescription
columnsarrayColumn metadata (name and type)
rowsarrayResult rows as key-value objects
nextTokenstringPagination token for next page of results
updateCountnumberNumber of rows affected (for INSERT/UPDATE statements)

athena_stop_query

Stop a running Athena query execution

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
queryExecutionIdstringYesQuery execution ID to stop

Output

ParameterTypeDescription
successbooleanWhether the query was successfully stopped

athena_list_query_executions

List recent Athena query execution IDs

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
workGroupstringNoWorkgroup to list executions for (default: primary)
maxResultsnumberNoMaximum number of results (0-50)
nextTokenstringNoPagination token from a previous request

Output

ParameterTypeDescription
queryExecutionIdsarrayList of query execution IDs
nextTokenstringPagination token for next page

athena_batch_get_query_execution

Get the status and details of up to 50 Athena query executions in one call

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
queryExecutionIdsstringYesComma-separated query execution IDs to check (up to 50)

Output

ParameterTypeDescription
queryExecutionsarrayDetails for each successfully retrieved query execution
unprocessedQueryExecutionIdsarrayQuery execution IDs that could not be retrieved, with error details

athena_create_named_query

Create a saved/named query in AWS Athena

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
namestringYesName for the saved query
databasestringYesDatabase the query runs against
queryStringstringYesSQL query string to save
descriptionstringNoDescription of the named query
workGroupstringNoWorkgroup to create the named query in

Output

ParameterTypeDescription
namedQueryIdstringID of the created named query

athena_get_named_query

Get details of a saved/named query in AWS Athena

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
namedQueryIdstringYesNamed query ID to retrieve

Output

ParameterTypeDescription
namedQueryIdstringNamed query ID
namestringName of the saved query
descriptionstringQuery description
databasestringDatabase the query runs against
queryStringstringSQL query string
workGroupstringWorkgroup name

athena_list_named_queries

List saved/named query IDs in AWS Athena

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
workGroupstringNoWorkgroup to list named queries for
maxResultsnumberNoMaximum number of results (0-50)
nextTokenstringNoPagination token from a previous request

Output

ParameterTypeDescription
namedQueryIdsarrayList of named query IDs
nextTokenstringPagination token for next page

athena_delete_named_query

Delete a saved/named query in AWS Athena

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
namedQueryIdstringYesNamed query ID to delete

Output

ParameterTypeDescription
successbooleanWhether the named query was successfully deleted

athena_list_databases

List the databases available in an Athena data catalog

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
catalogNamestringYesData catalog name to list databases from (e.g., AwsDataCatalog)
workGroupstringNoWorkgroup for which the metadata is being fetched (required for IAM Identity Center enabled catalogs)
maxResultsnumberNoMaximum number of results (1-50)
nextTokenstringNoPagination token from a previous request

Output

ParameterTypeDescription
databasesarrayList of databases (name, description)
nextTokenstringPagination token for next page

athena_list_table_metadata

List tables and their column/partition metadata for an Athena database

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
catalogNamestringYesData catalog name (e.g., AwsDataCatalog)
databaseNamestringYesDatabase name to list tables from
expressionstringNoRegex filter that pattern-matches table names
workGroupstringNoWorkgroup for which the metadata is being fetched (required for IAM Identity Center enabled catalogs)
maxResultsnumberNoMaximum number of results (1-50)
nextTokenstringNoPagination token from a previous request

Output

ParameterTypeDescription
tablesarrayTable metadata (name, type, columns, partition keys)
nextTokenstringPagination token for next page

Notes

  • Category: tools
  • Type: athena
Athena