Skip to content

Commit ae0c24f

Browse files
feat: add grouping aggregate function
Support for the SQL grouping function that is used with group by statements. The SQL grouping function typically has a single column parameter. However, many dialects also provide a grouping_id function, which behaves as an extended grouping function, allowing multiple parameters to be specified. Calcite treats grouping and grouing_id as synonyms and allows multiple parameters for either function name. This implementation follows the Calcite model by allowing multiple parameters. The behavior for a single parameter should be the same as grouping, while multiple parameters should behave the same as grouping_id. Signed-off-by: Mark S. Lewis <[email protected]>
1 parent 793c64b commit ae0c24f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

extensions/functions_aggregate_generic.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,25 @@ aggregate_functions:
4040
decomposable: MANY
4141
intermediate: any1?
4242
return: any1?
43+
- name: grouping
44+
description: >
45+
Indicates whether the column(s) in a GROUP BY list are aggregated or
46+
not. This function can be used to distinguish between a NULL value in
47+
the raw data vs the total across all values that are returned by ROLLUP,
48+
CUBE or GROUPING SETS for a specific column.
49+
50+
Returns an integer value which is unique for each combination of
51+
grouping values. The return value can be interpreted as a bit vector
52+
where bits in the binary representation of the integer correspond to each
53+
grouping value.
54+
55+
For a single grouping value, the result is 1 if the data is aggregated
56+
across the specified column or 0 for not aggregated in the result set.
57+
impls:
58+
- args:
59+
- value: any?
60+
ordered: true
61+
variadic:
62+
min: 1
63+
nullability: DECLARED_OUTPUT
64+
return: i64

0 commit comments

Comments
 (0)