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

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


The following commit(s) were added to refs/heads/temp_tables by this push:
     new 159b659  use temp tables
159b659 is described below

commit 159b659abc3a6526ed5041783f82026c4754e8e0
Author: AlexanderSaydakov <[email protected]>
AuthorDate: Fri Feb 7 11:40:35 2025 -0800

    use temp tables
---
 cpc/test/cpc_sketch_test.sql                       | 28 +++++-----
 fi/test/frequent_strings_sketch_test.sql           | 10 ++--
 hll/test/hll_sketch_test.sql                       | 22 ++++----
 kll/test/kll_sketch_example.sql                    |  8 +--
 kll/test/kll_sketch_test.sql                       | 28 +++++-----
 req/test/req_sketch_float_test.sql                 | 36 ++++++------
 tdigest/test/tdigest_double_test.sql               | 24 ++++----
 theta/test/theta_sketch_test.sql                   | 32 +++++------
 theta/test/theta_sketch_test2.sql                  | 64 ++++++++++++++++++++++
 .../test/tuple_sketch_int64_issue_124.sql          | 16 +-----
 tuple/test/tuple_sketch_int64_test.sql             | 41 +++++++-------
 11 files changed, 181 insertions(+), 128 deletions(-)

diff --git a/cpc/test/cpc_sketch_test.sql b/cpc/test/cpc_sketch_test.sql
index dab6dc8..ce60395 100644
--- a/cpc/test/cpc_sketch_test.sql
+++ b/cpc/test/cpc_sketch_test.sql
@@ -39,47 +39,47 @@ select `$BQ_DATASET`.cpc_sketch_get_estimate_seed(
 );
 
 # using defaults
-create or replace table `$BQ_DATASET`.cpc_sketch(sketch bytes);
+create or replace temp table cpc_sketch(sketch bytes);
 
-insert into `$BQ_DATASET`.cpc_sketch
+insert into cpc_sketch
 (select `$BQ_DATASET`.cpc_sketch_agg_int64(value) from 
unnest(GENERATE_ARRAY(1, 10000, 1)) as value);
-insert into `$BQ_DATASET`.cpc_sketch
+insert into cpc_sketch
 (select `$BQ_DATASET`.cpc_sketch_agg_int64(value) from 
unnest(GENERATE_ARRAY(100000, 110000, 1)) as value);
 
-select `$BQ_DATASET`.cpc_sketch_to_string(sketch) from 
`$BQ_DATASET`.cpc_sketch;
+select `$BQ_DATASET`.cpc_sketch_to_string(sketch) from cpc_sketch;
 
 # expected about 20000
 select `$BQ_DATASET`.cpc_sketch_get_estimate(
   `$BQ_DATASET`.cpc_sketch_agg_union(sketch)
-) from `$BQ_DATASET`.cpc_sketch;
+) from cpc_sketch;
 
 select `$BQ_DATASET`.cpc_sketch_get_estimate_and_bounds(
   `$BQ_DATASET`.cpc_sketch_agg_union(sketch),
   3
-) from `$BQ_DATASET`.cpc_sketch;
+) from cpc_sketch;
 
-drop table `$BQ_DATASET`.cpc_sketch;
+drop table cpc_sketch;
 
 # using full signatures
-create or replace table `$BQ_DATASET`.cpc_sketch(sketch bytes);
+create or replace temp table cpc_sketch(sketch bytes);
 
-insert into `$BQ_DATASET`.cpc_sketch
+insert into cpc_sketch
 (select `$BQ_DATASET`.cpc_sketch_agg_int64_lgk_seed(value, struct<byteint, 
int64>(10, 111)) from unnest(GENERATE_ARRAY(1, 10000, 1)) as value);
-insert into `$BQ_DATASET`.cpc_sketch
+insert into cpc_sketch
 (select `$BQ_DATASET`.cpc_sketch_agg_int64_lgk_seed(value, struct<byteint, 
int64>(10, 111)) from unnest(GENERATE_ARRAY(100000, 110000, 1)) as value);
 
-select `$BQ_DATASET`.cpc_sketch_to_string_seed(sketch, 111) from 
`$BQ_DATASET`.cpc_sketch;
+select `$BQ_DATASET`.cpc_sketch_to_string_seed(sketch, 111) from cpc_sketch;
 
 # expected about 20000
 select `$BQ_DATASET`.cpc_sketch_get_estimate_seed(
   `$BQ_DATASET`.cpc_sketch_agg_union_lgk_seed(sketch, struct<byteint, 
int64>(10, 111)),
   111
-) from `$BQ_DATASET`.cpc_sketch;
+) from cpc_sketch;
 
 select `$BQ_DATASET`.cpc_sketch_get_estimate_and_bounds_seed(
   `$BQ_DATASET`.cpc_sketch_agg_union_lgk_seed(sketch, struct<byteint, 
int64>(10, 111)),
   3,
   111
-) from `$BQ_DATASET`.cpc_sketch;
+) from cpc_sketch;
 
-drop table `$BQ_DATASET`.cpc_sketch;
+drop table cpc_sketch;
diff --git a/fi/test/frequent_strings_sketch_test.sql 
b/fi/test/frequent_strings_sketch_test.sql
index a7634f1..d419809 100644
--- a/fi/test/frequent_strings_sketch_test.sql
+++ b/fi/test/frequent_strings_sketch_test.sql
@@ -19,14 +19,14 @@
 
 select 
`$BQ_DATASET`.frequent_strings_sketch_to_string(`$BQ_DATASET`.frequent_strings_sketch_build(str,
 1, 5)) from unnest(["a", "b", "c"]) as str;
 
