Athena

Amazon Athena queries data in Amazon S3 with SQL. Start a query, check its execution status, then retrieve the results; cancel a query when needed. Run parameterized queries with execution parameters and prepared statements, reuse recent results, and read runtime statistics after a query completes. The integration also manages named queries, browses data catalogs, databases, and table schemas, and inspects workgroup configuration. Connect with an AWS access key and secret access key.

Usage Instructions

Integrate AWS Athena into workflows. Execute SQL queries against data in S3, check query status and runtime statistics, retrieve results, manage named queries and prepared statements, and inspect data catalogs, databases, tables, and workgroups. Requires AWS access key and secret access key.

Actions

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)
executionParametersjsonNoValues for ? placeholders in a parameterized query or EXECUTE statement, applied in order. Pass a JSON array of strings (e.g. ["2024-01-01", "US"]); a plain comma-separated list is also accepted when no value contains a comma
resultReuseEnabledbooleanNoReuse a previous result of the same query instead of re-scanning data (default: false)
resultReuseMaxAgeInMinutesnumberNoMaximum age in minutes of a previous result eligible for reuse (0-10080, default: 60)

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 Executions

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
queryExecutionIdstringQuery execution ID
querystringSQL query string
statestringQuery state (QUEUED, RUNNING, SUCCEEDED, FAILED, CANCELLED)
stateChangeReasonstringReason for state change
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
unprocessedQueryExecutionIdsarrayQuery execution IDs that could not be retrieved, with error details
queryExecutionIdstringQuery execution ID
errorCodestringError code
errorMessagestringError message

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, parameters)
namestringDatabase name
descriptionstringDatabase description
parametersjsonKey/value properties set on the database
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, parameters)
namestringTable name
tableTypestringTable type
createTimenumberTable creation time (Unix epoch ms)
lastAccessTimenumberTable last access time (Unix epoch ms)
columnsarrayColumn definitions
namestringColumn name
typestringColumn data type
commentstringColumn comment
partitionKeysarrayPartition key definitions
namestringPartition key name
typestringPartition key data type
commentstringPartition key comment
parametersjsonKey/value table properties (e.g., classification, location)
nextTokenstringPagination token for next page

Athena Get Query Runtime Statistics

Get runtime statistics (timeline, row counts, and output stage) for 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 runtime statistics for

Output

ParameterTypeDescription
queryExecutionIdstringQuery execution ID
timelinejsonTiming breakdown in milliseconds (available once the query has SUCCEEDED or FAILED)
queryQueueTimeInMillisnumberTime spent in queue
servicePreProcessingTimeInMillisnumberService pre-processing time
queryPlanningTimeInMillisnumberQuery planning time
engineExecutionTimeInMillisnumberEngine execution time
serviceProcessingTimeInMillisnumberService processing time
totalExecutionTimeInMillisnumberTotal execution time
rowStatisticsjsonRow and byte counts (updated asynchronously; may be null shortly after completion)
inputRowsnumberRows read
inputBytesnumberBytes read
outputRowsnumberRows produced
outputBytesnumberBytes produced
outputStagejsonSummary of the final query stage
stageIdnumberStage identifier
statestringStage state
inputRowsnumberRows read by the stage
inputBytesnumberBytes read by the stage
outputRowsnumberRows produced by the stage
outputBytesnumberBytes produced by the stage
executionTimenumberStage execution time in milliseconds
subStageCountnumberNumber of direct sub-stages

Athena Batch Get Named Queries

Get the details of up to 50 Athena named queries by ID in a single call

Input

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

Output

ParameterTypeDescription
namedQueriesarrayDetails for each named query that was found
namedQueryIdstringNamed query ID
namestringNamed query name
descriptionstringNamed query description
databasestringDatabase the query runs against
queryStringstringSQL text of the named query
workGroupstringWorkgroup the query is saved in
unprocessedNamedQueryIdsarrayNamed query IDs that could not be retrieved, with error details
namedQueryIdstringNamed query ID
errorCodestringError code
errorMessagestringError message

Athena Update Named Query

Update the name, description, or SQL of an existing Athena named query (database and workgroup cannot change)

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
namedQueryIdstringYesNamed query ID to update
namestringYesNew name for the query (1-128 characters)
queryStringstringYesNew SQL query text
descriptionstringNoNew description; omit to keep the current one, or pass an empty string to clear it

Output

ParameterTypeDescription
successbooleanWhether the operation succeeded

Athena Create Prepared Statement

Create a parameterized prepared statement in an Athena workgroup for use with EXECUTE or execution parameters

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
statementNamestringYesPrepared statement name (letters, digits, _ @ : ; must start with a letter or underscore)
workGroupstringYesWorkgroup the prepared statement belongs to
queryStatementstringYesSQL statement with ? placeholders for parameters
descriptionstringNoDescription of the prepared statement

Output

ParameterTypeDescription
successbooleanWhether the operation succeeded

Athena Get Prepared Statement

Get the SQL and metadata of a prepared statement in an Athena workgroup

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
statementNamestringYesPrepared statement name (letters, digits, _ @ : ; must start with a letter or underscore)
workGroupstringYesWorkgroup the prepared statement belongs to

Output

ParameterTypeDescription
statementNamestringPrepared statement name
queryStatementstringSQL text of the prepared statement
workGroupNamestringWorkgroup the statement belongs to
descriptionstringPrepared statement description
lastModifiedTimenumberLast modified time (Unix epoch ms)

Athena Batch Get Prepared Statements

Get the details of up to 256 prepared statements in an Athena workgroup by name in a single call

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
preparedStatementNamesstringYesComma-separated prepared statement names (up to 256)
workGroupstringYesWorkgroup the prepared statement belongs to

Output

ParameterTypeDescription
preparedStatementsarrayDetails for each prepared statement that was found
statementNamestringPrepared statement name
queryStatementstringSQL text of the prepared statement
workGroupNamestringWorkgroup the statement belongs to
descriptionstringPrepared statement description
lastModifiedTimenumberLast modified time (Unix epoch ms)
unprocessedPreparedStatementNamesarrayStatement names that could not be retrieved, with error details
statementNamestringPrepared statement name
errorCodestringError code
errorMessagestringError message

Athena Update Prepared Statement

Replace the SQL and description of an existing prepared statement in an Athena workgroup

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
statementNamestringYesPrepared statement name (letters, digits, _ @ : ; must start with a letter or underscore)
workGroupstringYesWorkgroup the prepared statement belongs to
queryStatementstringYesNew SQL statement with ? placeholders for parameters
descriptionstringNoNew description of the prepared statement

Output

ParameterTypeDescription
successbooleanWhether the operation succeeded

Athena List Prepared Statements

List the prepared statements saved in an Athena workgroup

Input

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

Output

ParameterTypeDescription
preparedStatementsarrayPrepared statement summaries
statementNamestringPrepared statement name
lastModifiedTimenumberLast modified time (Unix epoch ms)
nextTokenstringPagination token for next page

Athena Delete Prepared Statement

Delete a prepared statement from an Athena workgroup

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
statementNamestringYesPrepared statement name (letters, digits, _ @ : ; must start with a letter or underscore)
workGroupstringYesWorkgroup the prepared statement belongs to

Output

ParameterTypeDescription
successbooleanWhether the operation succeeded

Athena List Data Catalogs

List the data catalogs (data sources) registered in the AWS account

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
workGroupstringNoWorkgroup name (required for IAM Identity Center requests)
maxResultsnumberNoMaximum number of results (2-50)
nextTokenstringNoPagination token from a previous request

Output

ParameterTypeDescription
dataCatalogsarrayData catalog summaries
catalogNamestringCatalog name
typestringCatalog type (LAMBDA, GLUE, HIVE, FEDERATED)
statusstringCreation or deletion status (e.g., CREATE_COMPLETE)
connectionTypestringConnector type for FEDERATED catalogs (e.g., MYSQL, REDSHIFT)
errorstringError text from catalog creation or deletion
nextTokenstringPagination token for next page

Athena Get Data Catalog

