You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::Athena::Client

Inherits:
Seahorse::Client::Base show all
Defined in:
(unknown)

Overview

An API client for Amazon Athena. To construct a client, you need to configure a :region and :credentials.

athena = Aws::Athena::Client.new(
  region: region_name,
  credentials: credentials,
  # ...
)

See #initialize for a full list of supported configuration options.

Region

You can configure a default region in the following locations:

  • ENV['AWS_REGION']
  • Aws.config[:region]

Go here for a list of supported regions.

Credentials

Default credentials are loaded automatically from the following locations:

  • ENV['AWS_ACCESS_KEY_ID'] and ENV['AWS_SECRET_ACCESS_KEY']
  • Aws.config[:credentials]
  • The shared credentials ini file at ~/.aws/credentials (more information)
  • From an instance profile when running on EC2

You can also construct a credentials object from one of the following classes:

Alternatively, you configure credentials with :access_key_id and :secret_access_key:

# load credentials from disk
creds = YAML.load(File.read('/path/to/secrets'))

Aws::Athena::Client.new(
  access_key_id: creds['access_key_id'],
  secret_access_key: creds['secret_access_key']
)

Always load your credentials from outside your application. Avoid configuring credentials statically and never commit them to source control.

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Base

#config, #handlers

Constructor collapse

API Operations collapse

Instance Method Summary collapse

Methods inherited from Seahorse::Client::Base

add_plugin, api, #build_request, clear_plugins, define, new, #operation, #operation_names, plugins, remove_plugin, set_api, set_plugins

Methods included from Seahorse::Client::HandlerBuilder

#handle, #handle_request, #handle_response

Constructor Details

#initialize(options = {}) ⇒ Aws::Athena::Client

Constructs an API client.

Options Hash (options):

  • :access_key_id (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :active_endpoint_cache (Boolean)

    When set to true, a thread polling for endpoints will be running in the background every 60 secs (default). Defaults to false. See Plugins::EndpointDiscovery for more details.

  • :convert_params (Boolean) — default: true

    When true, an attempt is made to coerce request parameters into the required types. See Plugins::ParamConverter for more details.

  • :credentials (required, Credentials)

    Your AWS credentials. The following locations will be searched in order for credentials:

    • :access_key_id, :secret_access_key, and :session_token options
    • ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
    • HOME/.aws/credentials shared credentials file
    • EC2 instance profile credentials See Plugins::RequestSigner for more details.
  • :disable_host_prefix_injection (Boolean)

    Set to true to disable SDK automatically adding host prefix to default service endpoint when available. See Plugins::EndpointPattern for more details.

  • :endpoint (String)

    A default endpoint is constructed from the :region. See Plugins::RegionalEndpoint for more details.

  • :endpoint_cache_max_entries (Integer)

    Used for the maximum size limit of the LRU cache storing endpoints data for endpoint discovery enabled operations. Defaults to 1000. See Plugins::EndpointDiscovery for more details.

  • :endpoint_cache_max_threads (Integer)

    Used for the maximum threads in use for polling endpoints to be cached, defaults to 10. See Plugins::EndpointDiscovery for more details.

  • :endpoint_cache_poll_interval (Integer)

    When :endpoint_discovery and :active_endpoint_cache is enabled, Use this option to config the time interval in seconds for making requests fetching endpoints information. Defaults to 60 sec. See Plugins::EndpointDiscovery for more details.

  • :endpoint_discovery (Boolean)

    When set to true, endpoint discovery will be enabled for operations when available. Defaults to false. See Plugins::EndpointDiscovery for more details.

  • :http_continue_timeout (Float) — default: 1

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_idle_timeout (Integer) — default: 5

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_open_timeout (Integer) — default: 15

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_proxy (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_read_timeout (Integer) — default: 60

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_wire_trace (Boolean) — default: false

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :log_level (Symbol) — default: :info

    The log level to send messages to the logger at. See Plugins::Logging for more details.

  • :log_formatter (Logging::LogFormatter)

    The log formatter. Defaults to Seahorse::Client::Logging::Formatter.default. See Plugins::Logging for more details.

  • :logger (Logger) — default: nil

    The Logger instance to send log messages to. If this option is not set, logging will be disabled. See Plugins::Logging for more details.

  • :profile (String)

    Used when loading credentials from the shared credentials file at HOME/.aws/credentials. When not specified, 'default' is used. See Plugins::RequestSigner for more details.

  • :raise_response_errors (Boolean) — default: true

    When true, response errors are raised. See Seahorse::Client::Plugins::RaiseResponseErrors for more details.

  • :region (required, String)

    The AWS region to connect to. The region is used to construct the client endpoint. Defaults to ENV['AWS_REGION']. Also checks AMAZON_REGION and AWS_DEFAULT_REGION. See Plugins::RegionalEndpoint for more details.

  • :retry_limit (Integer) — default: 3

    The maximum number of times to retry failed requests. Only ~ 500 level server errors and certain ~ 400 level client errors are retried. Generally, these are throttling errors, data checksum errors, networking errors, timeout errors and auth errors from expired credentials. See Plugins::RetryErrors for more details.

  • :secret_access_key (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :session_token (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :simple_json (Boolean) — default: false

    Disables request parameter conversion, validation, and formatting. Also disable response data type conversions. This option is useful when you want to ensure the highest level of performance by avoiding overhead of walking request parameters and response data structures.

    When :simple_json is enabled, the request parameters hash must be formatted exactly as the DynamoDB API expects. See Plugins::Protocols::JsonRpc for more details.

  • :ssl_ca_bundle (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_directory (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_store (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_verify_peer (Boolean) — default: true

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :stub_responses (Boolean) — default: false

    Causes the client to return stubbed responses. By default fake responses are generated and returned. You can specify the response data to return or errors to raise by calling ClientStubs#stub_responses. See ClientStubs for more information.

    Please note When response stubbing is enabled, no HTTP requests are made, and retries are disabled. See Plugins::StubResponses for more details.

  • :validate_params (Boolean) — default: true

    When true, request parameters are validated before sending the request. See Plugins::ParamValidator for more details.

Instance Method Details

#batch_get_named_query(options = {}) ⇒ Types::BatchGetNamedQueryOutput

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.

Examples:

Request syntax with placeholder values


resp = client.batch_get_named_query({
  named_query_ids: ["NamedQueryId"], # required
})

Response structure


resp.named_queries #=> Array
resp.named_queries[0].name #=> String
resp.named_queries[0].description #=> String
resp.named_queries[0].database #=> String
resp.named_queries[0].query_string #=> String
resp.named_queries[0].named_query_id #=> String
resp.named_queries[0].work_group #=> String
resp.unprocessed_named_query_ids #=> Array
resp.unprocessed_named_query_ids[0].named_query_id #=> String
resp.unprocessed_named_query_ids[0].error_code #=> String
resp.unprocessed_named_query_ids[0].error_message #=> String

Options Hash (options):

  • :named_query_ids (required, Array<String>)

    An array of query IDs.

Returns:

See Also:

#batch_get_query_execution(options = {}) ⇒ Types::BatchGetQueryExecutionOutput

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.

Examples:

Request syntax with placeholder values


resp = client.batch_get_query_execution({
  query_execution_ids: ["QueryExecutionId"], # required
})

Response structure


resp.query_executions #=> Array
resp.query_executions[0].query_execution_id #=> String
resp.query_executions[0].query #=> String
resp.query_executions[0].statement_type #=> String, one of "DDL", "DML", "UTILITY"
resp.query_executions[0].result_configuration.output_location #=> String
resp.query_executions[0].result_configuration.encryption_configuration.encryption_option #=> String, one of "SSE_S3", "SSE_KMS", "CSE_KMS"
resp.query_executions[0].result_configuration.encryption_configuration.kms_key #=> String
resp.query_executions[0].query_execution_context.database #=> String
resp.query_executions[0].query_execution_context.catalog #=> String
resp.query_executions[0].status.state #=> String, one of "QUEUED", "RUNNING", "SUCCEEDED", "FAILED", "CANCELLED"
resp.query_executions[0].status.state_change_reason #=> String
resp.query_executions[0].status.submission_date_time #=> Time
resp.query_executions[0].status.completion_date_time #=> Time
resp.query_executions[0].statistics.engine_execution_time_in_millis #=> Integer
resp.query_executions[0].statistics.data_scanned_in_bytes #=> Integer
resp.query_executions[0].statistics.data_manifest_location #=> String
resp.query_executions[0].statistics.total_execution_time_in_millis #=> Integer
resp.query_executions[0].statistics.query_queue_time_in_millis #=> Integer
resp.query_executions[0].statistics.query_planning_time_in_millis #=> Integer
resp.query_executions[0].statistics.service_processing_time_in_millis #=> Integer
resp.query_executions[0].work_group #=> String
resp.unprocessed_query_execution_ids #=> Array
resp.unprocessed_query_execution_ids[0].query_execution_id #=> String
resp.unprocessed_query_execution_ids[0].error_code #=> String
resp.unprocessed_query_execution_ids[0].error_message #=> String

Options Hash (options):

  • :query_execution_ids (required, Array<String>)

    An array of query execution IDs.

Returns:

See Also:

#create_data_catalog(options = {}) ⇒ Struct

Creates (registers) a data catalog with the specified name and properties. Catalogs created are visible to all users of the same AWS account.

Examples:

Request syntax with placeholder values


resp = client.create_data_catalog({
  name: "CatalogNameString", # required
  type: "LAMBDA", # required, accepts LAMBDA, GLUE, HIVE
  description: "DescriptionString",
  parameters: {
    "KeyString" => "ParametersMapValue",
  },
  tags: [
    {
      key: "TagKey",
      value: "TagValue",
    },
  ],
})

Options Hash (options):

  • :name (required, String)

    The name of the data catalog to create. The catalog name must be unique for the AWS account and can use a maximum of 128 alphanumeric, underscore, at sign, or hyphen characters.

  • :type (required, String)

    The type of data catalog to create: LAMBDA for a federated catalog, GLUE for AWS Glue Catalog, or HIVE for an external hive metastore.

  • :description (String)

    A description of the data catalog to be created.

  • :parameters (Hash<String,String>)

    Specifies the Lambda function or functions to use for creating the data catalog. This is a mapping whose values depend on the catalog type.

    • For the HIVE data catalog type, use the following syntax. The metadata-function parameter is required. The sdk-version parameter is optional and defaults to the currently supported version.

      metadata-function=lambda_arn, sdk-version=version_number

    • For the LAMBDA data catalog type, use one of the following sets of required parameters, but not both.

      • If you have one Lambda function that processes metadata and another for reading the actual data, use the following syntax. Both parameters are required.

        metadata-function=lambda_arn, record-function=lambda_arn

      • If you have a composite Lambda function that processes both metadata and data, use the following syntax to specify your Lambda function.

        function=lambda_arn

    • The GLUE type has no parameters.

  • :tags (Array<Types::Tag>)

    A list of comma separated tags to add to the data catalog that is created.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#create_named_query(options = {}) ⇒ Types::CreateNamedQueryOutput

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.

Examples:

Request syntax with placeholder values


resp = client.create_named_query({
  name: "NameString", # required
  description: "DescriptionString",
  database: "DatabaseString", # required
  query_string: "QueryString", # required
  client_request_token: "IdempotencyToken",
  work_group: "WorkGroupName",
})

Response structure


resp.named_query_id #=> String

Options Hash (options):

  • :name (required, String)

    The query name.

  • :description (String)

    The query description.

  • :database (required, String)

    The database to which the query belongs.

  • :query_string (required, String)

    The contents of the query with all query statements.

  • :client_request_token (String)

    This parameter will be auto-filled on your behalf with a random UUIDv4 when no value is provided. 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.

    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.

  • :work_group (String)

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

Returns:

See Also:

#create_work_group(options = {}) ⇒ Struct

Creates a workgroup with the specified name.

Examples:

Request syntax with placeholder values


resp = client.create_work_group({
  name: "WorkGroupName", # required
  configuration: {
    result_configuration: {
      output_location: "String",
      encryption_configuration: {
        encryption_option: "SSE_S3", # required, accepts SSE_S3, SSE_KMS, CSE_KMS
        kms_key: "String",
      },
    },
    enforce_work_group_configuration: false,
    publish_cloud_watch_metrics_enabled: false,
    bytes_scanned_cutoff_per_query: 1,
    requester_pays_enabled: false,
  },
  description: "WorkGroupDescriptionString",
  tags: [
    {
      key: "TagKey",
      value: "TagValue",
    },
  ],
})

Options Hash (options):

  • :name (required, String)

    The workgroup name.

  • :configuration (Types::WorkGroupConfiguration)

    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.

  • :description (String)

    The workgroup description.

  • :tags (Array<Types::Tag>)

    A list of comma separated tags to add to the workgroup that is created.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#delete_data_catalog(options = {}) ⇒ Struct

Deletes a data catalog.

Examples:

Request syntax with placeholder values


resp = client.delete_data_catalog({
  name: "CatalogNameString", # required
})

Options Hash (options):

  • :name (required, String)

    The name of the data catalog to delete.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#delete_named_query(options = {}) ⇒ Struct

Deletes the named query if you have access to the workgroup in which the query was saved.

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

Examples:

Request syntax with placeholder values


resp = client.delete_named_query({
  named_query_id: "NamedQueryId", # required
})

Options Hash (options):

  • :named_query_id (required, String)

    This parameter will be auto-filled on your behalf with a random UUIDv4 when no value is provided. The unique ID of the query to delete.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#delete_work_group(options = {}) ⇒ Struct

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

Examples:

Request syntax with placeholder values


resp = client.delete_work_group({
  work_group: "WorkGroupName", # required
  recursive_delete_option: false,
})

Options Hash (options):

  • :work_group (required, String)

    The unique name of the workgroup to delete.

  • :recursive_delete_option (Boolean)

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

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#get_data_catalog(options = {}) ⇒ Types::GetDataCatalogOutput

Returns the specified data catalog.

Examples:

Request syntax with placeholder values


resp = client.get_data_catalog({
  name: "CatalogNameString", # required
})

Response structure


resp.data_catalog.name #=> String
resp.data_catalog.description #=> String
resp.data_catalog.type #=> String, one of "LAMBDA", "GLUE", "HIVE"
resp.data_catalog.parameters #=> Hash
resp.data_catalog.parameters["KeyString"] #=> String

Options Hash (options):

  • :name (required, String)

    The name of the data catalog to return.

Returns:

See Also:

#get_database(options = {}) ⇒ Types::GetDatabaseOutput

Returns a database object for the specfied database and data catalog.

Examples:

Request syntax with placeholder values


resp = client.get_database({
  catalog_name: "CatalogNameString", # required
  database_name: "NameString", # required
})

Response structure


resp.database.name #=> String
resp.database.description #=> String
resp.database.parameters #=> Hash
resp.database.parameters["KeyString"] #=> String

Options Hash (options):

  • :catalog_name (required, String)

    The name of the data catalog that contains the database to return.

  • :database_name (required, String)

    The name of the database to return.

Returns:

See Also:

#get_named_query(options = {}) ⇒ Types::GetNamedQueryOutput

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

Examples:

Request syntax with placeholder values


resp = client.get_named_query({
  named_query_id: "NamedQueryId", # required
})

Response structure


resp.named_query.name #=> String
resp.named_query.description #=> String
resp.named_query.database #=> String
resp.named_query.query_string #=> String
resp.named_query.named_query_id #=> String
resp.named_query.work_group #=> String

Options Hash (options):

  • :named_query_id (required, String)

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

Returns:

See Also:

#get_query_execution(options = {}) ⇒ Types::GetQueryExecutionOutput

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.

Examples:

Request syntax with placeholder values


resp = client.get_query_execution({
  query_execution_id: "QueryExecutionId", # required
})

Response structure


resp.query_execution.query_execution_id #=> String
resp.query_execution.query #=> String
resp.query_execution.statement_type #=> String, one of "DDL", "DML", "UTILITY"
resp.query_execution.result_configuration.output_location #=> String
resp.query_execution.result_configuration.encryption_configuration.encryption_option #=> String, one of "SSE_S3", "SSE_KMS", "CSE_KMS"
resp.query_execution.result_configuration.encryption_configuration.kms_key #=> String
resp.query_execution.query_execution_context.database #=> String
resp.query_execution.query_execution_context.catalog #=> String
resp.query_execution.status.state #=> String, one of "QUEUED", "RUNNING", "SUCCEEDED", "FAILED", "CANCELLED"
resp.query_execution.status.state_change_reason #=> String
resp.query_execution.status.submission_date_time #=> Time
resp.query_execution.status.completion_date_time #=> Time
resp.query_execution.statistics.engine_execution_time_in_millis #=> Integer
resp.query_execution.statistics.data_scanned_in_bytes #=> Integer
resp.query_execution.statistics.data_manifest_location #=> String
resp.query_execution.statistics.total_execution_time_in_millis #=> Integer
resp.query_execution.statistics.query_queue_time_in_millis #=> Integer
resp.query_execution.statistics.query_planning_time_in_millis #=> Integer
resp.query_execution.statistics.service_processing_time_in_millis #=> Integer
resp.query_execution.work_group #=> String

Options Hash (options):

  • :query_execution_id (required, String)

    The unique ID of the query execution.

Returns:

See Also:

#get_query_results(options = {}) ⇒ Types::GetQueryResultsOutput

Streams the results of a single query execution specified by QueryExecutionId from the Athena query results location in Amazon S3. For more information, see Query Results in the Amazon Athena User Guide. This request does not execute the query but returns results. Use StartQueryExecution to run a query.

To stream query results successfully, the IAM principal with permission to call GetQueryResults also must have permissions to the Amazon S3 GetObject action for the Athena query results location.

IAM principals with permission to the Amazon S3 GetObject action for the query results location are able to retrieve query results from Amazon S3 even if permission to the GetQueryResults action is denied. To restrict user or role access, ensure that Amazon S3 permissions to the Athena query location are denied.

Examples:

Request syntax with placeholder values


resp = client.get_query_results({
  query_execution_id: "QueryExecutionId", # required
  next_token: "Token",
  max_results: 1,
})

Response structure


resp.update_count #=> Integer
resp.result_set.rows #=> Array
resp.result_set.rows[0].data #=> Array
resp.result_set.rows[0].data[0].var_char_value #=> String
resp.result_set..column_info #=> Array
resp.result_set..column_info[0].catalog_name #=> String
resp.result_set..column_info[0].schema_name #=> String
resp.result_set..column_info[0].table_name #=> String
resp.result_set..column_info[0].name #=> String
resp.result_set..column_info[0].label #=> String
resp.result_set..column_info[0].type #=> String
resp.result_set..column_info[0].precision #=> Integer
resp.result_set..column_info[0].scale #=> Integer
resp.result_set..column_info[0].nullable #=> String, one of "NOT_NULL", "NULLABLE", "UNKNOWN"
resp.result_set..column_info[0].case_sensitive #=> true/false
resp.next_token #=> String

Options Hash (options):

  • :query_execution_id (required, String)

    The unique ID of the query execution.

  • :next_token (String)

    A token generated by the Athena service that specifies where to continue pagination if a previous request was truncated. To obtain the next set of pages, pass in the NextToken from the response object of the previous page call.

  • :max_results (Integer)

    The maximum number of results (rows) to return in this request.

Returns:

See Also:

#get_table_metadata(options = {}) ⇒ Types::GetTableMetadataOutput

Returns table metadata for the specified catalog, database, and table.

Examples:

Request syntax with placeholder values


resp = client.({
  catalog_name: "CatalogNameString", # required
  database_name: "NameString", # required
  table_name: "NameString", # required
})

Response structure


resp..name #=> String
resp..create_time #=> Time
resp..last_access_time #=> Time
resp..table_type #=> String
resp..columns #=> Array
resp..columns[0].name #=> String
resp..columns[0].type #=> String
resp..columns[0].comment #=> String
resp..partition_keys #=> Array
resp..partition_keys[0].name #=> String
resp..partition_keys[0].type #=> String
resp..partition_keys[0].comment #=> String
resp..parameters #=> Hash
resp..parameters["KeyString"] #=> String

Options Hash (options):

  • :catalog_name (required, String)

    The name of the data catalog that contains the database and table metadata to return.

  • :database_name (required, String)

    The name of the database that contains the table metadata to return.

  • :table_name (required, String)

    The name of the table for which metadata is returned.

Returns:

See Also:

#get_work_group(options = {}) ⇒ Types::GetWorkGroupOutput

Returns information about the workgroup with the specified name.

Examples:

Request syntax with placeholder values


resp = client.get_work_group({
  work_group: "WorkGroupName", # required
})

Response structure


resp.work_group.name #=> String
resp.work_group.state #=> String, one of "ENABLED", "DISABLED"
resp.work_group.configuration.result_configuration.output_location #=> String
resp.work_group.configuration.result_configuration.encryption_configuration.encryption_option #=> String, one of "SSE_S3", "SSE_KMS", "CSE_KMS"
resp.work_group.configuration.result_configuration.encryption_configuration.kms_key #=> String
resp.work_group.configuration.enforce_work_group_configuration #=> true/false
resp.work_group.configuration.publish_cloud_watch_metrics_enabled #=> true/false
resp.work_group.configuration.bytes_scanned_cutoff_per_query #=> Integer
resp.work_group.configuration.requester_pays_enabled #=> true/false
resp.work_group.description #=> String
resp.work_group.creation_time #=> Time

Options Hash (options):

  • :work_group (required, String)

    The name of the workgroup.

Returns:

See Also:

#list_data_catalogs(options = {}) ⇒ Types::ListDataCatalogsOutput

Lists the data catalogs in the current AWS account.

Examples:

Request syntax with placeholder values


resp = client.list_data_catalogs({
  next_token: "Token",
  max_results: 1,
})

Response structure


resp.data_catalogs_summary #=> Array
resp.data_catalogs_summary[0].catalog_name #=> String
resp.data_catalogs_summary[0].type #=> String, one of "LAMBDA", "GLUE", "HIVE"
resp.next_token #=> String

Options Hash (options):

  • :next_token (String)

    A token generated by the Athena service that specifies where to continue pagination if a previous request was truncated. To obtain the next set of pages, pass in the NextToken from the response object of the previous page call.

  • :max_results (Integer)

    Specifies the maximum number of data catalogs to return.

Returns:

See Also:

#list_databases(options = {}) ⇒ Types::ListDatabasesOutput

Lists the databases in the specified data catalog.

Examples:

Request syntax with placeholder values


resp = client.list_databases({
  catalog_name: "CatalogNameString", # required
  next_token: "Token",
  max_results: 1,
})

Response structure


resp.database_list #=> Array
resp.database_list[0].name #=> String
resp.database_list[0].description #=> String
resp.database_list[0].parameters #=> Hash
resp.database_list[0].parameters["KeyString"] #=> String
resp.next_token #=> String

Options Hash (options):

  • :catalog_name (required, String)

    The name of the data catalog that contains the databases to return.

  • :next_token (String)

    A token generated by the Athena service that specifies where to continue pagination if a previous request was truncated. To obtain the next set of pages, pass in the NextToken from the response object of the previous page call.

  • :max_results (Integer)

    Specifies the maximum number of results to return.

Returns:

See Also:

#list_named_queries(options = {}) ⇒ Types::ListNamedQueriesOutput

Provides a list of available query IDs only for queries saved in the specified workgroup. Requires that you have access to the specified workgroup. If a workgroup is not specified, lists the saved queries for the primary workgroup.

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

Examples:

Request syntax with placeholder values


resp = client.list_named_queries({
  next_token: "Token",
  max_results: 1,
  work_group: "WorkGroupName",
})

Response structure


resp.named_query_ids #=> Array
resp.named_query_ids[0] #=> String
resp.next_token #=> String

Options Hash (options):

  • :next_token (String)

    A token generated by the Athena service that specifies where to continue pagination if a previous request was truncated. To obtain the next set of pages, pass in the NextToken from the response object of the previous page call.

  • :max_results (Integer)

    The maximum number of queries to return in this request.

  • :work_group (String)

    The name of the workgroup from which the named queries are being returned. If a workgroup is not specified, the saved queries for the primary workgroup are returned.

Returns:

See Also:

#list_query_executions(options = {}) ⇒ Types::ListQueryExecutionsOutput

Provides a list of available query execution IDs for the queries in the specified workgroup. If a workgroup is not specified, returns a list of query execution IDs for the primary 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.

Examples:

Request syntax with placeholder values


resp = client.list_query_executions({
  next_token: "Token",
  max_results: 1,
  work_group: "WorkGroupName",
})

Response structure


resp.query_execution_ids #=> Array
resp.query_execution_ids[0] #=> String
resp.next_token #=> String

Options Hash (options):

  • :next_token (String)

    A token generated by the Athena service that specifies where to continue pagination if a previous request was truncated. To obtain the next set of pages, pass in the NextToken from the response object of the previous page call.

  • :max_results (Integer)

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

  • :work_group (String)

    The name of the workgroup from which queries are being returned. If a workgroup is not specified, a list of available query execution IDs for the queries in the primary workgroup is returned.

Returns:

See Also:

#list_table_metadata(options = {}) ⇒ Types::ListTableMetadataOutput

Lists the metadata for the tables in the specified data catalog database.

Examples:

Request syntax with placeholder values


resp = client.({
  catalog_name: "CatalogNameString", # required
  database_name: "NameString", # required
  expression: "ExpressionString",
  next_token: "Token",
  max_results: 1,
})

Response structure


resp. #=> Array
resp.[0].name #=> String
resp.[0].create_time #=> Time
resp.[0].last_access_time #=> Time
resp.[0].table_type #=> String
resp.[0].columns #=> Array
resp.[0].columns[0].name #=> String
resp.[0].columns[0].type #=> String
resp.[0].columns[0].comment #=> String
resp.[0].partition_keys #=> Array
resp.[0].partition_keys[0].name #=> String
resp.[0].partition_keys[0].type #=> String
resp.[0].partition_keys[0].comment #=> String
resp.[0].parameters #=> Hash
resp.[0].parameters["KeyString"] #=> String
resp.next_token #=> String

Options Hash (options):

  • :catalog_name (required, String)

    The name of the data catalog for which table metadata should be returned.

  • :database_name (required, String)

    The name of the database for which table metadata should be returned.

  • :expression (String)

    A regex filter that pattern-matches table names. If no expression is supplied, metadata for all tables are listed.

  • :next_token (String)

    A token generated by the Athena service that specifies where to continue pagination if a previous request was truncated. To obtain the next set of pages, pass in the NextToken from the response object of the previous page call.

  • :max_results (Integer)

    Specifies the maximum number of results to return.

Returns:

See Also:

#list_tags_for_resource(options = {}) ⇒ Types::ListTagsForResourceOutput

Lists the tags associated with an Athena workgroup or data catalog resource.

Examples:

Request syntax with placeholder values


resp = client.list_tags_for_resource({
  resource_arn: "AmazonResourceName", # required
  next_token: "Token",
  max_results: 1,
})

Response structure


resp.tags #=> Array
resp.tags[0].key #=> String
resp.tags[0].value #=> String
resp.next_token #=> String

Options Hash (options):

  • :resource_arn (required, String)

    Lists the tags for the resource with the specified ARN.

  • :next_token (String)

    The token for the next set of results, or null if there are no additional results for this request, where the request lists the tags for the resource with the specified ARN.

  • :max_results (Integer)

    The maximum number of results to be returned per request that lists the tags for the resource.

Returns:

See Also:

#list_work_groups(options = {}) ⇒ Types::ListWorkGroupsOutput

Lists available workgroups for the account.

Examples:

Request syntax with placeholder values


resp = client.list_work_groups({
  next_token: "Token",
  max_results: 1,
})

Response structure


resp.work_groups #=> Array
resp.work_groups[0].name #=> String
resp.work_groups[0].state #=> String, one of "ENABLED", "DISABLED"
resp.work_groups[0].description #=> String
resp.work_groups[0].creation_time #=> Time
resp.next_token #=> String

Options Hash (options):

  • :next_token (String)

    A token generated by the Athena service that specifies where to continue pagination if a previous request was truncated. To obtain the next set of pages, pass in the NextToken from the response object of the previous page call.

  • :max_results (Integer)

    The maximum number of workgroups to return in this request.

Returns:

See Also:

#start_query_execution(options = {}) ⇒ Types::StartQueryExecutionOutput

Runs the SQL query statements contained in the Query. Requires you to have access to the workgroup in which the query ran. Running queries against an external catalog requires GetDataCatalog permission to the catalog. For code samples using the AWS SDK for Java, see Examples and Code Samples in the Amazon Athena User Guide.

Examples:

Request syntax with placeholder values


resp = client.start_query_execution({
  query_string: "QueryString", # required
  client_request_token: "IdempotencyToken",
  query_execution_context: {
    database: "DatabaseString",
    catalog: "CatalogNameString",
  },
  result_configuration: {
    output_location: "String",
    encryption_configuration: {
      encryption_option: "SSE_S3", # required, accepts SSE_S3, SSE_KMS, CSE_KMS
      kms_key: "String",
    },
  },
  work_group: "WorkGroupName",
})

Response structure


resp.query_execution_id #=> String

Options Hash (options):

  • :query_string (required, String)

    The SQL query statements to be executed.

  • :client_request_token (String)

    This parameter will be auto-filled on your behalf with a random UUIDv4 when no value is provided. 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.

    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.

  • :query_execution_context (Types::QueryExecutionContext)

    The database within which the query executes.

  • :result_configuration (Types::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.

  • :work_group (String)

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

Returns:

See Also:

#stop_query_execution(options = {}) ⇒ Struct

Stops a query execution. 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.

Examples:

Request syntax with placeholder values


resp = client.stop_query_execution({
  query_execution_id: "QueryExecutionId", # required
})

Options Hash (options):

  • :query_execution_id (required, String)

    This parameter will be auto-filled on your behalf with a random UUIDv4 when no value is provided. The unique ID of the query execution to stop.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#tag_resource(options = {}) ⇒ Struct

Adds one or more tags to an Athena resource. A tag is a label that you assign to a resource. In Athena, a resource can be a workgroup or data catalog. Each tag consists of a key and an optional value, both of which you define. For example, you can use tags to categorize Athena workgroups or data catalogs by purpose, owner, or environment. Use a consistent set of tag keys to make it easier to search and filter workgroups or data catalogs in your account. For best practices, see Tagging Best Practices. Tag keys can be from 1 to 128 UTF-8 Unicode characters, and tag values can be from 0 to 256 UTF-8 Unicode characters. Tags can use letters and numbers representable in UTF-8, and the following characters: + - = . _ : / @. Tag keys and values are case-sensitive. Tag keys must be unique per resource. If you specify more than one tag, separate them by commas.

Examples:

Request syntax with placeholder values


resp = client.tag_resource({
  resource_arn: "AmazonResourceName", # required
  tags: [ # required
    {
      key: "TagKey",
      value: "TagValue",
    },
  ],
})

Options Hash (options):

  • :resource_arn (required, String)

    Specifies the ARN of the Athena resource (workgroup or data catalog) to which tags are to be added.

  • :tags (required, Array<Types::Tag>)

    A collection of one or more tags, separated by commas, to be added to an Athena workgroup or data catalog resource.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#untag_resource(options = {}) ⇒ Struct

Removes one or more tags from a data catalog or workgroup resource.

Examples:

Request syntax with placeholder values


resp = client.untag_resource({
  resource_arn: "AmazonResourceName", # required
  tag_keys: ["TagKey"], # required
})

Options Hash (options):

  • :resource_arn (required, String)

    Specifies the ARN of the resource from which tags are to be removed.

  • :tag_keys (required, Array<String>)

    A comma-separated list of one or more tag keys whose tags are to be removed from the specified resource.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#update_data_catalog(options = {}) ⇒ Struct

Updates the data catalog that has the specified name.

Examples:

Request syntax with placeholder values


resp = client.update_data_catalog({
  name: "CatalogNameString", # required
  type: "LAMBDA", # required, accepts LAMBDA, GLUE, HIVE
  description: "DescriptionString",
  parameters: {
    "KeyString" => "ParametersMapValue",
  },
})

Options Hash (options):

  • :name (required, String)

    The name of the data catalog to update. The catalog name must be unique for the AWS account and can use a maximum of 128 alphanumeric, underscore, at sign, or hyphen characters.

  • :type (required, String)

    Specifies the type of data catalog to update. Specify LAMBDA for a federated catalog, GLUE for AWS Glue Catalog, or HIVE for an external hive metastore.

  • :description (String)

    New or modified text that describes the data catalog.

  • :parameters (Hash<String,String>)

    Specifies the Lambda function or functions to use for updating the data catalog. This is a mapping whose values depend on the catalog type.

    • For the HIVE data catalog type, use the following syntax. The metadata-function parameter is required. The sdk-version parameter is optional and defaults to the currently supported version.

      metadata-function=lambda_arn, sdk-version=version_number

    • For the LAMBDA data catalog type, use one of the following sets of required parameters, but not both.

      • If you have one Lambda function that processes metadata and another for reading the actual data, use the following syntax. Both parameters are required.

        metadata-function=lambda_arn, record-function=lambda_arn

      • If you have a composite Lambda function that processes both metadata and data, use the following syntax to specify your Lambda function.

        function=lambda_arn

    • The GLUE type has no parameters.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#update_work_group(options = {}) ⇒ Struct

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

Examples:

Request syntax with placeholder values


resp = client.update_work_group({
  work_group: "WorkGroupName", # required
  description: "WorkGroupDescriptionString",
  configuration_updates: {
    enforce_work_group_configuration: false,
    result_configuration_updates: {
      output_location: "String",
      remove_output_location: false,
      encryption_configuration: {
        encryption_option: "SSE_S3", # required, accepts SSE_S3, SSE_KMS, CSE_KMS
        kms_key: "String",
      },
      remove_encryption_configuration: false,
    },
    publish_cloud_watch_metrics_enabled: false,
    bytes_scanned_cutoff_per_query: 1,
    remove_bytes_scanned_cutoff_per_query: false,
    requester_pays_enabled: false,
  },
  state: "ENABLED", # accepts ENABLED, DISABLED
})

Options Hash (options):

  • :work_group (required, String)

    The specified workgroup that will be updated.

  • :description (String)

    The workgroup description.

  • :configuration_updates (Types::WorkGroupConfigurationUpdates)

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

  • :state (String)

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

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean

Waiters polls an API operation until a resource enters a desired state.

Basic Usage

Waiters will poll until they are succesful, they fail by entering a terminal state, or until a maximum number of attempts are made.

# polls in a loop, sleeping between attempts client.waiter_until(waiter_name, params)

Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You configure waiters by passing a block to #wait_until:

# poll for ~25 seconds
client.wait_until(...) do |w|
  w.max_attempts = 5
  w.delay = 5
end

Callbacks

You can be notified before each polling attempt and before each delay. If you throw :success or :failure from these callbacks, it will terminate the waiter.

started_at = Time.now
client.wait_until(...) do |w|

  # disable max attempts
  w.max_attempts = nil

  # poll for 1 hour, instead of a number of attempts
  w.before_wait do |attempts, response|
    throw :failure if Time.now - started_at > 3600
  end

end

Handling Errors

When a waiter is successful, it returns true. When a waiter fails, it raises an error. All errors raised extend from Waiters::Errors::WaiterFailed.

begin
  client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

Parameters:

  • waiter_name (Symbol)

    The name of the waiter. See #waiter_names for a full list of supported waiters.

  • params (Hash) (defaults to: {})

    Additional request parameters. See the #waiter_names for a list of supported waiters and what request they call. The called request determines the list of accepted parameters.

Yield Parameters:

Returns:

  • (Boolean)

    Returns true if the waiter was successful.

Raises:

  • (Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

  • (Errors::TooManyAttemptsError)

    Raised when the configured maximum number of attempts have been made, and the waiter is not yet successful.

  • (Errors::UnexpectedError)

    Raised when an error is encounted while polling for a resource that is not expected.

  • (Errors::NoSuchWaiterError)

    Raised when you request to wait for an unknown state.

#waiter_namesArray<Symbol>

Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:

Waiter NameClient MethodDefault Delay:Default Max Attempts:

Returns:

  • (Array<Symbol>)

    the list of supported waiters.