-create or replace table `$BQ_DATASET`.fs_sketch(sketch bytes);
+create or replace temp table fs_sketch(sketch bytes);
 
-insert into `$BQ_DATASET`.fs_sketch
+insert into fs_sketch
 (select `$BQ_DATASET`.frequent_strings_sketch_build(str, 1, 5) from 
unnest(["a", "b", "c", "d"]) as str);
 
-insert into `$BQ_DATASET`.fs_sketch
+insert into fs_sketch
 (select `$BQ_DATASET`.frequent_strings_sketch_build(str, 1, 5) from 
unnest(["a", "a", "c"]) as str);
 
-select 
`$BQ_DATASET`.frequent_strings_sketch_get_result(`$BQ_DATASET`.frequent_strings_sketch_merge(sketch,
 5), "NO_FALSE_NEGATIVES", null) from `$BQ_DATASET`.fs_sketch;
+select 
`$BQ_DATASET`.frequent_strings_sketch_get_result(`$BQ_DATASET`.frequent_strings_sketch_merge(sketch,
 5), "NO_FALSE_NEGATIVES", null) from fs_sketch;
 
-drop table `$BQ_DATASET`.fs_sketch;
+drop table fs_sketch;
diff --git a/hll/test/hll_sketch_test.sql b/hll/test/hll_sketch_test.sql
index 0d1245b..f3a14ab 100644
--- a/hll/test/hll_sketch_test.sql
+++ b/hll/test/hll_sketch_test.sql
@@ -42,34 +42,34 @@ select `$BQ_DATASET`.hll_sketch_to_string(
   )
 );
 
-create or replace table `$BQ_DATASET`.hll_sketch(sketch bytes);
+create or replace temp table hll_sketch(sketch bytes);
 
-insert into `$BQ_DATASET`.hll_sketch
+insert into hll_sketch
 (select `$BQ_DATASET`.hll_sketch_agg_int64(value) from 
unnest(GENERATE_ARRAY(1, 10000, 1)) as value);
-insert into `$BQ_DATASET`.hll_sketch
+insert into hll_sketch
 (select `$BQ_DATASET`.hll_sketch_agg_int64(value) from 
unnest(GENERATE_ARRAY(100000, 110000, 1)) as value);
 
 # expected estimate about 20000
 select `$BQ_DATASET`.hll_sketch_to_string(
   `$BQ_DATASET`.hll_sketch_agg_union(sketch)
-) from `$BQ_DATASET`.hll_sketch;
+) from hll_sketch;
 
 select `$BQ_DATASET`.hll_sketch_to_string(
   `$BQ_DATASET`.hll_sketch_agg_union_lgk_type(sketch, struct<byteint, 
string>(10, "HLL_6"))
-) from `$BQ_DATASET`.hll_sketch;
+) from hll_sketch;
 
-drop table `$BQ_DATASET`.hll_sketch;
+drop table hll_sketch;
 
-create or replace table `$BQ_DATASET`.hll_sketch(sketch bytes);
+create or replace temp table hll_sketch(sketch bytes);
 
-insert into `$BQ_DATASET`.hll_sketch
+insert into hll_sketch
 (select `$BQ_DATASET`.hll_sketch_agg_int64_lgk_type(value, struct<int, 
string>(8, "HLL_6")) from unnest(GENERATE_ARRAY(1, 10000, 1)) as value);
-insert into `$BQ_DATASET`.hll_sketch
+insert into hll_sketch
 (select `$BQ_DATASET`.hll_sketch_agg_int64_lgk_type(value, struct<int, 
string>(8, "HLL_6")) from unnest(GENERATE_ARRAY(100000, 110000, 1)) as value);
 
 # expected estimate about 20000
 select `$BQ_DATASET`.hll_sketch_to_string(
   `$BQ_DATASET`.hll_sketch_agg_union_lgk_type(sketch, struct<byteint, 
string>(8, "HLL_6"))
-) from `$BQ_DATASET`.hll_sketch;
+) from hll_sketch;
 
-drop table `$BQ_DATASET`.hll_sketch;
+drop table hll_sketch;
diff --git a/kll/test/kll_sketch_example.sql b/kll/test/kll_sketch_example.sql
index 9fa28b7..2153069 100644
--- a/kll/test/kll_sketch_example.sql
+++ b/kll/test/kll_sketch_example.sql
@@ -19,7 +19,7 @@
 
 # Creating sample data with 1 million records split into 100 groups of nearly 
equal size
 
-CREATE OR REPLACE TABLE `$BQ_DATASET`.sample_data AS
+CREATE OR REPLACE TEMP TABLE sample_data AS
 SELECT
   CONCAT("group_key_", CAST(RAND() * 100 AS INT64)) as group_key,
   RAND() AS x
@@ -28,12 +28,12 @@ FROM
 
 # Creating KLL merge sketches for a group key
 
-CREATE OR REPLACE TABLE `$BQ_DATASET`.agg_sample_data AS
+CREATE OR REPLACE TEMP TABLE agg_sample_data AS
 SELECT
   group_key,
   count(*) AS total_count,
   `$BQ_DATASET`.kll_sketch_float_build_k(x, 250) AS kll_sketch
-FROM `$BQ_DATASET`.sample_data
+FROM sample_data
 GROUP BY group_key;
 
 # Merge group based sketches into a single sketch and then get approx quantiles
@@ -42,7 +42,7 @@ WITH agg_data AS (
   SELECT
     `$BQ_DATASET`.kll_sketch_float_merge_k(kll_sketch, 250) as 
merged_kll_sketch,
     SUM(total_count) as total_count
-  FROM `$BQ_DATASET`.agg_sample_data
+  FROM agg_sample_data
 )
 SELECT
   `$BQ_DATASET`.kll_sketch_float_get_quantile(merged_kll_sketch, 0.0, true) AS 
mininum,
diff --git a/kll/test/kll_sketch_test.sql b/kll/test/kll_sketch_test.sql
index 6cbef51..ddc69d1 100644
--- a/kll/test/kll_sketch_test.sql
+++ b/kll/test/kll_sketch_test.sql
@@ -17,46 +17,46 @@
  * under the License.
  */
 
-create or replace table `$BQ_DATASET`.kll_sketch(sketch bytes);
+create or replace temp table kll_sketch(sketch bytes);
 
 # using default
-insert into `$BQ_DATASET`.kll_sketch
+insert into kll_sketch
 (select `$BQ_DATASET`.kll_sketch_float_build(value) from 
unnest([1,2,3,4,5,6,7,8,9,10]) as value);
 
 # using full signature
-insert into `$BQ_DATASET`.kll_sketch
+insert into kll_sketch
 (select `$BQ_DATASET`.kll_sketch_float_build_k(value, 100) from 
unnest([11,12,13,14,15,16,17,18,19,20]) as value);
 
-select `$BQ_DATASET`.kll_sketch_float_to_string(sketch) from 
`$BQ_DATASET`.kll_sketch;
+select `$BQ_DATASET`.kll_sketch_float_to_string(sketch) from kll_sketch;
 
 # using default
-select 
`$BQ_DATASET`.kll_sketch_float_to_string(`$BQ_DATASET`.kll_sketch_float_merge(sketch))
 from `$BQ_DATASET`.kll_sketch;
+select 
`$BQ_DATASET`.kll_sketch_float_to_string(`$BQ_DATASET`.kll_sketch_float_merge(sketch))
 from kll_sketch;
 
 # using full signature
-select 
`$BQ_DATASET`.kll_sketch_float_to_string(`$BQ_DATASET`.kll_sketch_float_merge_k(sketch,
 100)) from `$BQ_DATASET`.kll_sketch;
+select 
`$BQ_DATASET`.kll_sketch_float_to_string(`$BQ_DATASET`.kll_sketch_float_merge_k(sketch,
 100)) from kll_sketch;
 
 # expected 0.5
-select 
`$BQ_DATASET`.kll_sketch_float_get_rank(`$BQ_DATASET`.kll_sketch_float_merge(sketch),
 10, true) from `$BQ_DATASET`.kll_sketch;
+select 
`$BQ_DATASET`.kll_sketch_float_get_rank(`$BQ_DATASET`.kll_sketch_float_merge(sketch),
 10, true) from kll_sketch;
 
 # expected 10
-select 
`$BQ_DATASET`.kll_sketch_float_get_quantile(`$BQ_DATASET`.kll_sketch_float_merge(sketch),
 0.5, true) from `$BQ_DATASET`.kll_sketch;
+select 
`$BQ_DATASET`.kll_sketch_float_get_quantile(`$BQ_DATASET`.kll_sketch_float_merge(sketch),
 0.5, true) from kll_sketch;
 
 # expected 20
-select 
`$BQ_DATASET`.kll_sketch_float_get_n(`$BQ_DATASET`.kll_sketch_float_merge(sketch))
 from `$BQ_DATASET`.kll_sketch;
+select 
`$BQ_DATASET`.kll_sketch_float_get_n(`$BQ_DATASET`.kll_sketch_float_merge(sketch))
 from kll_sketch;
 
 # expected 0.5, 0.5
-select 
`$BQ_DATASET`.kll_sketch_float_get_pmf(`$BQ_DATASET`.kll_sketch_float_merge(sketch),
 [10.0], true) from `$BQ_DATASET`.kll_sketch;
+select 
`$BQ_DATASET`.kll_sketch_float_get_pmf(`$BQ_DATASET`.kll_sketch_float_merge(sketch),
 [10.0], true) from kll_sketch;
 
 # expected 0.5, 1
-select 
`$BQ_DATASET`.kll_sketch_float_get_cdf(`$BQ_DATASET`.kll_sketch_float_merge(sketch),
 [10.0], true) from `$BQ_DATASET`.kll_sketch;
+select 
`$BQ_DATASET`.kll_sketch_float_get_cdf(`$BQ_DATASET`.kll_sketch_float_merge(sketch),
 [10.0], true) from kll_sketch;
 
 # expected 1
-select 
`$BQ_DATASET`.kll_sketch_float_get_min_value(`$BQ_DATASET`.kll_sketch_float_merge(sketch))
 from `$BQ_DATASET`.kll_sketch;
+select 
`$BQ_DATASET`.kll_sketch_float_get_min_value(`$BQ_DATASET`.kll_sketch_float_merge(sketch))
 from kll_sketch;
 
 # expected 20
-select 
`$BQ_DATASET`.kll_sketch_float_get_max_value(`$BQ_DATASET`.kll_sketch_float_merge(sketch))
 from `$BQ_DATASET`.kll_sketch;
+select 
`$BQ_DATASET`.kll_sketch_float_get_max_value(`$BQ_DATASET`.kll_sketch_float_merge(sketch))
 from kll_sketch;
 
-drop table `$BQ_DATASET`.kll_sketch;
+drop table kll_sketch;
 
 # expected about 1.3%
 select 
`$BQ_DATASET`.kll_sketch_float_get_normalized_rank_error(`$BQ_DATASET`.kll_sketch_float_build(value),
 false) from unnest(generate_array(1, 10000)) as value;
