Rust

query

Module

Usage-specific queries: time buckets, dimensions and the aggregate.

Contents

use utopia_usage::query::aggregate;
Rust
pub fn aggregate(function: &str) -> Result<Query>

The aggregate query: max takes the largest value per bucket instead of the per-type default.

use utopia_usage::query::extract_aggregate;
Rust
pub fn extract_aggregate(queries: &[Query]) -> Option<&'static str>

The aggregate function named by queries (the first max), if any.

use utopia_usage::query::group_by;
Rust
pub fn group_by(attribute: &str) -> Query

A groupBy query on one dimension (attribute, no values).

use utopia_usage::query::group_by_interval;
Rust
pub fn group_by_interval(attribute: &str, interval: &str) -> Result<Query>

A groupByTimeBucket query: results bucketed by interval on attribute (usually time).

use utopia_usage::query::group_by_many;
Rust
pub fn group_by_many<S: Into<String>>(attributes: impl IntoIterator<Item = S>) -> Query

A groupBy query on several dimensions (the base Query::groupBy: no attribute, the dimensions as values).

use utopia_usage::query::interval_sql;
Rust
pub fn interval_sql(interval: &str) -> Option<&'static str>

The INTERVAL expression of a bucket size.

Rust
pub const VALID_AGGREGATES: &[&str] = &["max"]

The aggregation functions aggregate accepts.

Rust
pub const VALID_INTERVALS: &[(&str, &str)] = &[ ("1m", "INTERVAL 1 MINUTE"), ("5m", "INTERVAL 5 MINUTE"), ("15m", "INTERVAL 15 MINUTE"), ("30m", "INTERVAL 30 MINUTE"), ("1h", "INTERVAL 1 HOUR"), ("1d", "INTERVAL 1 DAY"), ("1w", "INTERVAL 1 WEEK"), ("1M", "INTERVAL 1 MONTH"), ]

The bucket sizes group_by_interval accepts and their ClickHouse INTERVAL expressions.