- Snowflake window functions documentation
- Databricks window functions documentation
- Amazon Redshift window functions documentation
- Google BigQuery analytic functions documentation
Window functions share some similarities with aggregate functions, and for some use cases you may find that the Aggregate component will serve your needs better. Bear the following in mind when evaluating which component best suits your use case:
- For an aggregate function, the input is a group of rows from the dataset, and the output is one row (so the aggregated group is collapsed into a single row).
- For a window function, the input is every row within the dataset, and the output is one row per input row.
Use case
Window functions enable a range of advanced analytics such as ranking, time-series processing, and data comparison. Some typical uses for window functions include:- Calculating cumulative totals across a sequence. For example, cumulative sales per customer. This would use the SUM window function.
- Calculating a moving average across a set of data. For example, to smooth out fluctuations in time-series data. This would use the Average window function.
- Identifying the first or last value in a set of ordered rows. This would use the First Value or Last Value window function.
Properties
- Snowflake
- Databricks
- Amazon Redshift
- Google BigQuery
A human-readable name for the component.
Defines whether the component passes all input columns into the output. The default is Yes.
Select the columns that will define how the input data is partitioned. The window calculation will be performed on each partition.
Select the columns that will be used to sort the partitioned data. For each column, select the sort order:
- Ascending
- Descending
- Nulls First (sort null values first)
- Nulls Last (sort null values last)
Select a function to be performed on the rows contained in the window. Refer to the Snowflake Window Function documentation for full details.Supported window functions:
- Any Value: Returns some value of the expression from the group. For full details, read the Snowflake documentation.
- Approximate Count Distinct: Uses HyperLogLog to return an approximation of the distinct cardinality of the input. For full details, read the Snowflake documentation.
- Array Aggregate Distinct: Returns the input values, pivoted into an array. For full details, read the Snowflake documentation.
- Average: Returns the average (arithmetic mean) of the input column values in the window. For full details, read the Snowflake documentation.
- Bit AND Aggregate: Returns the bitwise AND value of all non-Null numeric records in a group. For full details, read the Snowflake documentation.
- Bit OR Aggregate: Returns the bitwise OR value of all non-Null numeric records in a group. For full details, read the Snowflake documentation.
- Bit XOR Aggregate: Returns the bitwise XOR value of all non-Null numeric records in a group. For full details, read the Snowflake documentation.
- Conditional Change Event: Returns a window event number for each row where the value of an argument is different from the value of the argument in the previous row. For full details, read the Snowflake documentation.
- Conditional True Event: Returns a window event number for each row within a window partition based on the result of a boolean argument. For full details, read the Snowflake documentation.
- Count: Returns a count of the non-Null values for the specified field. For full details, read the Snowflake documentation.
- First Value: Given an ordered set of rows, returns the specified column value with respect to the first row in the window frame. For full details, read the Snowflake documentation.
- Hash Aggregate: Returns an aggregate signed 64-bit hash value over the (unordered) set of input rows. For full details, read the Snowflake documentation.
- Kurtosis: Returns the population excess kurtosis of non-Null records. For full details, read the Snowflake documentation.
- Last Value: Given an ordered set of rows, returns the specified column value with respect to the last row in the window frame. For full details, read the Snowflake documentation.
- List Aggregate: Returns the concatenated input values, separated by a delimiter string. For full details, read the Snowflake documentation.
- List Aggregate Distinct: Returns the concatenated input values, separated by a delimiter string. Duplicate values are eliminated before concatenating. For full details, read the Snowflake documentation.
- Maximum: Returns the maximum of the input expression values. The MAX function works with numeric values and ignores Null values. For full details, read the Snowflake documentation.
- Median: Calculates the median value for the range of values in a window or partition. Null values in the range are ignored. For full details, read the Snowflake documentation.
- Minimum: Returns the minimum of the input expression values. The MIN function works with numeric values and ignores Null values. For full details, read the Snowflake documentation.
- Population Variance: Returns the population variance of a set of numeric columns. For full details, read the Snowflake documentation.
- Sample Variance: Returns the sample variance of a set of numeric columns. For full details, read the Snowflake documentation.
- Standard Deviation: Returns the standard deviation of a set of numeric values. For full details, read the Snowflake documentation.
- Standard Deviation Population: Returns the population standard deviation of a set of numeric values. For full details, read the Snowflake documentation.
- Sum: Returns the sum of the input column in the window. For full details, read the Snowflake documentation.
This property is visible after Ordering within partitions is set. Select which row of the partition the window calculation will start on. Options are:
- unbounded preceding: The window starts at the first row of the partition.
- current row: The window starts at the current row.
- offset preceding: The window starts a number of rows (offset) before the current row. This requires you to set the Lower bound offset property.
This property is visible after Ordering within partitions is set. Select which row of the partition the window calculation will end on. Options are:
- unbounded following: The window ends at the last row of the partition.
- current row: The window ends at the current row.
- offset following: The window ends a number of rows (offset) after the current row. This requires you to set the Upper bound offset property.
If the Lower bound property is set to offset preceding, enter the number of rows before the current row that the window will start on.
If the Upper bound property is set to offset following, enter the number of rows after the current row that the window will end on.