diff --git a/req/test/req_sketch_float_test.sql 
b/req/test/req_sketch_float_test.sql
index 1349177..9bcfb15 100644
--- a/req/test/req_sketch_float_test.sql
+++ b/req/test/req_sketch_float_test.sql
@@ -19,52 +19,52 @@
 
 # using defaults
 
-create or replace table `$BQ_DATASET`.req_sketch(sketch bytes);
+create or replace temp table req_sketch(sketch bytes);
 
-insert into `$BQ_DATASET`.req_sketch
+insert into req_sketch
 (select `$BQ_DATASET`.req_sketch_float_build(value) from 
unnest([1,2,3,4,5,6,7,8,9,10]) as value);
 
-insert into `$BQ_DATASET`.req_sketch
+insert into req_sketch
 (select `$BQ_DATASET`.req_sketch_float_build(value) from 
unnest([11,12,13,14,15,16,17,18,19,20]) as value);
 
-select 
`$BQ_DATASET`.req_sketch_float_to_string(`$BQ_DATASET`.req_sketch_float_merge(sketch))
 from `$BQ_DATASET`.req_sketch;
+select 
`$BQ_DATASET`.req_sketch_float_to_string(`$BQ_DATASET`.req_sketch_float_merge(sketch))
 from req_sketch;
 
 # expected 0.5
-select 
`$BQ_DATASET`.req_sketch_float_get_rank(`$BQ_DATASET`.req_sketch_float_merge(sketch),
 10, true) from `$BQ_DATASET`.req_sketch;
+select 
`$BQ_DATASET`.req_sketch_float_get_rank(`$BQ_DATASET`.req_sketch_float_merge(sketch),
 10, true) from req_sketch;
 
 # expected 10
-select 
`$BQ_DATASET`.req_sketch_float_get_quantile(`$BQ_DATASET`.req_sketch_float_merge(sketch),
 0.5, true) from `$BQ_DATASET`.req_sketch;
+select 
`$BQ_DATASET`.req_sketch_float_get_quantile(`$BQ_DATASET`.req_sketch_float_merge(sketch),
 0.5, true) from req_sketch;
 
 # expected 0.5, 0.5
-select 
`$BQ_DATASET`.req_sketch_float_get_pmf(`$BQ_DATASET`.req_sketch_float_merge(sketch),
 [10.0], true) from `$BQ_DATASET`.req_sketch;
+select 
`$BQ_DATASET`.req_sketch_float_get_pmf(`$BQ_DATASET`.req_sketch_float_merge(sketch),
 [10.0], true) from req_sketch;
 
 # expected 0.5, 1
-select 
`$BQ_DATASET`.req_sketch_float_get_cdf(`$BQ_DATASET`.req_sketch_float_merge(sketch),
 [10.0], true) from `$BQ_DATASET`.req_sketch;
+select 
`$BQ_DATASET`.req_sketch_float_get_cdf(`$BQ_DATASET`.req_sketch_float_merge(sketch),
 [10.0], true) from req_sketch;
 
 # expected 1
-select 
`$BQ_DATASET`.req_sketch_float_get_min_value(`$BQ_DATASET`.req_sketch_float_merge(sketch))
 from `$BQ_DATASET`.req_sketch;
+select 
`$BQ_DATASET`.req_sketch_float_get_min_value(`$BQ_DATASET`.req_sketch_float_merge(sketch))
 from req_sketch;
 
 # expected 20
-select 
`$BQ_DATASET`.req_sketch_float_get_max_value(`$BQ_DATASET`.req_sketch_float_merge(sketch))
 from `$BQ_DATASET`.req_sketch;
+select 
`$BQ_DATASET`.req_sketch_float_get_max_value(`$BQ_DATASET`.req_sketch_float_merge(sketch))
 from req_sketch;
 
 # expected 20
-select 
`$BQ_DATASET`.req_sketch_float_get_n(`$BQ_DATASET`.req_sketch_float_merge(sketch))
 from `$BQ_DATASET`.req_sketch;
+select 
`$BQ_DATASET`.req_sketch_float_get_n(`$BQ_DATASET`.req_sketch_float_merge(sketch))
 from req_sketch;
 
 # expected 20
-select 
`$BQ_DATASET`.req_sketch_float_get_num_retained(`$BQ_DATASET`.req_sketch_float_merge(sketch))
 from `$BQ_DATASET`.req_sketch;
+select 
`$BQ_DATASET`.req_sketch_float_get_num_retained(`$BQ_DATASET`.req_sketch_float_merge(sketch))
 from req_sketch;
 
-drop table `$BQ_DATASET`.req_sketch;
+drop table req_sketch;
 
 # using full signatures
 
-create or replace table `$BQ_DATASET`.req_sketch(sketch bytes);
+create or replace temp table req_sketch(sketch bytes);
 
-insert into `$BQ_DATASET`.req_sketch
+insert into req_sketch
 (select `$BQ_DATASET`.req_sketch_float_build_k_hra(value, struct<int, 
bool>(10, false)) from unnest([1,2,3,4,5,6,7,8,9,10]) as value);
 
-insert into `$BQ_DATASET`.req_sketch
+insert into req_sketch
 (select `$BQ_DATASET`.req_sketch_float_build_k_hra(value, struct<int, 
bool>(10, false)) from unnest([11,12,13,14,15,16,17,18,19,20]) as value);
 
-select 
`$BQ_DATASET`.req_sketch_float_to_string(`$BQ_DATASET`.req_sketch_float_merge_k_hra(sketch,
 struct<int, bool>(10, false))) from `$BQ_DATASET`.req_sketch;
+select 
`$BQ_DATASET`.req_sketch_float_to_string(`$BQ_DATASET`.req_sketch_float_merge_k_hra(sketch,
 struct<int, bool>(10, false))) from req_sketch;
 
-drop table `$BQ_DATASET`.req_sketch;
+drop table req_sketch;
diff --git a/tdigest/test/tdigest_double_test.sql 
b/tdigest/test/tdigest_double_test.sql
index e3d79e9..35963ea 100644
--- a/tdigest/test/tdigest_double_test.sql
+++ b/tdigest/test/tdigest_double_test.sql
@@ -17,37 +17,37 @@
  * under the License.
  */
 
-create or replace table `$BQ_DATASET`.tdigest_double(sketch bytes);
+create or replace temp table tdigest_double(sketch bytes);
 
 # using default
-insert into `$BQ_DATASET`.tdigest_double
+insert into tdigest_double
 (select `$BQ_DATASET`.tdigest_double_build(value) from 
unnest([1,2,3,4,5,6,7,8,9,10]) as value);
 
 # using full signature
-insert into `$BQ_DATASET`.tdigest_double
+insert into tdigest_double
 (select `$BQ_DATASET`.tdigest_double_build_k(value, 100) from 
unnest([11,12,13,14,15,16,17,18,19,20]) as value);
 
-select `$BQ_DATASET`.tdigest_double_to_string(sketch) from 
`$BQ_DATASET`.tdigest_double;
+select `$BQ_DATASET`.tdigest_double_to_string(sketch) from tdigest_double;
 
 # using default
-select 
`$BQ_DATASET`.tdigest_double_to_string(`$BQ_DATASET`.tdigest_double_merge(sketch))
 from `$BQ_DATASET`.tdigest_double;
+select 
`$BQ_DATASET`.tdigest_double_to_string(`$BQ_DATASET`.tdigest_double_merge(sketch))
 from tdigest_double;
 
 # using full signature
-select 
`$BQ_DATASET`.tdigest_double_to_string(`$BQ_DATASET`.tdigest_double_merge_k(sketch,
 100)) from `$BQ_DATASET`.tdigest_double;
+select 
`$BQ_DATASET`.tdigest_double_to_string(`$BQ_DATASET`.tdigest_double_merge_k(sketch,
 100)) from tdigest_double;
 
 # expected 0.5
-select 
`$BQ_DATASET`.tdigest_double_get_rank(`$BQ_DATASET`.tdigest_double_merge(sketch),
 10) from `$BQ_DATASET`.tdigest_double;
+select 
`$BQ_DATASET`.tdigest_double_get_rank(`$BQ_DATASET`.tdigest_double_merge(sketch),
 10) from tdigest_double;
 
 # expected 10
-select 
`$BQ_DATASET`.tdigest_double_get_quantile(`$BQ_DATASET`.tdigest_double_merge(sketch),
 0.5) from `$BQ_DATASET`.tdigest_double;
+select 
`$BQ_DATASET`.tdigest_double_get_quantile(`$BQ_DATASET`.tdigest_double_merge(sketch),
 0.5) from tdigest_double;
 
 # expected 20
-select 
`$BQ_DATASET`.tdigest_double_get_total_weight(`$BQ_DATASET`.tdigest_double_merge(sketch))
 from `$BQ_DATASET`.tdigest_double;
+select 
`$BQ_DATASET`.tdigest_double_get_total_weight(`$BQ_DATASET`.tdigest_double_merge(sketch))
 from tdigest_double;
 
 # expected 1
-select 
`$BQ_DATASET`.tdigest_double_get_min_value(`$BQ_DATASET`.tdigest_double_merge(sketch))
 from `$BQ_DATASET`.tdigest_double;
+select 
`$BQ_DATASET`.tdigest_double_get_min_value(`$BQ_DATASET`.tdigest_double_merge(sketch))
 from tdigest_double;
 
 # expected 20
-select 
`$BQ_DATASET`.tdigest_double_get_max_value(`$BQ_DATASET`.tdigest_double_merge(sketch))
 from `$BQ_DATASET`.tdigest_double;
+select 
`$BQ_DATASET`.tdigest_double_get_max_value(`$BQ_DATASET`.tdigest_double_merge(sketch))
 from tdigest_double;
 
-drop table `$BQ_DATASET`.tdigest_double;
+drop table tdigest_double;
diff --git a/theta/test/theta_sketch_test.sql b/theta/test/theta_sketch_test.sql
index 98e2c34..40e2b2e 100644
--- a/theta/test/theta_sketch_test.sql
+++ b/theta/test/theta_sketch_test.sql
@@ -18,40 +18,40 @@
  */
 
 # using defaults
-create or replace table `$BQ_DATASET`.theta_sketch(sketch bytes);
+create or replace temp table theta_sketch(sketch bytes);
 
-insert into `$BQ_DATASET`.theta_sketch
+insert into theta_sketch
 (select `$BQ_DATASET`.theta_sketch_agg_int64(value) from 
unnest(GENERATE_ARRAY(1, 10000, 1)) as value);
-insert into `$BQ_DATASET`.theta_sketch
+insert into theta_sketch
 (select `$BQ_DATASET`.theta_sketch_agg_int64(value) from 
unnest(GENERATE_ARRAY(100000, 110000, 1)) as value);
 
 # expected about 20000
 select `$BQ_DATASET`.theta_sketch_get_estimate_and_bounds(
   `$BQ_DATASET`.theta_sketch_agg_union(sketch),
   2
-) from `$BQ_DATASET`.theta_sketch;
+) from theta_sketch;
 
 # expected estimate about 20000
 select `$BQ_DATASET`.theta_sketch_to_string(
   `$BQ_DATASET`.theta_sketch_agg_union(sketch)
-) from `$BQ_DATASET`.theta_sketch;
+) from theta_sketch;
 
 select `$BQ_DATASET`.theta_sketch_get_theta(
   `$BQ_DATASET`.theta_sketch_agg_union(sketch)
-) from `$BQ_DATASET`.theta_sketch;
+) from theta_sketch;
 
 select `$BQ_DATASET`.theta_sketch_get_num_retained(
   `$BQ_DATASET`.theta_sketch_agg_union(sketch)
-) from `$BQ_DATASET`.theta_sketch;
+) from theta_sketch;
 
-drop table `$BQ_DATASET`.theta_sketch;
+drop table theta_sketch;
 
 # using full signatures
-create or replace table `$BQ_DATASET`.theta_sketch(sketch bytes);
+create or replace temp table theta_sketch(sketch bytes);
 
-insert into `$BQ_DATASET`.theta_sketch
+insert into theta_sketch
 (select `$BQ_DATASET`.theta_sketch_agg_int64_lgk_seed_p(value, struct<int, 
int, float64>(14, 111, 0.9)) from unnest(GENERATE_ARRAY(1, 10000, 1)) as value);
-insert into `$BQ_DATASET`.theta_sketch
+insert into theta_sketch
 (select `$BQ_DATASET`.theta_sketch_agg_int64_lgk_seed_p(value, struct<int, 
int, float64>(14, 111, 0.9)) from unnest(GENERATE_ARRAY(100000, 110000, 1)) as 
value);
 
 # expected about 20000
@@ -59,25 +59,25 @@ select 
`$BQ_DATASET`.theta_sketch_get_estimate_and_bounds_seed(
   `$BQ_DATASET`.theta_sketch_agg_union_lgk_seed(sketch, struct<int, int>(10, 
111)),
   2,
   111
-) from `$BQ_DATASET`.theta_sketch;
+) from theta_sketch;
 
 # expected estimate about 20000
 select `$BQ_DATASET`.theta_sketch_to_string_seed(
   `$BQ_DATASET`.theta_sketch_agg_union_lgk_seed(sketch, struct<int, int>(10, 
111)),
   111
-) from `$BQ_DATASET`.theta_sketch;
+) from theta_sketch;
 
 select `$BQ_DATASET`.theta_sketch_get_theta_seed(
   `$BQ_DATASET`.theta_sketch_agg_union_lgk_seed(sketch, struct<int, int>(10, 
111)),
   111
-) from `$BQ_DATASET`.theta_sketch;
+) from theta_sketch;
 
 select `$BQ_DATASET`.theta_sketch_get_num_retained_seed(
   `$BQ_DATASET`.theta_sketch_agg_union_lgk_seed(sketch, struct<int, int>(10, 
111)),
   111
-) from `$BQ_DATASET`.theta_sketch;
+) from theta_sketch;
 
-drop table `$BQ_DATASET`.theta_sketch;
+drop table theta_sketch;
 
 # using defaults
 # expected 5
diff --git a/theta/test/theta_sketch_test2.sql 
b/theta/test/theta_sketch_test2.sql
new file mode 100644
index 0000000..7084413
--- /dev/null
+++ b/theta/test/theta_sketch_test2.sql
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+create or replace table `$BQ_DATASET`.theta_sketches as
+select
+  hour,
+  `$BQ_DATASET`.theta_sketch_agg_int64(cast(rand() * 100000 as int64)) as 
sketch1,
+  `$BQ_DATASET`.theta_sketch_agg_int64(cast(rand() * 100000 as int64)) as 
sketch2,
+  `$BQ_DATASET`.theta_sketch_agg_int64(cast(rand() * 100000 as int64)) as 
sketch3,
+  `$BQ_DATASET`.theta_sketch_agg_int64(cast(rand() * 100000 as int64)) as 
sketch4,
+  `$BQ_DATASET`.theta_sketch_agg_int64(cast(rand() * 100000 as int64)) as 
sketch5,
+  `$BQ_DATASET`.theta_sketch_agg_int64(cast(rand() * 100000 as int64)) as 
sketch6,
+  `$BQ_DATASET`.theta_sketch_agg_int64(cast(rand() * 100000 as int64)) as 
sketch7,
+  `$BQ_DATASET`.theta_sketch_agg_int64(cast(rand() * 100000 as int64)) as 
sketch8
+#  `$BQ_DATASET`.theta_sketch_agg_int64(cast(rand() * 100000 as int64)) as 
sketch9,
+#  `$BQ_DATASET`.theta_sketch_agg_int64(cast(rand() * 100000 as int64)) as 
sketch10
+from unnest(generate_array(1,10)) as hour, unnest(generate_array(1,500000))
+group by hour;
+*/
+
+create or replace table `$BQ_DATASET`.theta_sketches as
+select
+  hour,
+  `$BQ_DATASET`.theta_sketch_agg_int64_nop(cast(rand() * 100000 as int64), 
struct<byteint, int64, float64>(null, null, null)) as sketch1,
+  `$BQ_DATASET`.theta_sketch_agg_int64_nop(cast(rand() * 100000 as int64), 
struct<byteint, int64, float64>(null, null, null)) as sketch2,
+  `$BQ_DATASET`.theta_sketch_agg_int64_nop(cast(rand() * 100000 as int64), 
struct<byteint, int64, float64>(null, null, null)) as sketch3,
+  `$BQ_DATASET`.theta_sketch_agg_int64_nop(cast(rand() * 100000 as int64), 
struct<byteint, int64, float64>(null, null, null)) as sketch4,
+  `$BQ_DATASET`.theta_sketch_agg_int64_nop(cast(rand() * 100000 as int64), 
struct<byteint, int64, float64>(null, null, null)) as sketch5,
+  `$BQ_DATASET`.theta_sketch_agg_int64_nop(cast(rand() * 100000 as int64), 
struct<byteint, int64, float64>(null, null, null)) as sketch6,
+  `$BQ_DATASET`.theta_sketch_agg_int64_nop(cast(rand() * 100000 as int64), 
struct<byteint, int64, float64>(null, null, null)) as sketch7,
+  `$BQ_DATASET`.theta_sketch_agg_int64_nop(cast(rand() * 100000 as int64), 
struct<byteint, int64, float64>(null, null, null)) as sketch8
+#  `$BQ_DATASET`.theta_sketch_agg_int64_nop(cast(rand() * 100000 as int64), 
struct<byteint, int64, float64>(null, null, null)) as sketch9,
+#  `$BQ_DATASET`.theta_sketch_agg_int64_nop(cast(rand() * 100000 as int64), 
struct<byteint, int64, float64>(null, null, null)) as sketch10
+from unnest(generate_array(1,10)) as hour, unnest(generate_array(1,500000))
+group by hour;
+
+#select hour, `$BQ_DATASET`.theta_sketch_get_estimate(sketch) from 
`$BQ_DATASET`.theta_sketches order by hour;
+/*
+select
+  
`$BQ_DATASET`.theta_sketch_get_estimate(`$BQ_DATASET`.theta_sketch_agg_union(sketch1)),
+  
`$BQ_DATASET`.theta_sketch_get_estimate(`$BQ_DATASET`.theta_sketch_agg_union(sketch2)),
+  
`$BQ_DATASET`.theta_sketch_get_estimate(`$BQ_DATASET`.theta_sketch_agg_union(sketch3)),
+  
`$BQ_DATASET`.theta_sketch_get_estimate(`$BQ_DATASET`.theta_sketch_agg_union(sketch4)),
+  
`$BQ_DATASET`.theta_sketch_get_estimate(`$BQ_DATASET`.theta_sketch_agg_union(sketch5)),
+  
`$BQ_DATASET`.theta_sketch_get_estimate(`$BQ_DATASET`.theta_sketch_agg_union(sketch6))
+from `$BQ_DATASET`.theta_sketches;
+*/
diff --git a/fi/test/frequent_strings_sketch_test.sql 
b/tuple/test/tuple_sketch_int64_issue_124.sql
similarity index 53%
copy from fi/test/frequent_strings_sketch_test.sql
copy to tuple/test/tuple_sketch_int64_issue_124.sql
index a7634f1..2a0400d 100644
--- a/fi/test/frequent_strings_sketch_test.sql
+++ b/tuple/test/tuple_sketch_int64_issue_124.sql
@@ -17,16 +17,6 @@
  * under the License.
  */
 
-select 
`$BQ_DATASET`.frequent_strings_sketch_to_string(`$BQ_DATASET`.frequent_strings_sketch_build(str,
 1, 5)) from unnest(["a", "b", "c"]) as str;
-
-create or replace table `$BQ_DATASET`.fs_sketch(sketch bytes);
-
-insert into `$BQ_DATASET`.fs_sketch
-(select `$BQ_DATASET`.frequent_strings_sketch_build(str, 1, 5) from 
unnest(["a", "b", "c", "d"]) as str);
-
-insert into `$BQ_DATASET`.fs_sketch
-(select `$BQ_DATASET`.frequent_strings_sketch_build(str, 1, 5) from 
unnest(["a", "a", "c"]) as str);
-
-select 
`$BQ_DATASET`.frequent_strings_sketch_get_result(`$BQ_DATASET`.frequent_strings_sketch_merge(sketch,
 5), "NO_FALSE_NEGATIVES", null) from `$BQ_DATASET`.fs_sketch;
-
-drop table `$BQ_DATASET`.fs_sketch;
+# issue #124
+select 
`$BQ_DATASET`.tuple_sketch_int64_to_string(`$BQ_DATASET`.tuple_sketch_int64_agg_int64(key,
 1)) from UNNEST(GENERATE_ARRAY(1, 1000000)) as key;
+#select `$BQ_DATASET`.tuple_sketch_int64_agg_int64(key, 1) from 
UNNEST(GENERATE_ARRAY(1, 1000000)) as key;
diff --git a/tuple/test/tuple_sketch_int64_test.sql 
b/tuple/test/tuple_sketch_int64_test.sql
index 70b9f59..43ef0bd 100644
--- a/tuple/test/tuple_sketch_int64_test.sql
+++ b/tuple/test/tuple_sketch_int64_test.sql
@@ -18,53 +18,53 @@
  */
 
 # using defaults
-create or replace table `$BQ_DATASET`.tuple_sketch(sketch bytes);
+create or replace temp table tuple_sketch(sketch bytes);
 
-insert into `$BQ_DATASET`.tuple_sketch
+insert into tuple_sketch
 (select 
`$BQ_DATASET`.tuple_sketch_int64_from_theta_sketch(`$BQ_DATASET`.theta_sketch_agg_string(cast(value
 as string)), 1) from unnest(GENERATE_ARRAY(1, 10000, 1)) as value);
-insert into `$BQ_DATASET`.tuple_sketch
+insert into tuple_sketch
 (select 
`$BQ_DATASET`.tuple_sketch_int64_from_theta_sketch(`$BQ_DATASET`.theta_sketch_agg_string(cast(value
 as string)), 1) from unnest(GENERATE_ARRAY(100000, 110000, 1)) as value);
 
 # expected about 20000
 select `$BQ_DATASET`.tuple_sketch_int64_get_estimate(
   `$BQ_DATASET`.tuple_sketch_int64_agg_union(sketch)
-) from `$BQ_DATASET`.tuple_sketch;
+) from tuple_sketch;
 
 select `$BQ_DATASET`.tuple_sketch_int64_get_estimate_and_bounds(
   `$BQ_DATASET`.tuple_sketch_int64_agg_union(sketch),
   2
-) from `$BQ_DATASET`.tuple_sketch;
+) from tuple_sketch;
 
 select `$BQ_DATASET`.tuple_sketch_int64_get_sum_estimate_and_bounds(
   `$BQ_DATASET`.tuple_sketch_int64_agg_union(sketch),
   2
-) from `$BQ_DATASET`.tuple_sketch;
+) from tuple_sketch;
 
 # expected estimate about 20000
 select `$BQ_DATASET`.tuple_sketch_int64_to_string(
   `$BQ_DATASET`.tuple_sketch_int64_agg_union(sketch)
-) from `$BQ_DATASET`.tuple_sketch;
+) from tuple_sketch;
 
 select `$BQ_DATASET`.tuple_sketch_int64_get_theta(
   `$BQ_DATASET`.tuple_sketch_int64_agg_union(sketch)
-) from `$BQ_DATASET`.tuple_sketch;
+) from tuple_sketch;
 
 select `$BQ_DATASET`.tuple_sketch_int64_get_num_retained(
   `$BQ_DATASET`.tuple_sketch_int64_agg_union(sketch)
-) from `$BQ_DATASET`.tuple_sketch;
+) from tuple_sketch;
 
-drop table `$BQ_DATASET`.tuple_sketch;
+drop table tuple_sketch;
 
 # using full signatures
-create or replace table `$BQ_DATASET`.tuple_sketch(sketch bytes);
+create or replace temp table tuple_sketch(sketch bytes);
 
-insert into `$BQ_DATASET`.tuple_sketch
+insert into tuple_sketch
 (select `$BQ_DATASET`.tuple_sketch_int64_from_theta_sketch_seed(
   `$BQ_DATASET`.theta_sketch_agg_string_lgk_seed_p(cast(value as string), 
STRUCT<BYTEINT, INT64, FLOAT64>(10, 111, 0.999)),
   1,
   111
 ) from unnest(GENERATE_ARRAY(1, 10000, 1)) as value);
-insert into `$BQ_DATASET`.tuple_sketch
+insert into tuple_sketch
 (select `$BQ_DATASET`.tuple_sketch_int64_from_theta_sketch_seed(
   `$BQ_DATASET`.theta_sketch_agg_string_lgk_seed_p(cast(value as string), 
STRUCT<BYTEINT, INT64, FLOAT64>(10, 111, 0.999)),
   1,
@@ -75,38 +75,37 @@ insert into `$BQ_DATASET`.tuple_sketch
 select `$BQ_DATASET`.tuple_sketch_int64_get_estimate_seed(
   `$BQ_DATASET`.tuple_sketch_int64_agg_union_lgk_seed_mode(sketch, 
STRUCT<BYTEINT, INT64, STRING>(10, 111, "NOP")),
   111
-) from `$BQ_DATASET`.tuple_sketch;
+) from tuple_sketch;
 
 select `$BQ_DATASET`.tuple_sketch_int64_get_estimate_and_bounds_seed(
   `$BQ_DATASET`.tuple_sketch_int64_agg_union_lgk_seed_mode(sketch, 
STRUCT<BYTEINT, INT64, STRING>(10, 111, "NOP")),
   2,
   111
-) from `$BQ_DATASET`.tuple_sketch;
+) from tuple_sketch;
 
 select `$BQ_DATASET`.tuple_sketch_int64_get_sum_estimate_and_bounds_seed(
   `$BQ_DATASET`.tuple_sketch_int64_agg_union_lgk_seed_mode(sketch, 
STRUCT<BYTEINT, INT64, STRING>(10, 111, "NOP")),
   2,
   111
-) from `$BQ_DATASET`.tuple_sketch;
+) from tuple_sketch;
 
 # expected estimate about 20000
 select `$BQ_DATASET`.tuple_sketch_int64_to_string_seed(
   `$BQ_DATASET`.tuple_sketch_int64_agg_union_lgk_seed_mode(sketch, 
STRUCT<BYTEINT, INT64, STRING>(10, 111, "NOP")),
   111
-) from `$BQ_DATASET`.tuple_sketch;
+) from tuple_sketch;
 
 select `$BQ_DATASET`.tuple_sketch_int64_get_theta_seed(
   `$BQ_DATASET`.tuple_sketch_int64_agg_union_lgk_seed_mode(sketch, 
STRUCT<BYTEINT, INT64, STRING>(10, 111, "NOP")),
   111
-) from `$BQ_DATASET`.tuple_sketch;
+) from tuple_sketch;
 
 select `$BQ_DATASET`.tuple_sketch_int64_get_num_retained_seed(
   `$BQ_DATASET`.tuple_sketch_int64_agg_union_lgk_seed_mode(sketch, 
STRUCT<BYTEINT, INT64, STRING>(10, 111, "NOP")),
   111
-) from `$BQ_DATASET`.tuple_sketch;
-
-drop table `$BQ_DATASET`.tuple_sketch;
+) from tuple_sketch;
 
+drop table tuple_sketch;
 
 # using defaults
 # expected 5


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

Reply via email to