Get the type, status, and connection parameters of an Athena data catalog

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
namestringYesData catalog name (e.g., AwsDataCatalog)
workGroupstringNoWorkgroup name (required for IAM Identity Center requests)

Output

ParameterTypeDescription
namestringCatalog name
typestringCatalog type (LAMBDA, GLUE, HIVE, FEDERATED)
descriptionstringCatalog description
statusstringCreation or deletion status (e.g., CREATE_COMPLETE)
connectionTypestringConnector type for FEDERATED catalogs (e.g., MYSQL, REDSHIFT)
errorstringError text from catalog creation or deletion
parametersjsonCatalog connection parameters (e.g., catalog-id, function ARN)

Athena Get Database

Get a single database (name, description, and parameters) from an Athena data catalog

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
workGroupstringNoWorkgroup name (required for IAM Identity Center enabled catalogs)

Output

ParameterTypeDescription
namestringDatabase name
descriptionstringDatabase description
parametersjsonKey/value properties set on the database

Athena Get Table Metadata

Get the columns, partition keys, and properties of a single table in an Athena data catalog 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
tableNamestringYesTable name
workGroupstringNoWorkgroup name (required for IAM Identity Center enabled catalogs)

Output

ParameterTypeDescription
namestringTable name
tableTypestringTable type (e.g., EXTERNAL_TABLE, VIRTUAL_VIEW)
createTimenumberTable creation time (Unix epoch ms)
lastAccessTimenumberLast access time (Unix epoch ms)
columnsarrayTable columns
namestringColumn name
typestringColumn data type
commentstringColumn comment
partitionKeysarrayPartition key columns
namestringColumn name
typestringColumn data type
commentstringColumn comment
parametersjsonKey/value table properties (e.g., classification, location)

Athena List Workgroups

List the Athena workgroups available in the AWS account

Input

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

Output

ParameterTypeDescription
workGroupsarrayWorkgroup summaries
namestringWorkgroup name
statestringWorkgroup state (ENABLED, DISABLED)
descriptionstringWorkgroup description
creationTimenumberCreation time (Unix epoch ms)
engineVersionjsonEngine version setting (selected and effective versions)
selectedEngineVersionstringRequested engine version
effectiveEngineVersionstringEngine version Athena actually uses
identityCenterApplicationArnstringIAM Identity Center application ARN
nextTokenstringPagination token for next page

Athena Get Workgroup

Get the configuration of an Athena workgroup, including its result location, encryption, and limits

Input

ParameterTypeRequiredDescription
awsRegionstringYesAWS region (e.g., us-east-1)
awsAccessKeyIdstringYesAWS access key ID
awsSecretAccessKeystringYesAWS secret access key
workGroupstringYesWorkgroup name

Output

ParameterTypeDescription
namestringWorkgroup name
statestringWorkgroup state (ENABLED, DISABLED)
descriptionstringWorkgroup description
creationTimenumberCreation time (Unix epoch ms)
identityCenterApplicationArnstringIAM Identity Center application ARN
engineVersionjsonEngine version setting (selected and effective versions)
selectedEngineVersionstringRequested engine version
effectiveEngineVersionstringEngine version Athena actually uses
outputLocationstringS3 location where query results are written
encryptionOptionstringResult encryption option (SSE_S3, SSE_KMS, CSE_KMS)
kmsKeystringKMS key ARN or ID used for result encryption
expectedBucketOwnerstringExpected AWS account ID of the results bucket owner
managedQueryResultsEnabledbooleanWhether results are stored in Athena-owned storage
enforceWorkGroupConfigurationbooleanWhether workgroup settings override client-side settings
publishCloudWatchMetricsEnabledbooleanWhether CloudWatch metrics are published for the workgroup
bytesScannedCutoffPerQuerynumberPer-query data scan limit in bytes
requesterPaysEnabledbooleanWhether Requester Pays S3 buckets may be queried
enableMinimumEncryptionConfigurationbooleanWhether a minimum encryption level is enforced
executionRolestringExecution role ARN for Spark or IAM Identity Center workgroups