From ddac90952c01c4066213c983bf8a5b48f3d10e07 Mon Sep 17 00:00:00 2001 From: Chandra Sanapala Date: Wed, 24 Jul 2024 15:19:33 +0530 Subject: [PATCH 1/3] feat: add aggregate count functions with decimal return type --- extensions/functions_aggregate_decimal.yaml | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 extensions/functions_aggregate_decimal.yaml diff --git a/extensions/functions_aggregate_decimal.yaml b/extensions/functions_aggregate_decimal.yaml new file mode 100644 index 000000000..cdeb9443e --- /dev/null +++ b/extensions/functions_aggregate_decimal.yaml @@ -0,0 +1,41 @@ +%YAML 1.2 +--- +aggregate_functions: + - name: "count" + description: Count a set of values + impls: + - args: + - name: x + value: any + options: + overflow: + values: [SILENT, SATURATE, ERROR] + nullability: DECLARED_OUTPUT + decomposable: MANY + intermediate: decimal<38,0> + return: decimal<38,0> + - name: "count_star" + description: "Count a set of records (not field referenced)" + impls: + - options: + overflow: + values: [SILENT, SATURATE, ERROR] + nullability: DECLARED_OUTPUT + decomposable: MANY + intermediate: decimal<38,0> + return: decimal<38,0> + - name: "approx_count_distinct" + description: >- + Calculates the approximate number of rows that contain distinct values of the expression argument using + HyperLogLog. This function provides an alternative to the COUNT (DISTINCT expression) function, which + returns the exact number of rows that contain distinct values of an expression. APPROX_COUNT_DISTINCT + processes large amounts of data significantly faster than COUNT, with negligible deviation from the exact + result. + impls: + - args: + - name: x + value: any + nullability: DECLARED_OUTPUT + decomposable: MANY + intermediate: binary + return: decimal<38,0> From af108cd1b4614130ca2f865ae8c484b0499832d8 Mon Sep 17 00:00:00 2001 From: Chandra Sanapala Date: Tue, 30 Jul 2024 04:18:51 +0530 Subject: [PATCH 2/3] address review comments --- ...decimal.yaml => functions_aggregate_decimal_output.yaml} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename extensions/{functions_aggregate_decimal.yaml => functions_aggregate_decimal_output.yaml} (82%) diff --git a/extensions/functions_aggregate_decimal.yaml b/extensions/functions_aggregate_decimal_output.yaml similarity index 82% rename from extensions/functions_aggregate_decimal.yaml rename to extensions/functions_aggregate_decimal_output.yaml index cdeb9443e..c8ed988b5 100644 --- a/extensions/functions_aggregate_decimal.yaml +++ b/extensions/functions_aggregate_decimal_output.yaml @@ -2,7 +2,7 @@ --- aggregate_functions: - name: "count" - description: Count a set of values + description: Count a set of values. Result is returned as a decimal instead of i64. impls: - args: - name: x @@ -15,7 +15,7 @@ aggregate_functions: intermediate: decimal<38,0> return: decimal<38,0> - name: "count_star" - description: "Count a set of records (not field referenced)" + description: "Count a set of records (not field referenced). Result is returned as a decimal instead of i64." impls: - options: overflow: @@ -30,7 +30,7 @@ aggregate_functions: HyperLogLog. This function provides an alternative to the COUNT (DISTINCT expression) function, which returns the exact number of rows that contain distinct values of an expression. APPROX_COUNT_DISTINCT processes large amounts of data significantly faster than COUNT, with negligible deviation from the exact - result. + result. Result is returned as a decimal instead of i64. impls: - args: - name: x From f9f9404436f361bec55002c0feb702543bdc6829 Mon Sep 17 00:00:00 2001 From: Chandra Sanapala Date: Thu, 1 Aug 2024 05:14:14 +0530 Subject: [PATCH 3/3] use count as name instead of count_star --- extensions/functions_aggregate_decimal_output.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/functions_aggregate_decimal_output.yaml b/extensions/functions_aggregate_decimal_output.yaml index c8ed988b5..13a3b2e23 100644 --- a/extensions/functions_aggregate_decimal_output.yaml +++ b/extensions/functions_aggregate_decimal_output.yaml @@ -14,7 +14,7 @@ aggregate_functions: decomposable: MANY intermediate: decimal<38,0> return: decimal<38,0> - - name: "count_star" + - name: "count" description: "Count a set of records (not field referenced). Result is returned as a decimal instead of i64." impls: - options: