This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch handling_nulls
in repository https://gitbox.apache.org/repos/asf/datasketches-bigquery.git


The following commit(s) were added to refs/heads/handling_nulls by this push:
     new 2b2ee59  handling nulls with tests
2b2ee59 is described below

commit 2b2ee59329907aa455f7ccc2ec5ae8728b1c371d
Author: AlexanderSaydakov <[email protected]>
AuthorDate: Thu Mar 6 23:31:01 2025 -0800

    handling nulls with tests
---
 tuple/sqlx/tuple_sketch_int64_agg_union_lgk_seed_mode.sqlx | 6 ++----
 tuple/test/tuple_sketch_int64_test.js                      | 6 ++++++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/tuple/sqlx/tuple_sketch_int64_agg_union_lgk_seed_mode.sqlx 
b/tuple/sqlx/tuple_sketch_int64_agg_union_lgk_seed_mode.sqlx
index add46b0..d7e18b9 100644
--- a/tuple/sqlx/tuple_sketch_int64_agg_union_lgk_seed_mode.sqlx
+++ b/tuple/sqlx/tuple_sketch_int64_agg_union_lgk_seed_mode.sqlx
@@ -76,11 +76,9 @@ export function aggregate(state, sketch) {
 }
 
 export function serialize(state) {
-  if (state.union == null) return state; // for transition 
deserialize-serialize
+  if (state.union == null && state.serialized != null) return state; // for 
transition deserialize-serialize
+  ensureUnion(state);
   try {
-    if (state.serialized != null) {
-      state.union.updateWithBytes(state.serialized, state.seed);
-    }
     state.serialized = state.union.getResultAsUint8Array();
     state.union.delete();
     delete state.union;
diff --git a/tuple/test/tuple_sketch_int64_test.js 
b/tuple/test/tuple_sketch_int64_test.js
index b7ec661..b30adfa 100644
--- a/tuple/test/tuple_sketch_int64_test.js
+++ b/tuple/test/tuple_sketch_int64_test.js
@@ -34,6 +34,12 @@ generate_udaf_test("tuple_sketch_int64_agg_int64", {
   expected_output: tuple_empty
 });
 
+generate_udaf_test("tuple_sketch_int64_agg_union", {
+  input_columns: [`sketch`],
+  input_rows: `SELECT * FROM UNNEST([CAST(NULL AS BYTES), CAST(NULL AS BYTES), 
CAST(NULL AS BYTES)]) AS sketch`,
+  expected_output: tuple_empty
+});
+
 const tuple_1 = 
`FROM_BASE64('AgMJAQAazJMDAAAAAAAAALcMbuWor0AIAQAAAAAAAACFf0C2icflNAEAAAAAAAAAF8EdUoUHAXsBAAAAAAAAAA==')`;
 
 generate_udaf_test("tuple_sketch_int64_agg_string", {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to