timestreamquery

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 49 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Timestream Query

Parity grade: A · SDK aws-sdk-go-v2/service/timestreamquery@v1.44.3 · last audited 2026-11-05 (a98a164d)

Coverage

Metric Value
PARITY entries audited 12 (12 ok)
Feature families 2 (1 ok, 1 deferred)
Known gaps 8
Structural gaps (can't be emulated) 1
Deferred items 0
Resource leaks clean
Known gaps
  • Static type inference (ts_infer.go) types every select-list expression before execution; a query it cannot parse or type keeps the older value-based column typing (and syntactic boolean/interval typing, ts_boolean.go), an empty result of such a column reports VARCHAR, and the checked arithmetic and casts below do not apply to it (SQLite semantics: integer overflow widens, CAST(double AS bigint) truncates, TRY_CAST of an unparsable string yields 0, division by zero yields NULL). Remaining sites: positional ? markers (PrepareQuery reports them as param1.. VARCHAR; the PrepareQuery page documents only @identifier names); an @name in the select list or compared with another untyped operand (its type depends on a value no request supplies; PrepareQuery reports VARCHAR); lambdas outside filter, transform, reduce, zip_with, the *_match functions and the regexp_replace lambda; transform() over a timeseries (the engine has no implementation); map-typed functions (map, map_agg, map_keys, map_values, histogram); a row field name that does not exist and row[i] with a non-literal i; any function without a return-type rule (SQLite built-ins outside the Timestream function list)
  • Unverified against the service: integer literals are typed INTEGER when they fit 32 bits else BIGINT (supported-data-types.html lists int and bigint but not which a literal gets; the SDK ScalarType enum has INTEGER, appended after UNKNOWN, and string-functions.html lists codepoint as integer, so the service emits it for something, but no recorded real response in the repo or the documentation shows a literal's ColumnInfo), and typeof() prints array(T), row(name T, ...) and timeseries(T) for nested types (array-functions.html writes output types as array(bigint), array(varchar), array(timestamp) and array(row), which is notation for function signatures, not typeof output; no page shows typeof of a row or timeseries)
  • Checked arithmetic and casts: the error type (ValidationException) and message wording ("bigint addition overflow: A + B", "Division by zero", "Cannot cast 'x' to BIGINT", "Out of range for integer: N", "Value cannot be cast to timestamp: x") follow the Presto/Trino family from memory; no Timestream page quotes them. CAST(double AS bigint) rounds half away from zero on the same basis. try() maps a failure anywhere inside its argument to NULL for the failing operation, which differs from the family only when a NULL changes a surrounding coalesce or CASE
  • Documented functions: every function on the Timestream mathematical, string, array, bitwise, regular expression, date/time, aggregate, window, conditional, comparison and time series pages is implemented except one example: parse_datetime with a zone-abbreviation pattern (date-time-functions.html: parse_datetime('2019-12-29 10:10 PST', 'uuuu-LL-dd HH:mm z') returns 2019-12-29 18:10:00.000000000) fails with 'Invalid format' because the base engine's parser has no zone abbreviations. max(x, n), min(x, n) and approx_percentile(x, ARRAY[...]) are not usable as window functions (they raise a clear error); the aggregates added in the reference function pass are. Argument bounds and error wording come from the engine family, not a Timestream page, for: max(x, n)/min(x, n) n 1-10000, max_by/min_by(x, y, n) n 1-10000 ('third argument of max_by must be a positive integer'), approx_percentile percentage range 0-1 and weight/accuracy checks, approx_distinct(x, e) with e in [0.0040625, 0.26] (the e range itself is on aggregate-functions.html), repeat count 0-10000, zip of 2 to 5 arrays, from_base/to_base radix 2-36, strpos/strrpos with overlapping matches and 'instance' must be a positive number, strpos/strrpos(x, '') = 1, skewness and the regr_* functions returning NULL for fewer than 3 rows or no variance in x, replace(x, '', y) inserting y between characters
  • NaN has no SQLite representation (a NaN stored in a REAL column becomes NULL), so a NaN DOUBLE is the text 'NaN' only where it is rendered (a top-level select item with no CTE), under a CAST to anything but DOUBLE, as the argument of is_nan/is_finite/is_infinite, or as an operand of DOUBLE arithmetic or comparison that is itself rewritten (an operand subtree containing nan(), infinity(), a division, a modulo, a CAST/typed literal to DOUBLE, or sqrt/ln/log10/log2/acos/asin/acosh/atanh/power/pow); there nan(), CAST('NaN' AS double), 0e0/0e0, sqrt(-1), ln(-1), infinity() - infinity() and nan() + 1 give NaN, ln(0) gives -Infinity, nan() = nan() is false and nan() <> nan() is true. Everywhere else a NaN is NULL: a NaN passed through a subquery or CTE column, ORDER BY, GROUP BY, DISTINCT, an aggregate (sum, min, max, avg over a NaN is not NaN), a window function, sign(), abs(), round() and similar numeric functions, or arithmetic whose operands the rewrite cannot see (a column holding a NaN, which the engine cannot store). NaN ordering (last, greatest) therefore does not hold. Infinity and -Infinity are real doubles and behave normally; a DOUBLE function rewritten for NaN is a Go function, not the native SQLite one, so its last digit can differ from SQLite's libm
  • Unverified against the service: the argument bounds and error wording of the reference functions come from the Presto/Trino family because no Timestream page states them: repeat count 0..10000, max_by/min_by n 1..10000, sequence() at most 1,000,000 elements (the family caps at 10,000), zip 2..5 arrays, from_base/to_base radix 2..36, bit_count bits 2..64, approx_distinct error 0.0040625..0.26, lpad/rpad length at most 16,777,216
  • INTERVAL YEAR TO MONTH arithmetic lives in the shared SQL engine (services/athena engine_interval.go) and does not range-check: 1year * 9223372036854775807 wraps instead of failing, and TIMESTAMP + 9999999999999year renders a year far beyond 9999
  • A checked arithmetic or cast rewrite that fails to translate or prepare (anything but a checked function rejecting a value) reruns the query without the checked rewrites, so such a query keeps the older semantics (overflow widens, division by zero is NULL, casts truncate) instead of failing
Structural gaps

These do not block an A grade — no implementation could produce real data here because the underlying data source cannot exist in an emulator.

  • CreateScheduledQuery KmsKeyId is stored and echoed, but there is no at-rest encryption layer to apply it to.

More

Documentation

Index

Constants

View Source
const (
	ScalarTypeBigint                = "BIGINT"
	ScalarTypeBoolean               = "BOOLEAN"
	ScalarTypeDate                  = "DATE"
	ScalarTypeDouble                = "DOUBLE"
	ScalarTypeIntervalDayToSecond   = "INTERVAL_DAY_TO_SECOND"
	ScalarTypeIntervalYearToMonth   = "INTERVAL_YEAR_TO_MONTH"
	ScalarTypeTime                  = "TIME"
	ScalarTypeTimestamp             = "TIMESTAMP"
	ScalarTypeTimestampWithTimezone = "TIMESTAMP_WITH_TIMEZONE"
	ScalarTypeUnknown               = "UNKNOWN"
	ScalarTypeVarchar               = "VARCHAR"
)
View Source
const DefaultQueryTimeout = time.Hour

DefaultQueryTimeout is the documented maximum query execution duration (Timestream quotas: 1 hour).

Variables

View Source
var (
	// ErrNotFound is returned when a requested resource does not exist.
	ErrNotFound = errors.New("ResourceNotFoundException")
	// ErrAlreadyExists is returned when a resource already exists.
	ErrAlreadyExists = errors.New("ConflictException")
	// ErrValidation is returned when request input fails validation.
	ErrValidation = errors.New("ValidationException")
	// ErrThrottling is returned when a request exceeds a documented rate limit.
	ErrThrottling = errors.New("ThrottlingException")
	// ErrQueryExecution is returned when Timestream cannot run a query (for example on timeout).
	ErrQueryExecution = errors.New("QueryExecutionException")
)
View Source
var ErrNilAppContext = errors.New("timestreamquery: nil app context")

ErrNilAppContext is returned when Init is called with a nil AppContext.

View Source
var ErrUnknownOperation = errors.New("unknown operation")

ErrUnknownOperation is returned when an unrecognized operation is requested.

Functions

This section is empty.

Types

type AccountSettings

type AccountSettings struct {
	MaxQueryTCU       *int32
	QueryCompute      *QueryCompute
	QueryPricingModel string
}

AccountSettings holds the account-level settings for Timestream Query.

type AccountSettingsNotificationConfiguration added in v1.2.0

type AccountSettingsNotificationConfiguration struct {
	SnsConfiguration *SnsConfiguration `json:"SnsConfiguration,omitempty"`
	RoleArn          string            `json:"RoleArn,omitempty"`
}

AccountSettingsNotificationConfiguration mirrors types.AccountSettingsNotificationConfiguration: settings for notifications sent whenever the provisioned-capacity settings are modified. Distinct from the scheduled-query NotificationConfiguration (see scheduledQueryToView), which shares the same nested SnsConfiguration shape but is used for a different resource.

type Catalog

type Catalog interface {
	DatabaseExists(region, database string) bool
	TableExists(region, database, table string) bool
}

Catalog reports which Timestream Write databases and tables exist in a region.

type ColumnInfo

type ColumnInfo struct {
	Name string     `json:"Name,omitempty"`
	Type ColumnType `json:"Type"`
}

ColumnInfo describes one column in a Timestream Query result set.

type ColumnType

type ColumnType struct {
	ArrayColumnInfo                  *ColumnInfo  `json:"ArrayColumnInfo,omitempty"`
	TimeSeriesMeasureValueColumnInfo *ColumnInfo  `json:"TimeSeriesMeasureValueColumnInfo,omitempty"`
	ScalarType                       string       `json:"ScalarType,omitempty"`
	RowColumnInfo                    []ColumnInfo `json:"RowColumnInfo,omitempty"`
}

ColumnType describes the type of a Timestream Query column. For scalar columns only ScalarType is set; for complex types the sub- fields carry the nested ColumnInfo.

type Datum

type Datum struct {
	ScalarValue     *string               `json:"ScalarValue,omitempty"`
	NullValue       *bool                 `json:"NullValue,omitempty"`
	ArrayValue      []Datum               `json:"ArrayValue,omitempty"`
	RowValue        *Row                  `json:"RowValue,omitempty"`
	TimeSeriesValue []TimeSeriesDataPoint `json:"TimeSeriesValue,omitempty"`
}

Datum is the AWS Timestream Query typed union cell. Exactly one of the pointer fields is non-nil for any given cell.

func NullDatum

func NullDatum() Datum

NullDatum returns a Datum representing a SQL NULL.

func ScalarDatum

func ScalarDatum(v string) Datum

ScalarDatum returns a Datum wrapping a scalar string value.

type DimensionMapping added in v1.5.0

type DimensionMapping struct {
	Name               string `json:"Name"`
	DimensionValueType string `json:"DimensionValueType"`
}

DimensionMapping maps a query result column to a dimension in the destination table (types.DimensionMapping on the wire).

type ErrorReportLocation

type ErrorReportLocation struct {
	S3ReportLocation *S3ReportLocation `json:"S3ReportLocation,omitempty"`
}

ErrorReportLocation holds the S3 error report location for a scheduled query run.

type ExecutionStats

type ExecutionStats struct {
	ExecutionTimeInMillis  int64 `json:"ExecutionTimeInMillis,omitempty"`
	DataWrites             int64 `json:"DataWrites,omitempty"`
	BytesMetered           int64 `json:"BytesMetered,omitempty"`
	CumulativeBytesScanned int64 `json:"CumulativeBytesScanned,omitempty"`
	QueryResultRows        int64 `json:"QueryResultRows,omitempty"`
	RecordsIngested        int64 `json:"RecordsIngested,omitempty"`
}

ExecutionStats holds statistics from a scheduled query execution. The wire field is "ExecutionTimeInMillis" (no trailing "ecs") per the real aws-sdk-go-v2 deserializer (types.ExecutionStats / awsAwsjson10_deserializeDocumentExecutionStats).

type FailedRun

type FailedRun struct {
	ErrorReport    *S3ReportLocation               `json:"error_report,omitempty"`
	Insights       *ScheduledQueryInsightsResponse `json:"insights,omitempty"`
	InvocationTime time.Time                       `json:"invocation_time"`
	TriggerTime    time.Time                       `json:"trigger_time"`
	Status         string                          `json:"status"`
	Failure        string                          `json:"failure"`
	Stats          ExecutionStats                  `json:"stats"`
}

FailedRun records one failed scheduled query run for DescribeScheduledQuery.RecentlyFailedRuns.

type Handler

type Handler struct {
	Backend StorageBackend
	// contains filtered or unexported fields
}

Handler is the Echo HTTP handler for the Timestream Query service.

func NewHandler

func NewHandler(backend StorageBackend) *Handler

NewHandler creates a new Timestream Query handler.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations returns the operations subject to chaos injection.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns the default region for chaos injection.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the service name for chaos injection.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation returns the operation name from the request.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns the ARN or name from the request body. It checks ScheduledQueryArn, ResourceARN, Arn, and Name fields in order.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations returns all supported Timestream Query operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler function for Timestream Query requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the matching priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the handler name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears handler state, delegating to the backend if it supports Reset.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher returns a matcher that identifies Timestream Query requests. It only matches operations explicitly supported by this handler to avoid intercepting operations belonging to other Timestream services (e.g. TimestreamWrite) that share the same X-Amz-Target prefix. Tag operations (TagResource, UntagResource, ListTagsForResource) are intentionally excluded: they are routed to the TimestreamWrite handler which provides a single unified tag store for all Timestream resource types.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker runs due scheduled queries on the backend clock until ctx is cancelled.

type InMemoryBackend

type InMemoryBackend struct {
	// contains filtered or unexported fields
}

InMemoryBackend is the in-memory backend for the Timestream Query service.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a new in-memory Timestream Query backend.

func (*InMemoryBackend) AccountID

func (b *InMemoryBackend) AccountID() string

AccountID returns the account ID for the backend.

func (*InMemoryBackend) AddScheduledQueryInternal

func (b *InMemoryBackend) AddScheduledQueryInternal(sq *ScheduledQuery)

AddScheduledQueryInternal is a test-only seed helper that stores a scheduled query directly, bypassing normal validation. It is used to pre-populate backend state in tests.

func (*InMemoryBackend) CancelQuery

func (b *InMemoryBackend) CancelQuery(_ context.Context, queryID string) error

CancelQuery cancels a running query (simulated no-op if not found). CancelQuery is documented as idempotent: cancelling a query that has already been cancelled must still succeed (with a CancellationMessage), not error, so the result is marked cancelled in place rather than deleted; an unknown QueryId still returns ValidationException (gap #9). ctx is accepted for interface consistency; query results are not region-isolated.

func (*InMemoryBackend) CreateScheduledQuery

func (b *InMemoryBackend) CreateScheduledQuery(
	ctx context.Context,
	name, queryString, scheduleExpression, executionRoleArn,
	notificationTopicArn, errorReportS3BucketName, targetDatabase, targetTable, clientToken, kmsKeyID string,
	errorReportEncryptionOption, errorReportObjectKeyPrefix string,
	tags map[string]string,
	targetDetail *ScheduledQueryTargetDetail,
) (*ScheduledQuery, error)

CreateScheduledQuery creates a new scheduled query.

clientToken supports the idempotency contract documented on CreateScheduledQueryInput.ClientToken: the aws-sdk-go-v2 client auto-generates a ClientToken on every call via its idempotency-token-autofill middleware, so a retried request (e.g. after a network blip following a successful create) must replay the original success rather than surface a spurious "already exists" conflict.

func (*InMemoryBackend) DeleteScheduledQuery

func (b *InMemoryBackend) DeleteScheduledQuery(ctx context.Context, arnStr string) error

DeleteScheduledQuery deletes a scheduled query by ARN. The ARN self-encodes the region, so no separate region resolution is needed. Any tags CreateScheduledQuery mirrored into the shared TimestreamWrite tag store (tagWriteBackend) are removed too, so a deleted ARN doesn't leave ghost tags behind for a later ListTagsForResource to surface.

func (*InMemoryBackend) DescribeAccountSettings

func (b *InMemoryBackend) DescribeAccountSettings(ctx context.Context) AccountSettings

DescribeAccountSettings returns the current account-level settings for the request region.

func (*InMemoryBackend) DescribeScheduledQuery

func (b *InMemoryBackend) DescribeScheduledQuery(_ context.Context, arnStr string) (*ScheduledQuery, error)

DescribeScheduledQuery returns details of a scheduled query by ARN. The ARN self-encodes the region, so no separate region resolution is needed.

func (*InMemoryBackend) ExecuteScheduledQuery

func (b *InMemoryBackend) ExecuteScheduledQuery(
	ctx context.Context, arnStr string, invocationTime time.Time, insightsMode string,
) error

ExecuteScheduledQuery runs the scheduled query once for invocationTime ("@scheduled_runtime") and ingests its result rows into the target table, recording the run outcome.

func (*InMemoryBackend) ListScheduledQueries

func (b *InMemoryBackend) ListScheduledQueries(ctx context.Context) []ScheduledQuerySummary

ListScheduledQueries returns all scheduled queries for the request region sorted by name.

func (*InMemoryBackend) ListScheduledQueriesEnriched

func (b *InMemoryBackend) ListScheduledQueriesEnriched(
	ctx context.Context, nextToken string, maxResults int32,
) ListScheduledQueriesResult

ListScheduledQueriesEnriched returns paged enriched scheduled query summaries for the request region.

func (*InMemoryBackend) ListScheduledQueriesFull

func (b *InMemoryBackend) ListScheduledQueriesFull(ctx context.Context) []*ScheduledQuery

ListScheduledQueriesFull returns all scheduled queries for the request region with full details, sorted by name.

func (*InMemoryBackend) ListTagsForResource

func (b *InMemoryBackend) ListTagsForResource(_ context.Context, arnStr string) ([]map[string]string, error)

ListTagsForResource returns tags for a resource identified by its ARN. The ARN self-encodes the region, so no separate region resolution is needed.

func (*InMemoryBackend) PrepareQuery

func (b *InMemoryBackend) PrepareQuery(
	ctx context.Context, queryString string, _ bool,
) (*PrepareQueryResult, error)

PrepareQuery validates a query string and returns its column and parameter metadata. It infers columns from the SELECT projection and parameters from ? markers.

Real Timestream documents ValidateOnly=true as the only supported mode for this operation, and PrepareQueryOutput.Columns/Parameters are both required (non-optional) response fields regardless of ValidateOnly -- they are the entire point of the call (describing a query's shape before running it as a scheduled query). validateOnly is accepted for wire-compatibility with the input shape but does not change the response: an earlier version of this method returned an empty Columns/Parameters list whenever ValidateOnly was true, which discarded the inferred result for the one mode real clients actually use. ctx is accepted for interface consistency; PrepareQuery is stateless.

func (*InMemoryBackend) Query

func (b *InMemoryBackend) Query(ctx context.Context, queryString string) *QueryResult

Query runs a query and returns its full result (legacy path); a failing query yields an empty result.

func (*InMemoryBackend) QueryWithOptions

func (b *InMemoryBackend) QueryWithOptions(ctx context.Context, opts QueryOptions) (*QueryPage, error)

QueryWithOptions executes a query with full options support (clientToken, pagination). ctx is accepted for interface consistency; query results are not region-isolated.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns the default region for the backend.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all backend state, returning it to a freshly initialised condition.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.

func (*InMemoryBackend) RunDue

func (b *InMemoryBackend) RunDue(ctx context.Context)

RunDue executes every automatic invocation of an enabled scheduled query that has come due on the backend clock.

func (*InMemoryBackend) SetCatalog

func (b *InMemoryBackend) SetCatalog(c Catalog)

SetCatalog wires the Timestream Write catalog; unset, table references are not checked.

func (*InMemoryBackend) SetClock

func (b *InMemoryBackend) SetClock(now func() time.Time)

SetClock replaces the wall clock used for now(), ago() and page-token expiry.

func (*InMemoryBackend) SetNotifier

func (b *InMemoryBackend) SetNotifier(n Notifier)

SetNotifier wires the SNS publisher for NotificationConfiguration.

func (*InMemoryBackend) SetObjectStore

func (b *InMemoryBackend) SetObjectStore(o billingexport.ObjectStore)

SetObjectStore wires the S3 store for scheduled query error reports and UNLOAD output.

func (*InMemoryBackend) SetQueryTimeout

func (b *InMemoryBackend) SetQueryTimeout(d time.Duration)

SetQueryTimeout overrides the query execution time limit; d <= 0 restores DefaultQueryTimeout.

func (*InMemoryBackend) SetRecordSource

func (b *InMemoryBackend) SetRecordSource(s RecordSource)

SetRecordSource wires the record source used to execute queries and scheduled-query writes. It also serves as the table catalog.

func (*InMemoryBackend) SetTagWriteBackend added in v1.3.1

func (b *InMemoryBackend) SetTagWriteBackend(wb TagWriteBackend)

SetTagWriteBackend wires the Timestream Write backend that owns the shared tag store. Left unwired, CreateScheduledQuery still records tags on the ScheduledQuery itself (this package's own TagResource/ListTagsForResource still serve them) -- only cross-service reads via TimestreamWrite are affected, matching how other cross-service seams in this repo degrade.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state to JSON. It implements persistence.Persistable.

func (*InMemoryBackend) TagResource

func (b *InMemoryBackend) TagResource(_ context.Context, arnStr string, tags map[string]string) error

TagResource adds tags to a resource identified by its ARN. The ARN self-encodes the region, so no separate region resolution is needed.

func (*InMemoryBackend) UntagResource

func (b *InMemoryBackend) UntagResource(_ context.Context, arnStr string, tagKeys []string) error

UntagResource removes tags from a resource identified by its ARN. The ARN self-encodes the region, so no separate region resolution is needed.

func (*InMemoryBackend) UpdateAccountSettings

func (b *InMemoryBackend) UpdateAccountSettings(
	ctx context.Context, queryPricingModel string, maxQueryTCU *int32, queryCompute *QueryComputeUpdate,
) (AccountSettings, error)

UpdateAccountSettings updates the account-level settings for the request region and returns the new state. Only non-empty queryPricingModel, non-nil maxQueryTCU, and non-nil queryCompute values are applied; omitted fields preserve their current values.

queryCompute wires UpdateAccountSettingsInput.QueryCompute -- switching the account between ON_DEMAND and PROVISIONED compute mode. An earlier version of this method accepted only queryPricingModel/maxQueryTCU, silently dropping QueryCompute from every request: the account could never actually transition away from the ON_DEMAND default even though DescribeAccountSettings always echoed a QueryCompute field back.

func (*InMemoryBackend) UpdateScheduledQuery

func (b *InMemoryBackend) UpdateScheduledQuery(ctx context.Context, arnStr, state string) error

UpdateScheduledQuery updates the state of a scheduled query by ARN. Only ENABLED and DISABLED are valid states. The ARN self-encodes the region, so no separate region resolution is needed.

type LastRunSummary

type LastRunSummary struct {
	ErrorReportLocation   *ErrorReportLocation            `json:"ErrorReportLocation,omitempty"`
	ExecutionStats        *ExecutionStats                 `json:"ExecutionStats,omitempty"`
	QueryInsightsResponse *ScheduledQueryInsightsResponse `json:"QueryInsightsResponse,omitempty"`
	FailureReason         string                          `json:"FailureReason,omitempty"`
	RunStatus             string                          `json:"RunStatus,omitempty"`
	TriggerTime           float64                         `json:"TriggerTime,omitempty"`
	InvocationTime        float64                         `json:"InvocationTime,omitempty"`
}

LastRunSummary holds the full summary of the most recent execution of a scheduled query. Timestamps are float64 (Unix epoch seconds) to match the AWS JSON protocol 1.0 wire format.

type LastUpdate

type LastUpdate struct {
	TargetQueryTCU *int32 `json:"TargetQueryTCU,omitempty"`
	Status         string `json:"Status,omitempty"`
}

LastUpdate reports the status of the most recent account-settings update affecting provisioned capacity (types.LastUpdate on the wire). This emulator applies QueryCompute changes synchronously, so Status is always SUCCEEDED.

type ListScheduledQueriesResult

type ListScheduledQueriesResult struct {
	NextToken string
	Items     []ScheduledQueryListEntry
}

ListScheduledQueriesResult is the paginated result of a ListScheduledQueries call.

type MixedMeasureMapping added in v1.5.0

type MixedMeasureMapping struct {
	MeasureName                   string                         `json:"MeasureName,omitempty"`
	SourceColumn                  string                         `json:"SourceColumn,omitempty"`
	TargetMeasureName             string                         `json:"TargetMeasureName,omitempty"`
	MeasureValueType              string                         `json:"MeasureValueType"`
	MultiMeasureAttributeMappings []MultiMeasureAttributeMapping `json:"MultiMeasureAttributeMappings,omitempty"`
}

MixedMeasureMapping maps a query result column to a measure (types.MixedMeasureMapping on the wire).

type MultiMeasureAttributeMapping added in v1.5.0

type MultiMeasureAttributeMapping struct {
	SourceColumn                    string `json:"SourceColumn"`
	TargetMultiMeasureAttributeName string `json:"TargetMultiMeasureAttributeName,omitempty"`
	MeasureValueType                string `json:"MeasureValueType"`
}

MultiMeasureAttributeMapping maps a source column to a multi-measure attribute (types.MultiMeasureAttributeMapping on the wire).

type MultiMeasureMappings added in v1.5.0

type MultiMeasureMappings struct {
	TargetMultiMeasureName        string                         `json:"TargetMultiMeasureName,omitempty"`
	MultiMeasureAttributeMappings []MultiMeasureAttributeMapping `json:"MultiMeasureAttributeMappings"`
}

MultiMeasureMappings groups multi-measure attribute mappings (types.MultiMeasureMappings on the wire).

type Notifier

type Notifier interface {
	Publish(ctx context.Context, topicARN, message string) error
}

Notifier publishes scheduled query notification messages to an SNS topic.

type PartitionKeySource

type PartitionKeySource interface {
	TablePartitionKeys(region, database, table string) []string
}

PartitionKeySource is optionally implemented by a RecordSource that knows a table's customer-defined partition key: the dimension names, or measure_name for a measure key, in schema order.

type PrepareQueryResult

type PrepareQueryResult struct {
	QueryString string
	Columns     []ColumnInfo
	Selected    []SelectColumn
	Parameters  []ColumnInfo
}

PrepareQueryResult holds the result of a PrepareQuery call (typed).

type Provider

type Provider struct{}

Provider implements service.Provider for the Timestream Query service.

func (*Provider) Init

Init initializes the Timestream Query service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type ProvisionedCapacity

type ProvisionedCapacity struct {
	ActiveQueryTCU            *int32                                    `json:"ActiveQueryTCU,omitempty"`
	LastUpdate                *LastUpdate                               `json:"LastUpdate,omitempty"`
	NotificationConfiguration *AccountSettingsNotificationConfiguration `json:"NotificationConfiguration,omitempty"`
}

ProvisionedCapacity holds the response-side provisioned-TCU configuration returned by DescribeAccountSettings/UpdateAccountSettings (types.ProvisionedCapacityResponse on the wire). The active-capacity field is named "ActiveQueryTCU" on the response -- "TargetQueryTCU" is the *request*-side field name (types.ProvisionedCapacityRequest) and is only used transiently while parsing an UpdateAccountSettings request body (see QueryComputeUpdate).

type QueryCompute

type QueryCompute struct {
	ProvisionedCapacity *ProvisionedCapacity `json:"ProvisionedCapacity,omitempty"`
	ComputeMode         string               `json:"ComputeMode,omitempty"` // ON_DEMAND | PROVISIONED
}

QueryCompute holds the compute mode and optional provisioned capacity (types.QueryComputeResponse on the wire).

type QueryComputeUpdate

type QueryComputeUpdate struct {
	TargetQueryTCU            *int32
	NotificationConfiguration *AccountSettingsNotificationConfiguration
	ComputeMode               string
}

QueryComputeUpdate is the parsed request-side shape for UpdateAccountSettingsInput.QueryCompute (types.QueryComputeRequest on the wire): the requested ComputeMode plus, when PROVISIONED, the requested TargetQueryTCU and optional NotificationConfiguration (types.ProvisionedCapacityRequest.NotificationConfiguration).

type QueryInsightsResponse

type QueryInsightsResponse struct {
	TemporalRange        *QueryTemporalRange   `json:"temporal_range,omitempty"`
	SpatialCoverage      *QuerySpatialCoverage `json:"spatial_coverage,omitempty"`
	OutputRows           int64                 `json:"OutputRows"`
	OutputBytes          int64                 `json:"OutputBytes"`
	UnloadPartitionCount int64                 `json:"UnloadPartitionCount,omitempty"`
	UnloadWrittenRows    int64                 `json:"UnloadWrittenRows,omitempty"`
	UnloadWrittenBytes   int64                 `json:"UnloadWrittenBytes,omitempty"`
	QuerySpatialCoverage float64               `json:"QuerySpatialCoverage,omitempty"`
	QueryTableCount      int64                 `json:"QueryTableCount"`
}

QueryInsightsResponse holds the insights payload returned alongside query results.

type QueryOptions

type QueryOptions struct {
	QueryString  string
	ClientToken  string
	NextToken    string
	InsightsMode string
	Principal    string
	MaxRows      int32
}

QueryOptions holds parameters for a Query call.

type QueryPage

type QueryPage struct {
	Insights    *QueryInsightsResponse
	QueryID     string
	NextToken   string
	Rows        []Row
	Columns     []ColumnInfo
	QueryStatus QueryStatusDetail
}

QueryPage is the page-level result returned by QueryWithOptions.

type QueryResult

type QueryResult struct {
	QueryID     string
	Rows        []Row
	Columns     []ColumnInfo
	Insights    QueryInsightsResponse
	QueryStatus QueryStatusDetail
	// Cancelled records whether CancelQuery has already been issued for this
	// query. CancelQueryOutput.CancellationMessage is documented as returned
	// "when a CancelQuery request for the query ... has already been issued",
	// i.e. cancellation is idempotent -- a repeat CancelQuery call for the
	// same QueryId must still succeed, not 404.
	Cancelled bool
}

QueryResult represents the result of a Query call (typed).

type QuerySpatialCoverage

type QuerySpatialCoverage struct {
	Max *QuerySpatialCoverageMax `json:"Max,omitempty"`
}

QuerySpatialCoverage mirrors types.QuerySpatialCoverage.

type QuerySpatialCoverageMax

type QuerySpatialCoverageMax struct {
	TableArn     string   `json:"TableArn"`
	PartitionKey []string `json:"PartitionKey"`
	Value        float64  `json:"Value"`
}

QuerySpatialCoverageMax mirrors types.QuerySpatialCoverageMax; Value is the fraction of partitions scanned.

type QueryStatusDetail

type QueryStatusDetail struct {
	ProgressPercentage     float64 `json:"ProgressPercentage"`
	CumulativeBytesScanned int64   `json:"CumulativeBytesScanned"`
	CumulativeBytesMetered int64   `json:"CumulativeBytesMetered"`
}

QueryStatusDetail holds byte-level progress info for a Query call.

type QueryTemporalRange

type QueryTemporalRange struct {
	Max *QueryTemporalRangeMax `json:"Max,omitempty"`
}

QueryTemporalRange mirrors types.QueryTemporalRange.

type QueryTemporalRangeMax

type QueryTemporalRangeMax struct {
	TableArn string `json:"TableArn"`
	Value    int64  `json:"Value"`
}

QueryTemporalRangeMax mirrors types.QueryTemporalRangeMax; Value is the scanned time range in nanoseconds.

type RecordSource

type RecordSource interface {
	Catalog
	// TableRecords returns the records still queryable at now.
	TableRecords(region, database, table string, now time.Time) ([]SourceRecord, error)
	ListDatabases(region string) []string
	ListTables(region, database string) []string
	AppendRecords(region, database, table string, records []SourceRecord) error
}

RecordSource is the seam onto Timestream Write's tables.

type RejectedError

type RejectedError struct {
	Rejected []RejectedRecord
}

RejectedError is returned by AppendRecords when the table rejects records.

func (*RejectedError) Error

func (e *RejectedError) Error() string

type RejectedRecord

type RejectedRecord struct {
	Reason string
	Index  int
}

RejectedRecord is one record a target table refused, by index into the appended batch.

type Row

type Row struct {
	Data []Datum `json:"Data"`
}

Row is a result row containing typed Data cells.

type S3Loc

type S3Loc struct {
	BucketName string `json:"bucketName"`
	ObjectKey  string `json:"objectKey"`
}

S3Loc is the notification form of an S3 report location.

type S3ReportLocation

type S3ReportLocation struct {
	ObjectKey  string `json:"ObjectKey,omitempty"`
	BucketName string `json:"BucketName,omitempty"`
}

S3ReportLocation is the S3 bucket + key for an error report.

type ScheduledQuery

type ScheduledQuery struct {
	CreationTime                time.Time                       `json:"creation_time"`
	LastRunTriggerTime          time.Time                       `json:"last_run_trigger_time,omitzero"`
	LastRunTime                 time.Time                       `json:"last_run_time"`
	NextRun                     time.Time                       `json:"next_run,omitzero"`
	LastRunStats                *ExecutionStats                 `json:"last_run_stats,omitempty"`
	LastRunInsights             *ScheduledQueryInsightsResponse `json:"last_run_insights,omitempty"`
	TargetDetail                *ScheduledQueryTargetDetail     `json:"target_detail,omitempty"`
	Tags                        map[string]string               `json:"tags"`
	LastRunErrorReport          *S3ReportLocation               `json:"last_run_error_report,omitempty"`
	ExecutionRoleArn            string                          `json:"execution_role_arn"`
	ErrorReportS3BucketName     string                          `json:"error_report_s3_bucket_name"`
	TargetTable                 string                          `json:"target_table"`
	State                       string                          `json:"state"`
	Name                        string                          `json:"name"`
	Arn                         string                          `json:"arn"`
	KmsKeyID                    string                          `json:"kms_key_id,omitempty"`
	TargetDatabase              string                          `json:"target_database"`
	LastRunStatus               string                          `json:"last_run_status,omitempty"`
	LastRunFailure              string                          `json:"last_run_failure,omitempty"`
	QueryString                 string                          `json:"query_string"`
	ScheduleExpression          string                          `json:"schedule_expression"`
	NotificationTopicArn        string                          `json:"notification_topic_arn"`
	ErrorReportObjectKeyPrefix  string                          `json:"error_report_object_key_prefix,omitempty"`
	ErrorReportEncryptionOption string                          `json:"error_report_encryption_option,omitempty"`
	RecentlyFailedRuns          []FailedRun                     `json:"recently_failed_runs,omitempty"`
}

ScheduledQuery represents a Timestream scheduled query.

type ScheduledQueryInsightsResponse

type ScheduledQueryInsightsResponse struct {
	QuerySpatialCoverage *QuerySpatialCoverage `json:"QuerySpatialCoverage,omitempty"`
	QueryTemporalRange   *QueryTemporalRange   `json:"QueryTemporalRange,omitempty"`
	OutputRows           int64                 `json:"OutputRows"`
	OutputBytes          int64                 `json:"OutputBytes"`
	QueryTableCount      int64                 `json:"QueryTableCount"`
}

ScheduledQueryInsightsResponse mirrors types.ScheduledQueryInsightsResponse.

type ScheduledQueryListEntry

type ScheduledQueryListEntry struct {
	TargetDestination      *TargetDestinationForList `json:"TargetDestination,omitempty"`
	Arn                    string                    `json:"Arn"`
	Name                   string                    `json:"Name"`
	State                  string                    `json:"State"`
	LastRunStatus          string                    `json:"LastRunStatus,omitempty"`
	CreationTime           float64                   `json:"CreationTime,omitempty"`
	NextInvocationTime     float64                   `json:"NextInvocationTime,omitempty"`
	PreviousInvocationTime float64                   `json:"PreviousInvocationTime,omitempty"`
}

ScheduledQueryListEntry is the enriched summary used in list responses (gap #19). Timestamps are float64 (Unix epoch seconds) to match the AWS JSON protocol 1.0 wire format.

type ScheduledQuerySummary

type ScheduledQuerySummary struct {
	Arn   string `json:"Arn"`
	Name  string `json:"Name"`
	State string `json:"State"`
}

ScheduledQuerySummary is a reduced view used in list responses.

type ScheduledQueryTargetDetail added in v1.5.0

type ScheduledQueryTargetDetail struct {
	MultiMeasureMappings *MultiMeasureMappings
	TimeColumn           string
	MeasureNameColumn    string
	DimensionMappings    []DimensionMapping
	MixedMeasureMappings []MixedMeasureMapping
}

ScheduledQueryTargetDetail holds the TargetConfiguration.TimestreamConfiguration fields beyond DatabaseName/TableName. TimeColumn and DimensionMappings are both required (types.TimestreamConfiguration, api_op_CreateScheduledQuery.go) whenever TargetConfiguration is set; MeasureNameColumn/MixedMeasureMappings/ MultiMeasureMappings are optional.

type SchemaSource

type SchemaSource interface {
	// TableShapes returns one value-less SourceRecord per distinct record shape ever written, first-seen first.
	TableShapes(region, database, table string) []SourceRecord
}

SchemaSource is optionally implemented by a RecordSource that remembers table schemas after the records that defined them have aged out.

type SelectColumn

type SelectColumn struct {
	DatabaseName string
	TableName    string
	ColumnInfo
	Aliased bool
}

SelectColumn is a PrepareQuery output column (types.SelectColumn).

type SnsConfiguration added in v1.2.0

type SnsConfiguration struct {
	TopicArn string `json:"TopicArn,omitempty"`
}

SnsConfiguration holds the SNS topic ARN for account-settings (provisioned-capacity) change notifications (types.SnsConfiguration).

type SourceDimension

type SourceDimension struct {
	Name  string
	Value string
}

SourceDimension is one dimension of a stored record.

type SourceMeasure

type SourceMeasure struct {
	Name  string
	Value string
	Type  string
}

SourceMeasure is one named measure of a MULTI record. TIMESTAMP values arrive formatted as "2006-01-02 15:04:05.000000000".

type SourceRecord

type SourceRecord struct {
	Time             time.Time
	MeasureName      string
	MeasureValue     string
	MeasureValueType string
	Dimensions       []SourceDimension
	Measures         []SourceMeasure
	Version          int64
}

SourceRecord is a record read from, or written to, a Timestream Write table. A record is single-measure when MeasureValueType is not MULTI, else Measures holds its values.

type StorageBackend

type StorageBackend interface {
	AccountID() string
	Region() string
	CreateScheduledQuery(
		ctx context.Context,
		name, queryString, scheduleExpression, executionRoleArn,
		notificationTopicArn, errorReportS3BucketName, targetDatabase, targetTable, clientToken, kmsKeyID string,
		errorReportEncryptionOption, errorReportObjectKeyPrefix string,
		tags map[string]string,
		targetDetail *ScheduledQueryTargetDetail,
	) (*ScheduledQuery, error)
	DescribeScheduledQuery(ctx context.Context, arnStr string) (*ScheduledQuery, error)
	DeleteScheduledQuery(ctx context.Context, arnStr string) error
	ListScheduledQueries(ctx context.Context) []ScheduledQuerySummary
	ListScheduledQueriesFull(ctx context.Context) []*ScheduledQuery
	ListScheduledQueriesEnriched(ctx context.Context, nextToken string, maxResults int32) ListScheduledQueriesResult
	UpdateScheduledQuery(ctx context.Context, arnStr, state string) error
	ExecuteScheduledQuery(ctx context.Context, arnStr string, invocationTime time.Time, insightsMode string) error
	Query(ctx context.Context, queryString string) *QueryResult
	QueryWithOptions(ctx context.Context, opts QueryOptions) (*QueryPage, error)
	CancelQuery(ctx context.Context, queryID string) error
	TagResource(ctx context.Context, arnStr string, tags map[string]string) error
	UntagResource(ctx context.Context, arnStr string, tagKeys []string) error
	ListTagsForResource(ctx context.Context, arnStr string) ([]map[string]string, error)
	DescribeAccountSettings(ctx context.Context) AccountSettings
	PrepareQuery(ctx context.Context, queryString string, validateOnly bool) (*PrepareQueryResult, error)
	UpdateAccountSettings(
		ctx context.Context, queryPricingModel string, maxQueryTCU *int32, queryCompute *QueryComputeUpdate,
	) (AccountSettings, error)
}

StorageBackend defines the interface for Timestream Query backend implementations. All mutating methods must be safe for concurrent use.

type TagWriteBackend added in v1.3.1

type TagWriteBackend interface {
	TagResource(arn string, tags map[string]string) error
	UntagResource(arn string, tagKeys []string) error
}

TagWriteBackend is the seam into the Timestream Write backend, which serves TagResource/UntagResource/ListTagsForResource for scheduled-query ARNs too (handler.go's writeServiceTagOps: real Timestream exposes one shared tag store across both API surfaces). Without this wired, CreateScheduledQuery's Tags never reach the store those reads consult.

type TargetDestinationForList

type TargetDestinationForList struct {
	TimestreamDestination *TimestreamDestinationForList `json:"TimestreamDestination,omitempty"`
}

TargetDestinationForList summarises the write destination for list responses.

type TimeSeriesDataPoint

type TimeSeriesDataPoint struct {
	Time  string `json:"Time"`
	Value Datum  `json:"Value"`
}

TimeSeriesDataPoint is one entry in a TimeSeries datum.

type TimestreamDestinationForList

type TimestreamDestinationForList struct {
	DatabaseName string `json:"DatabaseName,omitempty"`
	TableName    string `json:"TableName,omitempty"`
}

TimestreamDestinationForList is the Timestream write target in a list summary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL