AggVariant
The AggVariant function calls a warehouse aggregate function that returns a Variant data type. This function is the aggregate version of CallVariant and can be applied to identify distinct values from a lower grouped level in the parent/higher level grouping of a table.
Syntax
AggVariant(function name, arguments...)
Function arguments:
- function name (required): The name of an aggregate function supported by your data warehouse.
- arguments (required): One or more arguments to be passed to the warehouse function. All arguments must meet the warehouse function’s input requirements.
Example
A table contains an ARRAY_UNIQUE_AGG
column that returns an array containing all the distinct customers who purchased at least one or more items per Product Type. You can pass Snowflake's ARRAY_UNION_AGG function to the AggVariant function to identify all distinct customers who made at least one purchase that week.
The
ARRAY_UNION_AGG
function takes in one column containing the arrays with distinct values as produced by Snowflake's ARRAY_UNIQUE_AGG function.
AggVariant("ARRAY_UNION_AGG", [ARRAY_UNIQUE_AGG])
- Return an array that contains the union of distinct customers from the input arrays in the
ARRAY_UNIQUE_AGG
column.
Updated 4 months ago