Amazon Athena

2019/02/18 - Amazon Athena - 5 new 8 updated api methods

Changes  This release adds support for Workgroups to Amazon Athena. Use Workgroups to isolate users, teams, applications or workloads in the same account, control costs by setting up query limits and creating Amazon SNS alarms, and publish query-related metrics to Amazon CloudWatch.

CreateWorkGroup (new) Link ¶

Creates a workgroup with the specified name.

See also: AWS API Documentation

Request Syntax

client.create_work_group(
    Name='string',
    Configuration={
        'ResultConfiguration': {
            'OutputLocation': 'string',
            'EncryptionConfiguration': {
                'EncryptionOption': 'SSE_S3'|'SSE_KMS'|'CSE_KMS',
                'KmsKey': 'string'
            }
        },
        'EnforceWorkGroupConfiguration': True|False,
        'PublishCloudWatchMetricsEnabled': True|False,
        'BytesScannedCutoffPerQuery': 123
    },
    Description='string'
)
type Name

string

param Name

[REQUIRED]

The workgroup name.

type Configuration

dict

param Configuration

The configuration for the workgroup, which includes the location in Amazon S3 where query results are stored, the encryption configuration, if any, used for encrypting query results, whether the Amazon CloudWatch Metrics are enabled for the workgroup, the limit for the amount of bytes scanned (cutoff) per query, if it is specified, and whether workgroup's settings (specified with EnforceWorkGroupConfiguration) in the WorkGroupConfiguration override client-side settings. See WorkGroupConfiguration$EnforceWorkGroupConfiguration .

  • ResultConfiguration (dict) --

    The configuration for the workgroup, which includes the location in Amazon S3 where query results are stored and the encryption option, if any, used for query results.

    • OutputLocation (string) --

      The location in Amazon S3 where your query results are stored, such as s3://path/to/query/bucket/ . For more information, see Queries and Query Result Files. If workgroup settings override client-side settings, then the query uses the location for the query results and the encryption configuration that are specified for the workgroup. The "workgroup settings override" is specified in EnforceWorkGroupConfiguration (true/false) in the WorkGroupConfiguration. See WorkGroupConfiguration$EnforceWorkGroupConfiguration .

    • EncryptionConfiguration (dict) --

      If query results are encrypted in Amazon S3, indicates the encryption option used (for example, SSE-KMS or CSE-KMS ) and key information. This is a client-side setting. If workgroup settings override client-side settings, then the query uses the encryption configuration that is specified for the workgroup, and also uses the location for storing query results specified in the workgroup. See WorkGroupConfiguration$EnforceWorkGroupConfiguration and Workgroup Settings Override Client-Side Settings .

      • EncryptionOption (string) -- [REQUIRED]

        Indicates whether Amazon S3 server-side encryption with Amazon S3-managed keys (SSE-S3 ), server-side encryption with KMS-managed keys (SSE-KMS ), or client-side encryption with KMS-managed keys (CSE-KMS) is used.

        If a query runs in a workgroup and the workgroup overrides client-side settings, then the workgroup's setting for encryption is used. It specifies whether query results must be encrypted, for all queries that run in this workgroup.

      • KmsKey (string) --

        For SSE-KMS and CSE-KMS , this is the KMS key ARN or ID.

  • EnforceWorkGroupConfiguration (boolean) --

    If set to "true", the settings for the workgroup override client-side settings. If set to "false", client-side settings are used. For more information, see Workgroup Settings Override Client-Side Settings .

  • PublishCloudWatchMetricsEnabled (boolean) --

    Indicates that the Amazon CloudWatch metrics are enabled for the workgroup.

  • BytesScannedCutoffPerQuery (integer) --

    The upper data usage limit (cutoff) for the amount of bytes a single query in a workgroup is allowed to scan.

type Description

string

param Description

The workgroup description.

rtype

dict

returns

Response Syntax

{}

Response Structure

  • (dict) --

GetWorkGroup (new) Link ¶

Returns information about the workgroup with the speficied name.

See also: AWS API Documentation

Request Syntax

client.get_work_group(
    WorkGroup='string'
)
type WorkGroup

string

param WorkGroup

[REQUIRED]

The name of the workgroup.

rtype

dict

returns

Response Syntax

{
    'WorkGroup': {
        'Name': 'string',
        'State': 'ENABLED'|'DISABLED',
        'Configuration': {
            'ResultConfiguration': {
                'OutputLocation': 'string',
                'EncryptionConfiguration': {
                    'EncryptionOption': 'SSE_S3'|'SSE_KMS'|'CSE_KMS',
                    'KmsKey': 'string'
                }
            },
            'EnforceWorkGroupConfiguration': True|False,
            'PublishCloudWatchMetricsEnabled': True|False,
            'BytesScannedCutoffPerQuery': 123
        },
        'Description': 'string',
        'CreationTime': datetime(2015, 1, 1)
    }
}

Response Structure

  • (dict) --

    • WorkGroup (dict) --

      Information about the workgroup.

      • Name (string) --

        The workgroup name.

      • State (string) --

        The state of the workgroup: ENABLED or DISABLED.

      • Configuration (dict) --

        The configuration of the workgroup, which includes the location in Amazon S3 where query results are stored, the encryption configuration, if any, used for query results; whether the Amazon CloudWatch Metrics are enabled for the workgroup; whether workgroup settings override client-side settings; and the data usage limit for the amount of data scanned per query, if it is specified. The workgroup settings override is specified in EnforceWorkGroupConfiguration (true/false) in the WorkGroupConfiguration. See WorkGroupConfiguration$EnforceWorkGroupConfiguration .

        • ResultConfiguration (dict) --

          The configuration for the workgroup, which includes the location in Amazon S3 where query results are stored and the encryption option, if any, used for query results.

          • OutputLocation (string) --

            The location in Amazon S3 where your query results are stored, such as s3://path/to/query/bucket/ . For more information, see Queries and Query Result Files. If workgroup settings override client-side settings, then the query uses the location for the query results and the encryption configuration that are specified for the workgroup. The "workgroup settings override" is specified in EnforceWorkGroupConfiguration (true/false) in the WorkGroupConfiguration. See WorkGroupConfiguration$EnforceWorkGroupConfiguration .

          • EncryptionConfiguration (dict) --

            If query results are encrypted in Amazon S3, indicates the encryption option used (for example, SSE-KMS or CSE-KMS ) and key information. This is a client-side setting. If workgroup settings override client-side settings, then the query uses the encryption configuration that is specified for the workgroup, and also uses the location for storing query results specified in the workgroup. See WorkGroupConfiguration$EnforceWorkGroupConfiguration and Workgroup Settings Override Client-Side Settings .

            • EncryptionOption (string) --

              Indicates whether Amazon S3 server-side encryption with Amazon S3-managed keys (SSE-S3 ), server-side encryption with KMS-managed keys (SSE-KMS ), or client-side encryption with KMS-managed keys (CSE-KMS) is used.

              If a query runs in a workgroup and the workgroup overrides client-side settings, then the workgroup's setting for encryption is used. It specifies whether query results must be encrypted, for all queries that run in this workgroup.

            • KmsKey (string) --

              For SSE-KMS and CSE-KMS , this is the KMS key ARN or ID.

        • EnforceWorkGroupConfiguration (boolean) --

          If set to "true", the settings for the workgroup override client-side settings. If set to "false", client-side settings are used. For more information, see Workgroup Settings Override Client-Side Settings .

        • PublishCloudWatchMetricsEnabled (boolean) --

          Indicates that the Amazon CloudWatch metrics are enabled for the workgroup.

        • BytesScannedCutoffPerQuery (integer) --

          The upper data usage limit (cutoff) for the amount of bytes a single query in a workgroup is allowed to scan.

      • Description (string) --

        The workgroup description.

      • CreationTime (datetime) --

        The date and time the workgroup was created.

ListWorkGroups (new) Link ¶

Lists available workgroups for the account.

See also: AWS API Documentation

Request Syntax

client.list_work_groups(
    NextToken='string',
    MaxResults=123
)
type NextToken

string

param NextToken

A token to be used by the next request if this request is truncated.

type MaxResults

integer

param MaxResults

The maximum number of workgroups to return in this request.

rtype

dict

returns

Response Syntax

{
    'WorkGroups': [
        {
            'Name': 'string',
            'State': 'ENABLED'|'DISABLED',
            'Description': 'string',
            'CreationTime': datetime(2015, 1, 1)
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • WorkGroups (list) --

      The list of workgroups, including their names, descriptions, creation times, and states.

      • (dict) --

        The summary information for the workgroup, which includes its name, state, description, and the date and time it was created.

        • Name (string) --

          The name of the workgroup.

        • State (string) --

          The state of the workgroup.

        • Description (string) --

          The workgroup description.

        • CreationTime (datetime) --

          The workgroup creation date and time.

    • NextToken (string) --

      A token to be used by the next request if this request is truncated.

UpdateWorkGroup (new) Link ¶

Updates the workgroup with the specified name. The workgroup's name cannot be changed.

See also: AWS API Documentation

Request Syntax

client.update_work_group(
    WorkGroup='string',
    Description='string',
    ConfigurationUpdates={
        'EnforceWorkGroupConfiguration': True|False,
        'ResultConfigurationUpdates': {
            'OutputLocation': 'string',
            'RemoveOutputLocation': True|False,
            'EncryptionConfiguration': {
                'EncryptionOption': 'SSE_S3'|'SSE_KMS'|'CSE_KMS',
                'KmsKey': 'string'
            },
            'RemoveEncryptionConfiguration': True|False
        },
        'PublishCloudWatchMetricsEnabled': True|False,
        'BytesScannedCutoffPerQuery': 123,
        'RemoveBytesScannedCutoffPerQuery': True|False
    },
    State='ENABLED'|'DISABLED'
)
type WorkGroup

string

param WorkGroup

[REQUIRED]

The specified workgroup that will be updated.

type Description

string

param Description

The workgroup description.

type ConfigurationUpdates

dict

param ConfigurationUpdates

The workgroup configuration that will be updated for the given workgroup.

  • EnforceWorkGroupConfiguration (boolean) --

    If set to "true", the settings for the workgroup override client-side settings. If set to "false" client-side settings are used. For more information, see Workgroup Settings Override Client-Side Settings .

  • ResultConfigurationUpdates (dict) --

    The result configuration information about the queries in this workgroup that will be updated. Includes the updated results location and an updated option for encrypting query results.

    • OutputLocation (string) --

      The location in Amazon S3 where your query results are stored, such as s3://path/to/query/bucket/ . For more information, see Queries and Query Result Files. If workgroup settings override client-side settings, then the query uses the location for the query results and the encryption configuration that are specified for the workgroup. The "workgroup settings override" is specified in EnforceWorkGroupConfiguration (true/false) in the WorkGroupConfiguration. See WorkGroupConfiguration$EnforceWorkGroupConfiguration .

    • RemoveOutputLocation (boolean) --

      If set to "true", indicates that the previously-specified query results location (also known as a client-side setting) for queries in this workgroup should be ignored and set to null. If set to "false" or not set, and a value is present in the OutputLocation in ResultConfigurationUpdates (the client-side setting), the OutputLocation in the workgroup's ResultConfiguration will be updated with the new value. For more information, see Workgroup Settings Override Client-Side Settings .

    • EncryptionConfiguration (dict) --

      The encryption configuration for the query results.

      • EncryptionOption (string) -- [REQUIRED]

        Indicates whether Amazon S3 server-side encryption with Amazon S3-managed keys (SSE-S3 ), server-side encryption with KMS-managed keys (SSE-KMS ), or client-side encryption with KMS-managed keys (CSE-KMS) is used.

        If a query runs in a workgroup and the workgroup overrides client-side settings, then the workgroup's setting for encryption is used. It specifies whether query results must be encrypted, for all queries that run in this workgroup.

      • KmsKey (string) --

        For SSE-KMS and CSE-KMS , this is the KMS key ARN or ID.

    • RemoveEncryptionConfiguration (boolean) --

      If set to "true", indicates that the previously-specified encryption configuration (also known as the client-side setting) for queries in this workgroup should be ignored and set to null. If set to "false" or not set, and a value is present in the EncryptionConfiguration in ResultConfigurationUpdates (the client-side setting), the EncryptionConfiguration in the workgroup's ResultConfiguration will be updated with the new value. For more information, see Workgroup Settings Override Client-Side Settings .

  • PublishCloudWatchMetricsEnabled (boolean) --

    Indicates whether this workgroup enables publishing metrics to Amazon CloudWatch.

  • BytesScannedCutoffPerQuery (integer) --

    The upper limit (cutoff) for the amount of bytes a single query in a workgroup is allowed to scan.

  • RemoveBytesScannedCutoffPerQuery (boolean) --

    Indicates that the data usage control limit per query is removed. WorkGroupConfiguration$BytesScannedCutoffPerQuery

type State

string

param State

The workgroup state that will be updated for the given workgroup.

rtype

dict

returns

Response Syntax

{}

Response Structure

  • (dict) --

DeleteWorkGroup (new) Link ¶

Deletes the workgroup with the specified name. The primary workgroup cannot be deleted.

See also: AWS API Documentation

Request Syntax

client.delete_work_group(
    WorkGroup='string',
    RecursiveDeleteOption=True|False
)
type WorkGroup

string

param WorkGroup

[REQUIRED]

The unique name of the workgroup to delete.

type RecursiveDeleteOption

boolean

param RecursiveDeleteOption

The option to delete the workgroup and its contents even if the workgroup contains any named queries.

rtype

dict

returns

Response Syntax

{}

Response Structure

  • (dict) --

BatchGetNamedQuery (updated) Link ¶
Changes (response)
{'NamedQueries': {'WorkGroup': 'string'}}

Returns the details of a single named query or a list of up to 50 queries, which you provide as an array of query ID strings. Requires you to have access to the workgroup in which the queries were saved. Use ListNamedQueriesInput to get the list of named query IDs in the specified workgroup. If information could not be retrieved for a submitted query ID, information about the query ID submitted is listed under UnprocessedNamedQueryId . Named queries differ from executed queries. Use BatchGetQueryExecutionInput to get details about each unique query execution, and ListQueryExecutionsInput to get a list of query execution IDs.

See also: AWS API Documentation

Request Syntax

client.batch_get_named_query(
    NamedQueryIds=[
        'string',
    ]
)
type NamedQueryIds

list

param NamedQueryIds

[REQUIRED]

An array of query IDs.

  • (string) --

rtype

dict

returns

Response Syntax

{
    'NamedQueries': [
        {
            'Name': 'string',
            'Description': 'string',
            'Database': 'string',
            'QueryString': 'string',
            'NamedQueryId': 'string',
            'WorkGroup': 'string'
        },
    ],
    'UnprocessedNamedQueryIds': [
        {
            'NamedQueryId': 'string',
            'ErrorCode': 'string',
            'ErrorMessage': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • NamedQueries (list) --

      Information about the named query IDs submitted.

      • (dict) --

        A query, where QueryString is the list of SQL query statements that comprise the query.

        • Name (string) --

          The query name.

        • Description (string) --

          The query description.

        • Database (string) --

          The database to which the query belongs.

        • QueryString (string) --

          The SQL query statements that comprise the query.

        • NamedQueryId (string) --

          The unique identifier of the query.

        • WorkGroup (string) --

          The name of the workgroup that contains the named query.

    • UnprocessedNamedQueryIds (list) --

      Information about provided query IDs.

      • (dict) --

        Information about a named query ID that could not be processed.

        • NamedQueryId (string) --

          The unique identifier of the named query.

        • ErrorCode (string) --

          The error code returned when the processing request for the named query failed, if applicable.

        • ErrorMessage (string) --

          The error message returned when the processing request for the named query failed, if applicable.

BatchGetQueryExecution (updated) Link ¶
Changes (response)
{'QueryExecutions': {'WorkGroup': 'string'}}

Returns the details of a single query execution or a list of up to 50 query executions, which you provide as an array of query execution ID strings. Requires you to have access to the workgroup in which the queries ran. To get a list of query execution IDs, use ListQueryExecutionsInput$WorkGroup . Query executions differ from named (saved) queries. Use BatchGetNamedQueryInput to get details about named queries.

See also: AWS API Documentation

Request Syntax

client.batch_get_query_execution(
    QueryExecutionIds=[
        'string',
    ]
)
type QueryExecutionIds

list

param QueryExecutionIds

[REQUIRED]

An array of query execution IDs.

  • (string) --

rtype

dict

returns

Response Syntax

{
    'QueryExecutions': [
        {
            'QueryExecutionId': 'string',
            'Query': 'string',
            'StatementType': 'DDL'|'DML'|'UTILITY',
            'ResultConfiguration': {
                'OutputLocation': 'string',
                'EncryptionConfiguration': {
                    'EncryptionOption': 'SSE_S3'|'SSE_KMS'|'CSE_KMS',
                    'KmsKey': 'string'
                }
            },
            'QueryExecutionContext': {
                'Database': 'string'
            },
            'Status': {
                'State': 'QUEUED'|'RUNNING'|'SUCCEEDED'|'FAILED'|'CANCELLED',
                'StateChangeReason': 'string',
                'SubmissionDateTime': datetime(2015, 1, 1),
                'CompletionDateTime': datetime(2015, 1, 1)
            },
            'Statistics': {
                'EngineExecutionTimeInMillis': 123,
                'DataScannedInBytes': 123
            },
            'WorkGroup': 'string'
        },
    ],
    'UnprocessedQueryExecutionIds': [
        {
            'QueryExecutionId': 'string',
            'ErrorCode': 'string',
            'ErrorMessage': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • QueryExecutions (list) --

      Information about a query execution.

      • (dict) --

        Information about a single instance of a query execution.

        • QueryExecutionId (string) --

          The unique identifier for each query execution.

        • Query (string) --

          The SQL query statements which the query execution ran.

        • StatementType (string) --

          The type of query statement that was run. DDL indicates DDL query statements. DML indicates DML (Data Manipulation Language) query statements, such as CREATE TABLE AS SELECT . UTILITY indicates query statements other than DDL and DML, such as SHOW CREATE TABLE , or DESCRIBE <table> .

        • ResultConfiguration (dict) --

          The location in Amazon S3 where query results were stored and the encryption option, if any, used for query results. These are known as "client-side settings". If workgroup settings override client-side settings, then the query uses the location for the query results and the encryption configuration that are specified for the workgroup.

          • OutputLocation (string) --

            The location in Amazon S3 where your query results are stored, such as s3://path/to/query/bucket/ . For more information, see Queries and Query Result Files. If workgroup settings override client-side settings, then the query uses the location for the query results and the encryption configuration that are specified for the workgroup. The "workgroup settings override" is specified in EnforceWorkGroupConfiguration (true/false) in the WorkGroupConfiguration. See WorkGroupConfiguration$EnforceWorkGroupConfiguration .

          • EncryptionConfiguration (dict) --

            If query results are encrypted in Amazon S3, indicates the encryption option used (for example, SSE-KMS or CSE-KMS ) and key information. This is a client-side setting. If workgroup settings override client-side settings, then the query uses the encryption configuration that is specified for the workgroup, and also uses the location for storing query results specified in the workgroup. See WorkGroupConfiguration$EnforceWorkGroupConfiguration and Workgroup Settings Override Client-Side Settings .

            • EncryptionOption (string) --

              Indicates whether Amazon S3 server-side encryption with Amazon S3-managed keys (SSE-S3 ), server-side encryption with KMS-managed keys (SSE-KMS ), or client-side encryption with KMS-managed keys (CSE-KMS) is used.

              If a query runs in a workgroup and the workgroup overrides client-side settings, then the workgroup's setting for encryption is used. It specifies whether query results must be encrypted, for all queries that run in this workgroup.

            • KmsKey (string) --

              For SSE-KMS and CSE-KMS , this is the KMS key ARN or ID.

        • QueryExecutionContext (dict) --

          The database in which the query execution occurred.

          • Database (string) --

            The name of the database.

        • Status (dict) --

          The completion date, current state, submission time, and state change reason (if applicable) for the query execution.

          • State (string) --

            The state of query execution. QUEUED state is listed but is not used by Athena and is reserved for future use. RUNNING indicates that the query has been submitted to the service, and Athena will execute the query as soon as resources are available. SUCCEEDED indicates that the query completed without errors. FAILED indicates that the query experienced an error and did not complete processing. CANCELLED indicates that a user input interrupted query execution.

          • StateChangeReason (string) --

            Further detail about the status of the query.

          • SubmissionDateTime (datetime) --

            The date and time that the query was submitted.

          • CompletionDateTime (datetime) --

            The date and time that the query completed.

        • Statistics (dict) --

          The amount of data scanned during the query execution and the amount of time that it took to execute, and the type of statement that was run.

          • EngineExecutionTimeInMillis (integer) --

            The number of milliseconds that the query took to execute.

          • DataScannedInBytes (integer) --

            The number of bytes in the data that was queried.

        • WorkGroup (string) --

          The name of the workgroup in which the query ran.

    • UnprocessedQueryExecutionIds (list) --

      Information about the query executions that failed to run.

      • (dict) --

        Describes a query execution that failed to process.

        • QueryExecutionId (string) --

          The unique identifier of the query execution.

        • ErrorCode (string) --

          The error code returned when the query execution failed to process, if applicable.

        • ErrorMessage (string) --

          The error message returned when the query execution failed to process, if applicable.

CreateNamedQuery (updated) Link ¶
Changes (request)
{'WorkGroup': 'string'}

Creates a named query in the specified workgroup. Requires that you have access to the workgroup.

For code samples using the AWS SDK for Java, see Examples and Code Samples in the Amazon Athena User Guide .

See also: AWS API Documentation

Request Syntax

client.create_named_query(
    Name='string',
    Description='string',
    Database='string',
    QueryString='string',
    ClientRequestToken='string',
    WorkGroup='string'
)
type Name

string

param Name

[REQUIRED]

The query name.

type Description

string

param Description

The query description.

type Database

string

param Database

[REQUIRED]

The database to which the query belongs.

type QueryString

string

param QueryString

[REQUIRED]

The contents of the query with all query statements.

type ClientRequestToken

string

param ClientRequestToken

A unique case-sensitive string used to ensure the request to create the query is idempotent (executes only once). If another CreateNamedQuery request is received, the same response is returned and another query is not created. If a parameter has changed, for example, the QueryString , an error is returned.

Warning

This token is listed as not required because AWS SDKs (for example the AWS SDK for Java) auto-generate the token for users. If you are not using the AWS SDK or the AWS CLI, you must provide this token or the action will fail.

This field is autopopulated if not provided.

type WorkGroup

string

param WorkGroup

The name of the workgroup in which the named query is being created.

rtype

dict

returns

Response Syntax

{
    'NamedQueryId': 'string'
}

Response Structure

  • (dict) --

    • NamedQueryId (string) --

      The unique ID of the query.

GetNamedQuery (updated) Link ¶
Changes (response)
{'NamedQuery': {'WorkGroup': 'string'}}

Returns information about a single query. Requires that you have access to the workgroup in which the query was saved.

See also: AWS API Documentation

Request Syntax

client.get_named_query(
    NamedQueryId='string'
)
type NamedQueryId

string

param NamedQueryId

[REQUIRED]

The unique ID of the query. Use ListNamedQueries to get query IDs.

rtype

dict

returns

Response Syntax

{
    'NamedQuery': {
        'Name': 'string',
        'Description': 'string',
        'Database': 'string',
        'QueryString': 'string',
        'NamedQueryId': 'string',
        'WorkGroup': 'string'
    }
}

Response Structure

  • (dict) --

    • NamedQuery (dict) --

      Information about the query.

      • Name (string) --

        The query name.

      • Description (string) --

        The query description.

      • Database (string) --

        The database to which the query belongs.

      • QueryString (string) --

        The SQL query statements that comprise the query.

      • NamedQueryId (string) --

        The unique identifier of the query.

      • WorkGroup (string) --

        The name of the workgroup that contains the named query.

GetQueryExecution (updated) Link ¶
Changes (response)
{'QueryExecution': {'WorkGroup': 'string'}}

Returns information about a single execution of a query if you have access to the workgroup in which the query ran. Each time a query executes, information about the query execution is saved with a unique ID.

See also: AWS API Documentation

Request Syntax

client.get_query_execution(
    QueryExecutionId='string'
)
type QueryExecutionId

string

param QueryExecutionId

[REQUIRED]

The unique ID of the query execution.

rtype

dict

returns

Response Syntax

{
    'QueryExecution': {
        'QueryExecutionId': 'string',
        'Query': 'string',
        'StatementType': 'DDL'|'DML'|'UTILITY',
        'ResultConfiguration': {
            'OutputLocation': 'string',
            'EncryptionConfiguration': {
                'EncryptionOption': 'SSE_S3'|'SSE_KMS'|'CSE_KMS',
                'KmsKey': 'string'
            }
        },
        'QueryExecutionContext': {
            'Database': 'string'
        },
        'Status': {
            'State': 'QUEUED'|'RUNNING'|'SUCCEEDED'|'FAILED'|'CANCELLED',
            'StateChangeReason': 'string',
            'SubmissionDateTime': datetime(2015, 1, 1),
            'CompletionDateTime': datetime(2015, 1, 1)
        },
        'Statistics': {
            'EngineExecutionTimeInMillis': 123,
            'DataScannedInBytes': 123
        },
        'WorkGroup': 'string'
    }
}

Response Structure

  • (dict) --

    • QueryExecution (dict) --

      Information about the query execution.

      • QueryExecutionId (string) --

        The unique identifier for each query execution.

      • Query (string) --

        The SQL query statements which the query execution ran.

      • StatementType (string) --

        The type of query statement that was run. DDL indicates DDL query statements. DML indicates DML (Data Manipulation Language) query statements, such as CREATE TABLE AS SELECT . UTILITY indicates query statements other than DDL and DML, such as SHOW CREATE TABLE , or DESCRIBE <table> .

      • ResultConfiguration (dict) --

        The location in Amazon S3 where query results were stored and the encryption option, if any, used for query results. These are known as "client-side settings". If workgroup settings override client-side settings, then the query uses the location for the query results and the encryption configuration that are specified for the workgroup.

        • OutputLocation (string) --

          The location in Amazon S3 where your query results are stored, such as s3://path/to/query/bucket/ . For more information, see Queries and Query Result Files. If workgroup settings override client-side settings, then the query uses the location for the query results and the encryption configuration that are specified for the workgroup. The "workgroup settings override" is specified in EnforceWorkGroupConfiguration (true/false) in the WorkGroupConfiguration. See WorkGroupConfiguration$EnforceWorkGroupConfiguration .

        • EncryptionConfiguration (dict) --

          If query results are encrypted in Amazon S3, indicates the encryption option used (for example, SSE-KMS or CSE-KMS ) and key information. This is a client-side setting. If workgroup settings override client-side settings, then the query uses the encryption configuration that is specified for the workgroup, and also uses the location for storing query results specified in the workgroup. See WorkGroupConfiguration$EnforceWorkGroupConfiguration and Workgroup Settings Override Client-Side Settings .

          • EncryptionOption (string) --

            Indicates whether Amazon S3 server-side encryption with Amazon S3-managed keys (SSE-S3 ), server-side encryption with KMS-managed keys (SSE-KMS ), or client-side encryption with KMS-managed keys (CSE-KMS) is used.

            If a query runs in a workgroup and the workgroup overrides client-side settings, then the workgroup's setting for encryption is used. It specifies whether query results must be encrypted, for all queries that run in this workgroup.

          • KmsKey (string) --

            For SSE-KMS and CSE-KMS , this is the KMS key ARN or ID.

      • QueryExecutionContext (dict) --

        The database in which the query execution occurred.

        • Database (string) --

          The name of the database.

      • Status (dict) --

        The completion date, current state, submission time, and state change reason (if applicable) for the query execution.

        • State (string) --

          The state of query execution. QUEUED state is listed but is not used by Athena and is reserved for future use. RUNNING indicates that the query has been submitted to the service, and Athena will execute the query as soon as resources are available. SUCCEEDED indicates that the query completed without errors. FAILED indicates that the query experienced an error and did not complete processing. CANCELLED indicates that a user input interrupted query execution.

        • StateChangeReason (string) --

          Further detail about the status of the query.

        • SubmissionDateTime (datetime) --

          The date and time that the query was submitted.

        • CompletionDateTime (datetime) --

          The date and time that the query completed.

      • Statistics (dict) --

        The amount of data scanned during the query execution and the amount of time that it took to execute, and the type of statement that was run.

        • EngineExecutionTimeInMillis (integer) --

          The number of milliseconds that the query took to execute.

        • DataScannedInBytes (integer) --

          The number of bytes in the data that was queried.

      • WorkGroup (string) --

        The name of the workgroup in which the query ran.

ListNamedQueries (updated) Link ¶
Changes (request)
{'WorkGroup': 'string'}

Provides a list of available query IDs only for queries saved in the specified workgroup. Requires that you have access to the workgroup.

For code samples using the AWS SDK for Java, see Examples and Code Samples in the Amazon Athena User Guide .

See also: AWS API Documentation

Request Syntax

client.list_named_queries(
    NextToken='string',
    MaxResults=123,
    WorkGroup='string'
)
type NextToken

string

param NextToken

The token that specifies where to start pagination if a previous request was truncated.

type MaxResults

integer

param MaxResults

The maximum number of queries to return in this request.

type WorkGroup

string

param WorkGroup

The name of the workgroup from which the named queries are being returned.

rtype

dict

returns

Response Syntax

{
    'NamedQueryIds': [
        'string',
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • NamedQueryIds (list) --

      The list of unique query IDs.

      • (string) --

    • NextToken (string) --

      A token to be used by the next request if this request is truncated.

ListQueryExecutions (updated) Link ¶
Changes (request)
{'WorkGroup': 'string'}

Provides a list of available query execution IDs for the queries in the specified workgroup. Requires you to have access to the workgroup in which the queries ran.

For code samples using the AWS SDK for Java, see Examples and Code Samples in the Amazon Athena User Guide .

See also: AWS API Documentation

Request Syntax

client.list_query_executions(
    NextToken='string',
    MaxResults=123,
    WorkGroup='string'
)
type NextToken

string

param NextToken

The token that specifies where to start pagination if a previous request was truncated.

type MaxResults

integer

param MaxResults

The maximum number of query executions to return in this request.

type WorkGroup

string

param WorkGroup

The name of the workgroup from which queries are being returned.

rtype

dict

returns

Response Syntax

{
    'QueryExecutionIds': [
        'string',
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • QueryExecutionIds (list) --

      The unique IDs of each query execution as an array of strings.

      • (string) --

    • NextToken (string) --

      A token to be used by the next request if this request is truncated.

StartQueryExecution (updated) Link ¶
Changes (request)
{'WorkGroup': 'string'}

Runs the SQL query statements contained in the Query . Requires you to have access to the workgroup in which the query ran.

For code samples using the AWS SDK for Java, see Examples and Code Samples in the Amazon Athena User Guide .

See also: AWS API Documentation

Request Syntax

client.start_query_execution(
    QueryString='string',
    ClientRequestToken='string',
    QueryExecutionContext={
        'Database': 'string'
    },
    ResultConfiguration={
        'OutputLocation': 'string',
        'EncryptionConfiguration': {
            'EncryptionOption': 'SSE_S3'|'SSE_KMS'|'CSE_KMS',
            'KmsKey': 'string'
        }
    },
    WorkGroup='string'
)
type QueryString

string

param QueryString

[REQUIRED]

The SQL query statements to be executed.

type ClientRequestToken

string

param ClientRequestToken

A unique case-sensitive string used to ensure the request to create the query is idempotent (executes only once). If another StartQueryExecution request is received, the same response is returned and another query is not created. If a parameter has changed, for example, the QueryString , an error is returned.

Warning

This token is listed as not required because AWS SDKs (for example the AWS SDK for Java) auto-generate the token for users. If you are not using the AWS SDK or the AWS CLI, you must provide this token or the action will fail.

This field is autopopulated if not provided.

type QueryExecutionContext

dict

param QueryExecutionContext

The database within which the query executes.

  • Database (string) --

    The name of the database.

type ResultConfiguration

dict

param ResultConfiguration

Specifies information about where and how to save the results of the query execution. If the query runs in a workgroup, then workgroup's settings may override query settings. This affects the query results location. The workgroup settings override is specified in EnforceWorkGroupConfiguration (true/false) in the WorkGroupConfiguration. See WorkGroupConfiguration$EnforceWorkGroupConfiguration .

  • OutputLocation (string) --

    The location in Amazon S3 where your query results are stored, such as s3://path/to/query/bucket/ . For more information, see Queries and Query Result Files. If workgroup settings override client-side settings, then the query uses the location for the query results and the encryption configuration that are specified for the workgroup. The "workgroup settings override" is specified in EnforceWorkGroupConfiguration (true/false) in the WorkGroupConfiguration. See WorkGroupConfiguration$EnforceWorkGroupConfiguration .

  • EncryptionConfiguration (dict) --

    If query results are encrypted in Amazon S3, indicates the encryption option used (for example, SSE-KMS or CSE-KMS ) and key information. This is a client-side setting. If workgroup settings override client-side settings, then the query uses the encryption configuration that is specified for the workgroup, and also uses the location for storing query results specified in the workgroup. See WorkGroupConfiguration$EnforceWorkGroupConfiguration and Workgroup Settings Override Client-Side Settings .

    • EncryptionOption (string) -- [REQUIRED]

      Indicates whether Amazon S3 server-side encryption with Amazon S3-managed keys (SSE-S3 ), server-side encryption with KMS-managed keys (SSE-KMS ), or client-side encryption with KMS-managed keys (CSE-KMS) is used.

      If a query runs in a workgroup and the workgroup overrides client-side settings, then the workgroup's setting for encryption is used. It specifies whether query results must be encrypted, for all queries that run in this workgroup.

    • KmsKey (string) --

      For SSE-KMS and CSE-KMS , this is the KMS key ARN or ID.

type WorkGroup

string

param WorkGroup

The name of the workgroup in which the query is being started.

rtype

dict

returns

Response Syntax

{
    'QueryExecutionId': 'string'
}

Response Structure

  • (dict) --

    • QueryExecutionId (string) --

      The unique ID of the query that ran as a result of this request.