Skip to content

aws.timestream_query.query

Example SQL Queries

SELECT * FROM
aws.timestream_query.query
WHERE
"query_string" = 'VALUE';

Description

Query is a synchronous operation that enables you to run a query against your Amazon Timestream data. Query will time out after 60 seconds. You must update the default timeout in the SDK to support a timeout of 60 seconds. See the code sample for details.

Your query request will fail in the following cases:

  • If you submit a Query request with the same client token outside of the 5-minute idempotency window.

  • If you submit a Query request with the same client token, but change other parameters, within the 5-minute idempotency window.

  • If the size of the row (including the query metadata) exceeds 1 MB, then the query will fail with the following error message:

    Query aborted as max page response size has been exceeded by the output result row

  • If the IAM principal of the query initiator and the result reader are not the same and/or the query initiator and the result reader do not have the same query string in the query requests, the query will fail with an Invalid pagination token error.

Table Definition

Column NameColumn Data Type
query_string Required Input Column

The query to be run by Timestream.

VARCHAR
client_token Input Column

Unique, case-sensitive string of up to 64 ASCII characters specified when a Query request is made. Providing a ClientToken makes the call to Query idempotent. This means that running the same query repeatedly will produce the same result. In other words, making multiple identical Query requests has the same effect as making a single request. When using ClientToken in a query, note the following:

  • If the Query API is instantiated without a ClientToken, the Query SDK generates a ClientToken on your behalf.

  • If the Query invocation only contains the ClientToken but does not include a NextToken, that invocation of Query is assumed to be a new query run.

  • If the invocation contains NextToken, that particular invocation is assumed to be a subsequent invocation of a prior call to the Query API, and a result set is returned.

  • After 4 hours, any request with the same ClientToken is treated as a new request.

VARCHAR
_aws_profile Input Column

The AWS profile defines the AWS identity used. It can be defined via credentials or by assuming a IAM role.

STRUCT(
"type" VARCHAR,
"name" VARCHAR,
"account_id" VARCHAR,
"via_profile_name" VARCHAR,
"assumed_role_arn" VARCHAR,
"organization" STRUCT(
"account_name" VARCHAR,
"id" VARCHAR,
"tags" STRUCT(
"key" VARCHAR,
"value" VARCHAR
)[],
"master_account" STRUCT(
"id" VARCHAR,
"email" VARCHAR
),
"parents" STRUCT(
"type" VARCHAR,
"id" VARCHAR,
"name" VARCHAR,
"tags" STRUCT(
"key" VARCHAR,
"value" VARCHAR
)[]
)[]
)
)
Show child fields
_aws_profile.account_id

The AWS account id

_aws_profile.assumed_role_arn

The ARN of the assumed role

_aws_profile.name

The unique name of the profile.

_aws_profile.organization

Information about this profile's membership in the AWS organization.

Show child fields
_aws_profile.organization.account_name

The name of account speciifed by the organization

_aws_profile.organization.id

The organization id

_aws_profile.organization.master_account
Show child fields
_aws_profile.organization.master_account.email

The organization master account email address

_aws_profile.organization.master_account.id

The organization master account id

_aws_profile.organization.parents[]
Show child fields
_aws_profile.organization.parents[].id

The id of the parent

_aws_profile.organization.parents[].name

The name of the parent

_aws_profile.organization.parents[].tags[]
Show child fields
_aws_profile.organization.parents[].tags[].key
_aws_profile.organization.parents[].tags[].value
_aws_profile.organization.parents[].type

The type of parent can be an organization unit or a root

_aws_profile.organization.tags[]
Show child fields
_aws_profile.organization.tags[].key
_aws_profile.organization.tags[].value
_aws_profile.type

The type of profile, either 'credentials' or 'assumed_role'

_aws_profile.via_profile_name

This IAM role for this profile is assumed by first utilizing another profile with this name to obtain credentials.

column_info

The column data types of the returned result set.

STRUCT(
"name" VARCHAR,
"type" STRUCT(
"scalar_type" VARCHAR
)
)[]
Show child fields
column_info[]
Show child fields
column_info[].name

The name of the result set column. The name of the result set is available for columns of all data types except for arrays.

column_info[].type

The data type of the result set column. The data type can be a scalar or complex. Scalar data types are integers, strings, doubles, Booleans, and others. Complex data types are types such as arrays, rows, and others.

Show child fields
column_info[].type.scalar_type

Indicates if the column is of type string, integer, Boolean, double, timestamp, date, time. For more information, see Supported data types.

query_id

A unique ID for the given query.

VARCHAR
query_status

Information about the status of the query, including progress and bytes scanned.

STRUCT(
"progress_percentage" DOUBLE,
"cumulative_bytes_scanned" BIGINT,
"cumulative_bytes_metered" BIGINT
)
Show child fields
query_status.cumulative_bytes_metered

The amount of data scanned by the query in bytes that you will be charged for. This is a cumulative sum and represents the total amount of data that you will be charged for since the query was started. The charge is applied only once and is either applied when the query completes running or when the query is cancelled.

query_status.cumulative_bytes_scanned

The amount of data scanned by the query in bytes. This is a cumulative sum and represents the total amount of bytes scanned since the query was started.

query_status.progress_percentage

The progress of the query, expressed as a percentage.

rows

The result set rows returned by the query.

STRUCT(
"data" STRUCT(
"scalar_value" VARCHAR,
"time_series_value" STRUCT(
"time" VARCHAR
)[],
"null_value" BOOLEAN
)[]
)[]
Show child fields
rows[]
Show child fields
rows[].data[]
Show child fields
rows[].data[].null_value

Indicates if the data point is null.

rows[].data[].scalar_value

Indicates if the data point is a scalar value such as integer, string, double, or Boolean.

rows[].data[].time_series_value[]
Show child fields
rows[].data[].time_series_value[].time

The timestamp when the measure value was collected.