executor

package
v0.86.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SummaryDimensionsLimit is the maximum number of dimensions to summarize.
	SummaryDimensionsLimit = 15
	// SummaryTimeDimensionsLimit is the maximum number of time dimensions to summarize.
	SummaryTimeDimensionsLimit = 2
	// SummarySampleInterval is the time offset from the max timestamp used for sampling values.
	SummarySampleInterval = 24 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DimensionSummary

type DimensionSummary struct {
	Name         string `json:"name"`
	DataType     string `json:"data_type"`
	ExampleValue any    `json:"example_value,omitempty"`
	HasNulls     bool   `json:"has_nulls,omitempty"`
	MinValue     any    `json:"min_value,omitempty"`
	MaxValue     any    `json:"max_value,omitempty"`
}

DimensionSummary provides statistics for a single dimension in the metrics view.

type Executor

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

Executor is capable of executing queries and other operations against a metrics view.

func New

func New(ctx context.Context, rt *runtime.Runtime, instanceID string, mv *runtimev1.MetricsViewSpec, streaming bool, sec *runtime.ResolvedSecurity, priority int, userAttrs map[string]any) (*Executor, error)

New creates a new Executor for the provided metrics view.

func (*Executor) Annotations

func (e *Executor) Annotations(ctx context.Context, qry *metricsview.AnnotationsQuery) ([]map[string]any, error)

func (*Executor) BindAnnotationsQuery

func (e *Executor) BindAnnotationsQuery(ctx context.Context, qry *metricsview.AnnotationsQuery, timestamps metricsview.TimestampsResult) error

BindAnnotationsQuery allows setting min, max and watermark from a cache for an AnnotationsQuery

func (*Executor) BindQuery

func (e *Executor) BindQuery(qry *metricsview.Query, timestamps metricsview.TimestampsResult) error

BindQuery allows to set min, max and watermark from a cache.

func (*Executor) CacheKey

func (e *Executor) CacheKey(ctx context.Context) ([]byte, bool, error)

CacheKey returns a cache key based on the executor's metrics view's cache key configuration. If ok is false, caching is disabled for the metrics view.

func (*Executor) Close

func (e *Executor) Close()

Close releases the resources held by the Executor.

func (*Executor) Export

func (e *Executor) Export(ctx context.Context, qry *metricsview.Query, executionTime *time.Time, format drivers.FileFormat, headers []string) (string, error)

Export executes and exports the provided query against the metrics view. It returns a path to a temporary file containing the export. The caller is responsible for cleaning up the file.

func (*Executor) LatestQueryTable added in v0.86.1

func (e *Executor) LatestQueryTable() string

LatestQueryTable returns the table used by the last Query/Export call. Returns the rollup table if one was selected, otherwise the base metricsview table.

func (*Executor) Query

func (e *Executor) Query(ctx context.Context, qry *metricsview.Query, executionTime *time.Time) (*drivers.Result, error)

Query executes the provided query against the metrics view.

func (*Executor) ResolveTimeRange added in v0.83.0

func (e *Executor) ResolveTimeRange(ctx context.Context, tr *metricsview.TimeRange, tz *time.Location, executionTime *time.Time) error

ResolveTimeRange resolves the given time range, ensuring only its Start and End properties are populated.

func (*Executor) RewriteQueryTimeRanges added in v0.85.1

func (e *Executor) RewriteQueryTimeRanges(ctx context.Context, qry *metricsview.Query, executionTime *time.Time) error

RewriteQueryTimeRanges rewrites the time ranges in the query to fixed start/end timestamps.

func (*Executor) Schema

func (e *Executor) Schema(ctx context.Context) (*runtimev1.StructType, error)

Schema returns a schema for the metrics view's dimensions and measures.

func (*Executor) Search

func (e *Executor) Search(ctx context.Context, qry *metricsview.SearchQuery, executionTime *time.Time) ([]metricsview.SearchResult, error)

Search executes the provided query against the metrics view.

func (*Executor) Summary

func (e *Executor) Summary(ctx context.Context) (*SummaryResult, error)

Summary provides statistics for all dimensions and measures in the metrics view.

func (*Executor) Timestamps

func (e *Executor) Timestamps(ctx context.Context, timeDim string) (metricsview.TimestampsResult, error)

Timestamps queries min, max and watermark for the metrics view. For the primary time dimension it also resolves rollup table timestamps if rollups are present.

func (*Executor) ValidateAndNormalizeMetricsView

func (e *Executor) ValidateAndNormalizeMetricsView(ctx context.Context) (*ValidateMetricsViewResult, error)

ValidateAndNormalizeMetricsView validates the dimensions and measures in the executor's metrics view and returns a ValidateMetricsViewResult It also inherits properties from parent metrics view and populates the schema of the metrics view if all dimensions and measures are valid. Note: Beware that it modifies the e.metricsView spec in place, e.g. to populate the dimension and measure types.

func (*Executor) ValidateQuery

func (e *Executor) ValidateQuery(qry *metricsview.Query) error

ValidateQuery validates the provided query against the executor's metrics view.

type IndexErr

type IndexErr struct {
	Idx int
	Err error
}

IndexErr contains an error and the index of the dimension or measure that caused the error.

type SummaryResult

type SummaryResult struct {
	DefaultTimeDimension DimensionSummary   `json:"default_time_dimension,omitempty"`
	Dimensions           []DimensionSummary `json:"dimensions"`
}

SummaryResult is the statistics for a single metrics view.

type ValidateMetricsViewResult

type ValidateMetricsViewResult struct {
	TimeDimensionErr error
	DimensionErrs    []IndexErr
	MeasureErrs      []IndexErr
	OtherErrs        []error
}

ValidateMetricsViewResult contains the results of validating a metrics view.

func (*ValidateMetricsViewResult) Error

func (r *ValidateMetricsViewResult) Error() error

Error returns a single error containing all validation errors. If there are no errors, it returns nil.

func (*ValidateMetricsViewResult) IsZero

func (r *ValidateMetricsViewResult) IsZero() bool

IsZero returns true if the result contains no errors.

Jump to

Keyboard shortcuts

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