This is an automated email from the ASF dual-hosted git repository.
alsay pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datasketches-bigquery.git
The following commit(s) were added to refs/heads/main by this push:
new 7e59792 show exception message
7e59792 is described below
commit 7e597928dd9adbb4527f6f5bbbe71d502ecd2985
Author: AlexanderSaydakov <[email protected]>
AuthorDate: Tue Jun 11 13:07:54 2024 -0700
show exception message
---
theta_sketch_a_not_b.sql | 12 ++++++++----
theta_sketch_scalar_intersection.sql | 16 ++++++++++------
theta_sketch_scalar_union.sql | 16 ++++++++++------
theta_sketch_to_string.sql | 2 +-
4 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/theta_sketch_a_not_b.sql b/theta_sketch_a_not_b.sql
index 3586a7e..e95a93e 100644
--- a/theta_sketch_a_not_b.sql
+++ b/theta_sketch_a_not_b.sql
@@ -18,10 +18,14 @@
CREATE OR REPLACE FUNCTION
`$BQ_PROJECT.$BQ_DATASET`.theta_sketch_a_not_b(sketch1 BYTES, sketch2 BYTES,
seed INT64) RETURNS BYTES LANGUAGE js
OPTIONS (library=["$GCS_BUCKET/theta_sketch.js"]) AS R"""
const default_seed = BigInt(9001);
-var a_not_b = new Module.theta_a_not_b(seed ? BigInt(seed) : default_seed);
try {
- return a_not_b.computeWithB64ReturnB64Compressed(sketch1, sketch2, seed ?
BigInt(seed) : default_seed);
-} finally {
- a_not_b.delete();
+ var a_not_b = new Module.theta_a_not_b(seed ? BigInt(seed) : default_seed);
+ try {
+ return a_not_b.computeWithB64ReturnB64Compressed(sketch1, sketch2, seed ?
BigInt(seed) : default_seed);
+ } finally {
+ a_not_b.delete();
+ }
+} catch (e) {
+ throw new Error(Module.getExceptionMessage(e));
}
""";
diff --git a/theta_sketch_scalar_intersection.sql
b/theta_sketch_scalar_intersection.sql
index 58c38ef..90f7322 100644
--- a/theta_sketch_scalar_intersection.sql
+++ b/theta_sketch_scalar_intersection.sql
@@ -18,12 +18,16 @@
CREATE OR REPLACE FUNCTION
`$BQ_PROJECT.$BQ_DATASET`.theta_sketch_scalar_intersection(sketchBytes1 BYTES,
sketchBytes2 BYTES, seed INT64) RETURNS BYTES LANGUAGE js
OPTIONS (library=["$GCS_BUCKET/theta_sketch.js"]) AS R"""
const default_seed = BigInt(9001);
-var intersection = new Module.theta_intersection(seed ? BigInt(seed) :
default_seed);
try {
- intersection.updateWithB64(sketchBytes1, seed ? BigInt(seed) : default_seed);
- intersection.updateWithB64(sketchBytes2, seed ? BigInt(seed) : default_seed);
- return intersection.getResultB64Compressed();
-} finally {
- intersection.delete();
+ var intersection = new Module.theta_intersection(seed ? BigInt(seed) :
default_seed);
+ try {
+ intersection.updateWithB64(sketchBytes1, seed ? BigInt(seed) :
default_seed);
+ intersection.updateWithB64(sketchBytes2, seed ? BigInt(seed) :
default_seed);
+ return intersection.getResultB64Compressed();
+ } finally {
+ intersection.delete();
+ }
+} catch (e) {
+ throw new Error(Module.getExceptionMessage(e));
}
""";
diff --git a/theta_sketch_scalar_union.sql b/theta_sketch_scalar_union.sql
index cacf2a9..08da19d 100644
--- a/theta_sketch_scalar_union.sql
+++ b/theta_sketch_scalar_union.sql
@@ -19,12 +19,16 @@ CREATE OR REPLACE FUNCTION
`$BQ_PROJECT.$BQ_DATASET`.theta_sketch_scalar_union(s
OPTIONS (library=["$GCS_BUCKET/theta_sketch.js"]) AS R"""
const default_lg_k = 12;
const default_seed = BigInt(9001);
-var union = new Module.theta_union(lg_k ? lg_k : default_lg_k, seed ?
BigInt(seed) : default_seed);
try {
- union.updateWithB64(sketch1, seed ? BigInt(seed) : default_seed)
- union.updateWithB64(sketch2, seed ? BigInt(seed) : default_seed)
- return union.getResultB64Compressed();
-} finally {
- union.delete();
+ var union = new Module.theta_union(lg_k ? lg_k : default_lg_k, seed ?
BigInt(seed) : default_seed);
+ try {
+ union.updateWithB64(sketch1, seed ? BigInt(seed) : default_seed)
+ union.updateWithB64(sketch2, seed ? BigInt(seed) : default_seed)
+ return union.getResultB64Compressed();
+ } finally {
+ union.delete();
+ }
+} catch (e) {
+ throw new Error(Module.getExceptionMessage(e));
}
""";
diff --git a/theta_sketch_to_string.sql b/theta_sketch_to_string.sql
index 3e8cff3..cd196b8 100644
--- a/theta_sketch_to_string.sql
+++ b/theta_sketch_to_string.sql
@@ -17,8 +17,8 @@
CREATE OR REPLACE FUNCTION
`$BQ_PROJECT.$BQ_DATASET`.theta_sketch_to_string(base64 BYTES, seed INT64)
RETURNS STRING LANGUAGE js
OPTIONS (library=["$GCS_BUCKET/theta_sketch.js"]) AS R"""
+const default_seed = BigInt(9001);
try {
- const default_seed = BigInt(9001);
var sketch = Module.compact_theta_sketch.deserializeFromB64(base64, seed ?
BigInt(seed) : default_seed);
try {
return sketch.toString();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]