Two-step aggregation
First, create an intermediate aggregation by using aggregate functions instead of calculating the final result in one step.Then, calculate the final result using analytic functions.
- 社区版
- 企业版
stats_agg
Perform linear regression analysis on two-dimensional data, such as calculating correlation coefficients and covariance. And you can also separately calculate the common statistical data of each dimension, aggregate the data into an intermediate statistical aggregation form for further calculation.
Aggregation will only occur when both x
and y
are not empty.
stats_agg(y, x)
Options | Description |
---|---|
y | The y values in the dataset to be used for statistical aggregation. |
x | The x values in the dataset to be used for statistical aggregation. |
View stats_agg
Example
stats_agg
supports the following functions for two-step aggregation
Function | Description |
---|---|
num_vals | Calculate the number of values in a two-dimensional statistical aggregate. |
average_y , average_x | Calculate the average from a two-dimensional statistical aggregate for the dimension specified. |
sum_y , sum_x | Calculate the sum from a two-dimensional statistical aggregate for the dimension specified. |
stddev_samp_y , stddev_samp_x | Calculate the standard deviation of the specified dimension after two-dimensional statistical aggregation, with the method being sample. |
stddev_pop_y , stddev_pop_x | Calculate the standard deviation from a two-dimensional statistical aggregate for the dimension specified, method is population. |
var_samp_y , var_samp_x | Calculate the variance of the specified dimension after two-dimensional statistical aggregation, with the method being sample. |
var_pop_y , var_pop_x | Calculate the variance from a two-dimensional statistical aggregate for the dimension specified, method is population. |
skewness_samp_y , skewness_samp_x | Calculate the skewness value of the specified dimension after two-dimensional statistical aggregation, with the method being sample. |
skewness_pop_y , skewness_pop_x | Calculate the skewness value of the specified dimension after two-dimensional statistical aggregation, method is population. |
kurtosis_samp_y , kurtosis_samp_x | Calculate the kurtosis value of the specified dimension after two-dimensional statistical aggregation, with the method being sample. |
kurtosis_pop_y , kurtosis_pop_x | Calculate the kurtosis value of the specified dimension after aggregating two-dimensional statistics, method is population. |
correlation | Calculate the correlation after two-dimensional statistical aggregation. |
covariance_samp , covariance_pop | Calculate the covariance after two-dimensional statistical aggregation. |
determination_coeff | Calculate the determination coefficient after two-dimensional statistical aggregation. |
slope | Calculate the slope of the linear regression line based on two-dimensional statistical aggregation. |
intercept | Calculate the intercept of y after two-dimensional statistical aggregation. |
x_intercept | Calculate the intercept of x after two-dimensional statistical aggregation. |
View Sample
gauge_agg
Analyze Gauge data.Unlike Counter, Gauge can decrease as well as increase.
gauge_agg(time, numeric_expression)
Options | Description |
---|---|
numeric_expression | Expression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators. |
View gauge_agg
Example
gauge_agg
supports the following functions for two-step aggregation
Function | Description |
---|---|
delta | Obtain the changes of Gauge within a period of time.This is a simple increment, calculated by subtracting the last seen value from the first one. |
time_delta | Get the duration, subtract the time of the last Gauge from the time of the first Gauge. |
rate | Calculate the ratio of Gauge changes to time changes. |
first_time | Get the minimum timestamp in the Gauge. |
last_time | Get the maximum timestamp in the Gauge. |
first_val | Get the value corresponding to the minimum timestamp in the Gauge. |
last_val | Get the value corresponding to the maximum timestamp in the Gauge. |
idelta_left | Calculate the earliest instantaneous change of Gauge.This is equal to the second value minus the first value. |
idelta_right | Calculate the latest instantaneous change of Gauge.This is equal to the last value minus the penultimate value. |
compact_state_agg
Given a system or value that switches between discrete states, summarize the time spent in each state.For example, you can use the compact_state_agg
function to track the time the system spends in error
, running
, or starting
states.
compact_state_agg(time_expression, state)
Options | Description |
---|---|
time_expression | The time expression to operate.Can be a constant, column, or function, and any combination of arithmetic operators. |
View compact_state_agg
Example
The above example aggregates the state data together for further analysis, compact_state_agg
supports the following two-step aggregation functions:
Function | Description |
---|---|
duration_in | Calculate the duration of a certain state, or calculate the duration of a certain state within a specific time period. |
duration_in
duration_in(state_agg_data, state [,begin_time, interval_time])
Options | Description |
---|---|
state_agg_data | Result set returned by the state_agg_data function. |
state | The state type of any is the same as compact_state_agg. |
begin_time | Optional, specifies the start time within the specified time period. |
interval_time | Optional, specifies the duration of the time period, when not specified, the time period is infinite. |
View duration_in
Example
state_agg
Given a system or value that switches between discrete states, track transitions between states.
state_agg(time_expression, state)
Calculate the time spent in each state.
View state_agg
Example
The above example aggregates the state data together for further analysis, state_agg
supports the following two-step aggregation functions:
Function | Description |
---|---|
duration_in | Calculate the duration of a certain state, or calculate the duration of a certain state within a specific time period. |
state_at | Statistics are in a state of affairs at a time. |
duration_in
duration_in(state_agg_data, state [,begin_time, interval_time])
Options | Description |
---|---|
state_agg_data | Result set returned by the state_agg function. |
state | The state type of any is the same as compact_state_agg . |
begin_time | Optional, specifies the start time within the specified time period. |
interval_time | Optional, specifies the duration of the time period, when not specified, the time period is infinite. |
View duration_in
Example
state_at
state_at(state_agg_data, time_expression)
Options | Description |
---|---|
state_agg_data | Result set returned by the state_agg function. |
time_expression | The time expression to operate.Can be a constant, column, or function, and any combination of arithmetic operators. |
View state_at
Example
- 社区版
- 企业版
candlestick_agg
Conduct financial asset data analysis, can obtain the opening and closing prices of stocks, as well as the lowest and highest prices.
candlestick_agg(time, price, volume)
View candlestick_agg
Example
You can extract the opening price, closing price, etc. separately in the above example.Supported functions include:
Function | Description |
---|---|
close | Closing price. |
close_time | Closing time. |
high | High price. |
high_time | High price time. |
low | Low price. |
low_time | Low price time. |
open | Opening price. |
open_time | Opening time. |
volume | Total cumulative. |
vwap | Volume Weighted Average Price. |