diff --git a/bigframes/testing/compiler_session.py b/bigframes/testing/compiler_session.py index b248f37cfc..f2992babc4 100644 --- a/bigframes/testing/compiler_session.py +++ b/bigframes/testing/compiler_session.py @@ -17,6 +17,7 @@ import bigframes.core import bigframes.core.compile as compile +from bigframes.core.compile.ibis_compiler import ibis_compiler import bigframes.session.executor @@ -24,8 +25,6 @@ class SQLCompilerExecutor(bigframes.session.executor.Executor): """Executor for SQL compilation using sqlglot.""" - compiler = compile.sqlglot - def to_sql( self, array_value: bigframes.core.ArrayValue, @@ -38,9 +37,9 @@ def to_sql( # Compared with BigQueryCachingExecutor, SQLCompilerExecutor skips # caching the subtree. - return self.compiler.compile_sql( - compile.CompileRequest(array_value.node, sort_rows=ordered) - ).sql + request = compile.CompileRequest(array_value.node, sort_rows=ordered) + compiled = ibis_compiler.compile_sql(request) + return compiled.sql def execute( self, diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_binary_compiler/test_corr/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_binary_compiler/test_corr/out.sql index 5c838f4882..c6ec7dea4a 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_binary_compiler/test_corr/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_binary_compiler/test_corr/out.sql @@ -1,13 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - CORR(`int64_col`, `float64_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `corr_col` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + CORR(`t1`.`int64_col`, `t1`.`float64_col`) AS `corr_col` + FROM ( + SELECT + `t0`.`int64_col`, + `t0`.`float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_binary_compiler/test_cov/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_binary_compiler/test_cov/out.sql index eda082250a..c6b20e09b5 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_binary_compiler/test_cov/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_binary_compiler/test_cov/out.sql @@ -1,13 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - COVAR_SAMP(`int64_col`, `float64_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `cov_col` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + COVAR_SAMP(`t1`.`int64_col`, `t1`.`float64_col`) AS `cov_col` + FROM ( + SELECT + `t0`.`int64_col`, + `t0`.`float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_row_number/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_row_number/out.sql index 78cc44fa54..e925055fda 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_row_number/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_row_number/out.sql @@ -1,27 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `bytes_col`, - `date_col`, - `datetime_col`, - `duration_col`, - `float64_col`, - `geography_col`, - `int64_col`, - `int64_too`, - `numeric_col`, - `rowindex`, - `rowindex_2`, - `string_col`, - `time_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ROW_NUMBER() OVER () AS `bfcol_32` - FROM `bfcte_0` -) SELECT - `bfcol_32` AS `row_number` -FROM `bfcte_1` \ No newline at end of file + ROW_NUMBER() OVER (ORDER BY NULL ASC) - 1 AS `row_number` +FROM ( + SELECT + * + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_row_number_with_window/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_row_number_with_window/out.sql index b63cb1ff61..6bf2bb14d1 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_row_number_with_window/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_row_number_with_window/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ROW_NUMBER() OVER (ORDER BY `int64_col` ASC NULLS LAST) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `row_number` -FROM `bfcte_1` \ No newline at end of file + ROW_NUMBER() OVER (ORDER BY `t1`.`int64_col` IS NULL ASC, `t1`.`int64_col` ASC) - 1 AS `row_number` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_size/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_size/out.sql index ed8e0c7619..36226c9f80 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_size/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_size/out.sql @@ -1,26 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `bytes_col`, - `date_col`, - `datetime_col`, - `duration_col`, - `float64_col`, - `geography_col`, - `int64_col`, - `int64_too`, - `numeric_col`, - `rowindex`, - `rowindex_2`, - `string_col`, - `time_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - COUNT(1) AS `bfcol_32` - FROM `bfcte_0` -) SELECT - `bfcol_32` AS `size` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + COUNT(1) AS `size` + FROM ( + SELECT + `t0`.`rowindex` AS `bfuid_col_1` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_array_agg/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_array_agg/out.sql index eafbc39daf..835e8c02a4 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_array_agg/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_array_agg/out.sql @@ -1,12 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - ARRAY_AGG(`int64_col` IGNORE NULLS ORDER BY `int64_col` IS NULL ASC, `int64_col` ASC) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + ARRAY_AGG( + `t1`.`int64_col` IGNORE NULLS ORDER BY (`t1`.`int64_col` IS NULL) ASC, (`t1`.`int64_col`) ASC + ) AS `int64_col` + FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_string_agg/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_string_agg/out.sql index 321341d4a0..8d1ea80b61 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_string_agg/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_string_agg/out.sql @@ -1,18 +1,17 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( +SELECT + * +FROM ( SELECT COALESCE( - STRING_AGG(`string_col`, ',' - ORDER BY - `string_col` IS NULL ASC, - `string_col` ASC), + string_agg( + `t1`.`string_col` ORDER BY (`t1`.`string_col` IS NULL) ASC, (`t1`.`string_col`) ASC, + ',' + ), '' - ) AS `bfcol_1` - FROM `bfcte_0` -) -SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + ) AS `string_col` + FROM ( + SELECT + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/out.sql index d31b21f56b..6de7195142 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/out.sql @@ -1,12 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - COALESCE(LOGICAL_AND(`bool_col`), TRUE) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `bool_col` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + COALESCE(LOGICAL_AND(`t1`.`bool_col`), TRUE) AS `bool_col` + FROM ( + SELECT + `t0`.`bool_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/window_out.sql index 83bd288e73..1147f2d2b0 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/window_out.sql @@ -1,17 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `bool_col` IS NULL - THEN NULL - ELSE COALESCE(LOGICAL_AND(`bool_col`) OVER (), TRUE) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_bool` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`bool_col` IS NULL + THEN NULL + WHEN TRUE + THEN COALESCE(LOGICAL_AND(`t1`.`bool_col`) OVER (), TRUE) + ELSE CAST(NULL AS BOOL) + END AS `agg_bool` +FROM ( + SELECT + `t0`.`bool_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/window_partition_out.sql index dc2471148b..46cd1d8b4d 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/window_partition_out.sql @@ -1,18 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `bool_col` IS NULL - THEN NULL - ELSE COALESCE(LOGICAL_AND(`bool_col`) OVER (PARTITION BY `string_col`), TRUE) - END AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_bool` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`bool_col` IS NULL + THEN NULL + WHEN TRUE + THEN COALESCE(LOGICAL_AND(`t1`.`bool_col`) OVER (PARTITION BY `t1`.`string_col`), TRUE) + ELSE CAST(NULL AS BOOL) + END AS `agg_bool` +FROM ( + SELECT + `t0`.`bool_col`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/out.sql index 4a13901f1c..5227df46f6 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/out.sql @@ -1,12 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - ANY_VALUE(`int64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + ANY_VALUE(`t1`.`int64_col`) AS `int64_col` + FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_out.sql index f179808b57..e76cbefcf7 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_out.sql @@ -1,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `int64_col` IS NULL THEN NULL ELSE ANY_VALUE(`int64_col`) OVER () END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN ANY_VALUE(`t1`.`int64_col`) OVER () + ELSE CAST(NULL AS INT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_partition_out.sql index e1b3da8a9a..af0875c70a 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_partition_out.sql @@ -1,18 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `int64_col` IS NULL - THEN NULL - ELSE ANY_VALUE(`int64_col`) OVER (PARTITION BY `string_col`) - END AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN ANY_VALUE(`t1`.`int64_col`) OVER (PARTITION BY `t1`.`string_col`) + ELSE CAST(NULL AS INT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_approx_quartiles/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_approx_quartiles/out.sql index 9eabb2d88a..24b4d1963d 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_approx_quartiles/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_approx_quartiles/out.sql @@ -1,16 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - APPROX_QUANTILES(`int64_col`, 4)[OFFSET(1)] AS `bfcol_1`, - APPROX_QUANTILES(`int64_col`, 4)[OFFSET(2)] AS `bfcol_2`, - APPROX_QUANTILES(`int64_col`, 4)[OFFSET(3)] AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `q1`, - `bfcol_2` AS `q2`, - `bfcol_3` AS `q3` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + APPROX_QUANTILES(`t1`.`int64_col`, 4)[safe_offset(1)] AS `q1`, + APPROX_QUANTILES(`t1`.`int64_col`, 4)[safe_offset(2)] AS `q2`, + APPROX_QUANTILES(`t1`.`int64_col`, 4)[safe_offset(3)] AS `q3` + FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_approx_top_count/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_approx_top_count/out.sql index b5e6275381..44837de428 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_approx_top_count/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_approx_top_count/out.sql @@ -1,12 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - APPROX_TOP_COUNT(`int64_col`, 10) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + approx_top_count(`t1`.`int64_col`, 10) AS `int64_col` + FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/out.sql index 9d18367cf6..9fb0366d6d 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/out.sql @@ -1,12 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - COUNT(`int64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + COUNT(`t1`.`int64_col`) AS `int64_col` + FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_out.sql index 0baac95311..03b1bd0446 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COUNT(`int64_col`) OVER () AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + COUNT(`t1`.`int64_col`) OVER () AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_partition_out.sql index 6d3f856459..f1be9df813 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_partition_out.sql @@ -1,14 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COUNT(`int64_col`) OVER (PARTITION BY `string_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + COUNT(`t1`.`int64_col`) OVER (PARTITION BY `t1`.`string_col`) AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_date_series_diff/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_date_series_diff/out.sql index 84c95fd010..dc16186475 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_date_series_diff/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_date_series_diff/out.sql @@ -1,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(DATE_DIFF(`date_col`, LAG(`date_col`, 1) OVER (ORDER BY `date_col` ASC NULLS LAST), DAY) * 86400000000 AS INT64) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `diff_date` -FROM `bfcte_1` \ No newline at end of file + CAST(FLOOR( + DATE_DIFF( + `t1`.`date_col`, + LAG(`t1`.`date_col`, 1) OVER (ORDER BY `t1`.`date_col` IS NULL ASC, `t1`.`date_col` ASC), + DAY + ) * 86400000000 + ) AS INT64) AS `diff_date` +FROM ( + SELECT + `t0`.`date_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff/diff_bool.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff/diff_bool.sql index 96d23c4747..9abc599159 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff/diff_bool.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff/diff_bool.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bool_col` <> LAG(`bool_col`, 1) OVER (ORDER BY `bool_col` DESC) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `diff_bool` -FROM `bfcte_1` \ No newline at end of file + `t1`.`bool_col` <> LAG(`t1`.`bool_col`, 1) OVER (ORDER BY `t1`.`bool_col` DESC) AS `diff_bool` +FROM ( + SELECT + `t0`.`bool_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff/diff_int.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff/diff_int.sql index 95d786b951..741d457b77 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff/diff_int.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff/diff_int.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `int64_col` - LAG(`int64_col`, 1) OVER (ORDER BY `int64_col` ASC NULLS LAST) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `diff_int` -FROM `bfcte_1` \ No newline at end of file + `t1`.`int64_col` - LAG(`t1`.`int64_col`, 1) OVER (ORDER BY `t1`.`int64_col` IS NULL ASC, `t1`.`int64_col` ASC) AS `diff_int` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first/out.sql index 40c9e6ddd8..695f1c3fb6 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first/out.sql @@ -1,20 +1,16 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `int64_col` IS NULL - THEN NULL - ELSE FIRST_VALUE(`int64_col`) OVER ( - ORDER BY `int64_col` DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN FIRST_VALUE(`t1`.`int64_col`) OVER ( + ORDER BY `t1`.`int64_col` DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) + ELSE CAST(NULL AS INT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first_non_null/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first_non_null/out.sql index 2ef7b7151e..c5fd28c441 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first_non_null/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first_non_null/out.sql @@ -1,16 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FIRST_VALUE(`int64_col` IGNORE NULLS) OVER ( - ORDER BY `int64_col` ASC NULLS LAST - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + FIRST_VALUE(`t1`.`int64_col` IGNORE NULLS) OVER ( + ORDER BY `t1`.`int64_col` IS NULL ASC, `t1`.`int64_col` ASC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last/out.sql index ebeaa0e338..53f70070b9 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last/out.sql @@ -1,20 +1,16 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `int64_col` IS NULL - THEN NULL - ELSE LAST_VALUE(`int64_col`) OVER ( - ORDER BY `int64_col` DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN LAST_VALUE(`t1`.`int64_col`) OVER ( + ORDER BY `t1`.`int64_col` DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) + ELSE CAST(NULL AS INT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last_non_null/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last_non_null/out.sql index c626c263ac..72ce0f89e0 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last_non_null/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last_non_null/out.sql @@ -1,16 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LAST_VALUE(`int64_col` IGNORE NULLS) OVER ( - ORDER BY `int64_col` ASC NULLS LAST - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + LAST_VALUE(`t1`.`int64_col` IGNORE NULLS) OVER ( + ORDER BY `t1`.`int64_col` IS NULL ASC, `t1`.`int64_col` ASC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/out.sql index 1537d735ea..46f960c1a2 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/out.sql @@ -1,12 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - MAX(`int64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + MAX(`t1`.`int64_col`) AS `int64_col` + FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_out.sql index a234601b6a..46e9117bdd 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_out.sql @@ -1,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `int64_col` IS NULL THEN NULL ELSE MAX(`int64_col`) OVER () END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN MAX(`t1`.`int64_col`) OVER () + ELSE CAST(NULL AS INT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_partition_out.sql index f918500788..f7e3575615 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_partition_out.sql @@ -1,18 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `int64_col` IS NULL - THEN NULL - ELSE MAX(`int64_col`) OVER (PARTITION BY `string_col`) - END AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN MAX(`t1`.`int64_col`) OVER (PARTITION BY `t1`.`string_col`) + ELSE CAST(NULL AS INT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/out.sql index 0b33d0b1d0..8382d34c21 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/out.sql @@ -1,27 +1,16 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `duration_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `int64_col` AS `bfcol_6`, - `bool_col` AS `bfcol_7`, - `duration_col` AS `bfcol_8` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - AVG(`bfcol_6`) AS `bfcol_12`, - AVG(CAST(`bfcol_7` AS INT64)) AS `bfcol_13`, - CAST(FLOOR(AVG(`bfcol_8`)) AS INT64) AS `bfcol_14`, - CAST(FLOOR(AVG(`bfcol_6`)) AS INT64) AS `bfcol_15` - FROM `bfcte_1` -) SELECT - `bfcol_12` AS `int64_col`, - `bfcol_13` AS `bool_col`, - `bfcol_14` AS `duration_col`, - `bfcol_15` AS `int64_col_w_floor` -FROM `bfcte_2` \ No newline at end of file + * +FROM ( + SELECT + AVG(`t1`.`bfuid_col_4`) AS `int64_col`, + AVG(CAST(`t1`.`bfuid_col_5` AS INT64)) AS `bool_col`, + CAST(FLOOR(AVG(`t1`.`bfuid_col_6`)) AS INT64) AS `duration_col`, + CAST(FLOOR(AVG(`t1`.`bfuid_col_4`)) AS INT64) AS `int64_col_w_floor` + FROM ( + SELECT + `t0`.`int64_col` AS `bfuid_col_4`, + `t0`.`bool_col` AS `bfuid_col_5`, + CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64) AS `bfuid_col_6` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_out.sql index 73bec9ccce..088c3b6a85 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_out.sql @@ -1,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `int64_col` IS NULL THEN NULL ELSE AVG(`int64_col`) OVER () END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN AVG(`t1`.`int64_col`) OVER () + ELSE CAST(NULL AS FLOAT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_partition_out.sql index d0a8345e12..21f36da90e 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_partition_out.sql @@ -1,18 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `int64_col` IS NULL - THEN NULL - ELSE AVG(`int64_col`) OVER (PARTITION BY `string_col`) - END AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN AVG(`t1`.`int64_col`) OVER (PARTITION BY `t1`.`string_col`) + ELSE CAST(NULL AS FLOAT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_median/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_median/out.sql index bfe94622b3..585af3e1cc 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_median/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_median/out.sql @@ -1,18 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - APPROX_QUANTILES(`int64_col`, 2)[OFFSET(1)] AS `bfcol_3`, - APPROX_QUANTILES(`date_col`, 2)[OFFSET(1)] AS `bfcol_4`, - APPROX_QUANTILES(`string_col`, 2)[OFFSET(1)] AS `bfcol_5` - FROM `bfcte_0` -) SELECT - `bfcol_3` AS `int64_col`, - `bfcol_4` AS `date_col`, - `bfcol_5` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + APPROX_QUANTILES(`t1`.`int64_col`, 2)[offset(1)] AS `int64_col`, + APPROX_QUANTILES(`t1`.`date_col`, 2)[offset(1)] AS `date_col`, + APPROX_QUANTILES(`t1`.`string_col`, 2)[offset(1)] AS `string_col` + FROM ( + SELECT + `t0`.`date_col`, + `t0`.`int64_col`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/out.sql index 0848313456..0339b0b289 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/out.sql @@ -1,12 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - MIN(`int64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + MIN(`t1`.`int64_col`) AS `int64_col` + FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_out.sql index 1d9db63491..f2beed5d3a 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_out.sql @@ -1,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `int64_col` IS NULL THEN NULL ELSE MIN(`int64_col`) OVER () END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN MIN(`t1`.`int64_col`) OVER () + ELSE CAST(NULL AS INT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_partition_out.sql index 8040f43ca5..89b7c2e2a9 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_partition_out.sql @@ -1,18 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `int64_col` IS NULL - THEN NULL - ELSE MIN(`int64_col`) OVER (PARTITION BY `string_col`) - END AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN MIN(`t1`.`int64_col`) OVER (PARTITION BY `t1`.`string_col`) + ELSE CAST(NULL AS INT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/out.sql index 2d38311f45..97a9b4cbe2 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/out.sql @@ -1,15 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - VAR_POP(`int64_col`) AS `bfcol_4`, - VAR_POP(CAST(`bool_col` AS INT64)) AS `bfcol_5` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `int64_col`, - `bfcol_5` AS `bool_col` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + VAR_POP(`t1`.`int64_col`) AS `int64_col`, + VAR_POP(CAST(`t1`.`bool_col` AS INT64)) AS `bool_col` + FROM ( + SELECT + `t0`.`int64_col`, + `t0`.`bool_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/window_out.sql index eae3db0048..5f29126198 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/window_out.sql @@ -1,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `int64_col` IS NULL THEN NULL ELSE VAR_POP(`int64_col`) OVER () END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN VAR_POP(`t1`.`int64_col`) OVER () + ELSE CAST(NULL AS FLOAT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_quantile/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_quantile/out.sql index b79d8d381f..8e6c10622c 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_quantile/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_quantile/out.sql @@ -1,14 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - PERCENTILE_CONT(`int64_col`, 0.5) OVER () AS `bfcol_1`, - CAST(FLOOR(PERCENTILE_CONT(`int64_col`, 0.5) OVER ()) AS INT64) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `quantile`, - `bfcol_2` AS `quantile_floor` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + PERCENTILE_CONT(`t1`.`int64_col`, 0.5) AS `quantile`, + CAST(FLOOR(PERCENTILE_CONT(`t1`.`int64_col`, 0.5)) AS INT64) AS `quantile_floor` + FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_rank/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_rank/out.sql index 96b121bde4..c2e9e78aa0 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_rank/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_rank/out.sql @@ -1,13 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - RANK() OVER (ORDER BY `int64_col` DESC NULLS FIRST) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + ( + RANK() OVER (ORDER BY `t1`.`int64_col` IS NULL DESC, `t1`.`int64_col` DESC) - 1 + ) + 1 AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lag.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lag.sql index 7d1d62f1ae..29f1612d4a 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lag.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lag.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LAG(`int64_col`, 1) OVER (ORDER BY `int64_col` ASC) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `lag` -FROM `bfcte_1` \ No newline at end of file + LAG(`t1`.`int64_col`, 1) OVER (ORDER BY `t1`.`int64_col` ASC) AS `lag` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lead.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lead.sql index 67b40c99db..99903eddfb 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lead.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lead.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LEAD(`int64_col`, 1) OVER (ORDER BY `int64_col` ASC) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `lead` -FROM `bfcte_1` \ No newline at end of file + LEAD(`t1`.`int64_col`, 1) OVER (ORDER BY `t1`.`int64_col` ASC) AS `lead` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/noop.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/noop.sql index 0202cf5c21..e1d9a985e6 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/noop.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/noop.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `int64_col` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `noop` -FROM `bfcte_1` \ No newline at end of file + `t0`.`int64_col` AS `noop` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql index 36a50302a6..7b8cc2bf1e 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql @@ -1,27 +1,16 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `duration_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `int64_col` AS `bfcol_6`, - `bool_col` AS `bfcol_7`, - `duration_col` AS `bfcol_8` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - STDDEV(`bfcol_6`) AS `bfcol_12`, - STDDEV(CAST(`bfcol_7` AS INT64)) AS `bfcol_13`, - CAST(FLOOR(STDDEV(`bfcol_8`)) AS INT64) AS `bfcol_14`, - CAST(FLOOR(STDDEV(`bfcol_6`)) AS INT64) AS `bfcol_15` - FROM `bfcte_1` -) SELECT - `bfcol_12` AS `int64_col`, - `bfcol_13` AS `bool_col`, - `bfcol_14` AS `duration_col`, - `bfcol_15` AS `int64_col_w_floor` -FROM `bfcte_2` \ No newline at end of file + * +FROM ( + SELECT + STDDEV_SAMP(`t1`.`bfuid_col_10`) AS `int64_col`, + STDDEV_SAMP(CAST(`t1`.`bfuid_col_11` AS INT64)) AS `bool_col`, + CAST(FLOOR(STDDEV_SAMP(`t1`.`bfuid_col_12`)) AS INT64) AS `duration_col`, + CAST(FLOOR(STDDEV_SAMP(`t1`.`bfuid_col_10`)) AS INT64) AS `int64_col_w_floor` + FROM ( + SELECT + `t0`.`int64_col` AS `bfuid_col_10`, + `t0`.`bool_col` AS `bfuid_col_11`, + CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64) AS `bfuid_col_12` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/window_out.sql index cb39f6dbc8..a392d02a11 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/window_out.sql @@ -1,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `int64_col` IS NULL THEN NULL ELSE STDDEV(`int64_col`) OVER () END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN STDDEV_SAMP(`t1`.`int64_col`) OVER () + ELSE CAST(NULL AS FLOAT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/out.sql index 2bf6c26cd4..2126c5751b 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/out.sql @@ -1,15 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - COALESCE(SUM(`int64_col`), 0) AS `bfcol_4`, - COALESCE(SUM(CAST(`bool_col` AS INT64)), 0) AS `bfcol_5` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `int64_col`, - `bfcol_5` AS `bool_col` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + COALESCE(SUM(`t1`.`int64_col`), 0) AS `int64_col`, + COALESCE(SUM(CAST(`t1`.`bool_col` AS INT64)), 0) AS `bool_col` + FROM ( + SELECT + `t0`.`int64_col`, + `t0`.`bool_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_out.sql index 401436019e..79a90b3187 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_out.sql @@ -1,17 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `int64_col` IS NULL - THEN NULL - ELSE COALESCE(SUM(`int64_col`) OVER (), 0) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN COALESCE(SUM(`t1`.`int64_col`) OVER (), 0) + ELSE CAST(NULL AS INT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_partition_out.sql index f8ada8a5d4..3cfa27b77b 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_partition_out.sql @@ -1,18 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `int64_col` IS NULL - THEN NULL - ELSE COALESCE(SUM(`int64_col`) OVER (PARTITION BY `string_col`), 0) - END AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN COALESCE(SUM(`t1`.`int64_col`) OVER (PARTITION BY `t1`.`string_col`), 0) + ELSE CAST(NULL AS INT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_time_series_diff/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_time_series_diff/out.sql index 645f583dc1..2500e73f48 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_time_series_diff/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_time_series_diff/out.sql @@ -1,17 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIMESTAMP_DIFF( - `timestamp_col`, - LAG(`timestamp_col`, 1) OVER (ORDER BY `timestamp_col` ASC NULLS LAST), - MICROSECOND - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `diff_time` -FROM `bfcte_1` \ No newline at end of file + TIMESTAMP_DIFF( + `t1`.`timestamp_col`, + LAG(`t1`.`timestamp_col`, 1) OVER (ORDER BY `t1`.`timestamp_col` IS NULL ASC, `t1`.`timestamp_col` ASC), + MICROSECOND + ) AS `diff_time` +FROM ( + SELECT + `t0`.`timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/out.sql index 733a22438c..06070473be 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/out.sql @@ -1,15 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - VARIANCE(`int64_col`) AS `bfcol_4`, - VARIANCE(CAST(`bool_col` AS INT64)) AS `bfcol_5` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `int64_col`, - `bfcol_5` AS `bool_col` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + VARIANCE(`t1`.`int64_col`) AS `int64_col`, + VARIANCE(CAST(`t1`.`bool_col` AS INT64)) AS `bool_col` + FROM ( + SELECT + `t0`.`int64_col`, + `t0`.`bool_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/window_out.sql index d300251447..ae66278944 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/window_out.sql @@ -1,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `int64_col` IS NULL THEN NULL ELSE VARIANCE(`int64_col`) OVER () END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `t1`.`int64_col` IS NULL + THEN NULL + WHEN TRUE + THEN VARIANCE(`t1`.`int64_col`) OVER () + ELSE CAST(NULL AS FLOAT64) + END AS `agg_int64` +FROM ( + SELECT + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_classify/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_classify/out.sql index a40784a3ca..1629f9193b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_classify/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_classify/out.sql @@ -1,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.CLASSIFY( - input => (`string_col`), - categories => ['greeting', 'rejection'], - connection_id => 'bigframes-dev.us.bigframes-default-connection' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.CLASSIFY( + input => STRUCT(`t0`.`string_col` AS `_field_1`), + categories => ['greeting', 'rejection'], + connection_id => 'bigframes-dev.us.bigframes-default-connection' + ) AS `result` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate/out.sql index 19f85b181b..db3f90c409 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate/out.sql @@ -1,18 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection', - endpoint => 'gemini-2.5-flash', - request_type => 'SHARED' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE( + prompt => STRUCT( + `t0`.`string_col` AS `_field_1`, + ' is the same as ' AS `_field_2`, + `t0`.`string_col` AS `_field_3` + ), + connection_id => 'bigframes-dev.us.bigframes-default-connection', + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool/out.sql index f844ed1691..87359caf2e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool/out.sql @@ -1,18 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_BOOL( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection', - endpoint => 'gemini-2.5-flash', - request_type => 'SHARED' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE_BOOL( + prompt => STRUCT( + `t0`.`string_col` AS `_field_1`, + ' is the same as ' AS `_field_2`, + `t0`.`string_col` AS `_field_3` + ), + connection_id => 'bigframes-dev.us.bigframes-default-connection', + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool_with_model_param/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool_with_model_param/out.sql index 35538c2ec2..28cfa8292a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool_with_model_param/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool_with_model_param/out.sql @@ -1,18 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_BOOL( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection', - request_type => 'SHARED', - model_params => JSON '{}' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE_BOOL( + prompt => STRUCT( + `t0`.`string_col` AS `_field_1`, + ' is the same as ' AS `_field_2`, + `t0`.`string_col` AS `_field_3` + ), + connection_id => 'bigframes-dev.us.bigframes-default-connection', + request_type => 'SHARED', + model_params => JSON '{}' + ) AS `result` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double/out.sql index fae92515cb..c6e407a56b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double/out.sql @@ -1,18 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_DOUBLE( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection', - endpoint => 'gemini-2.5-flash', - request_type => 'SHARED' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE_DOUBLE( + prompt => STRUCT( + `t0`.`string_col` AS `_field_1`, + ' is the same as ' AS `_field_2`, + `t0`.`string_col` AS `_field_3` + ), + connection_id => 'bigframes-dev.us.bigframes-default-connection', + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double_with_model_param/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double_with_model_param/out.sql index f3ddf71014..9809e8f372 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double_with_model_param/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double_with_model_param/out.sql @@ -1,18 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_DOUBLE( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection', - request_type => 'SHARED', - model_params => JSON '{}' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE_DOUBLE( + prompt => STRUCT( + `t0`.`string_col` AS `_field_1`, + ' is the same as ' AS `_field_2`, + `t0`.`string_col` AS `_field_3` + ), + connection_id => 'bigframes-dev.us.bigframes-default-connection', + request_type => 'SHARED', + model_params => JSON '{}' + ) AS `result` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int/out.sql index a0c92c959c..04a1c83ea2 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int/out.sql @@ -1,18 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_INT( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection', - endpoint => 'gemini-2.5-flash', - request_type => 'SHARED' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE_INT( + prompt => STRUCT( + `t0`.`string_col` AS `_field_1`, + ' is the same as ' AS `_field_2`, + `t0`.`string_col` AS `_field_3` + ), + connection_id => 'bigframes-dev.us.bigframes-default-connection', + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int_with_model_param/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int_with_model_param/out.sql index 1951e13325..0953d8f9cb 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int_with_model_param/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int_with_model_param/out.sql @@ -1,18 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_INT( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection', - request_type => 'SHARED', - model_params => JSON '{}' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE_INT( + prompt => STRUCT( + `t0`.`string_col` AS `_field_1`, + ' is the same as ' AS `_field_2`, + `t0`.`string_col` AS `_field_3` + ), + connection_id => 'bigframes-dev.us.bigframes-default-connection', + request_type => 'SHARED', + model_params => JSON '{}' + ) AS `result` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_model_param/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_model_param/out.sql index 3419a77c61..80edf0ca78 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_model_param/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_model_param/out.sql @@ -1,18 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection', - request_type => 'SHARED', - model_params => JSON '{}' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE( + prompt => STRUCT( + `t0`.`string_col` AS `_field_1`, + ' is the same as ' AS `_field_2`, + `t0`.`string_col` AS `_field_3` + ), + connection_id => 'bigframes-dev.us.bigframes-default-connection', + request_type => 'SHARED', + model_params => JSON '{}' + ) AS `result` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_output_schema/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_output_schema/out.sql index e1e1670f12..acd0ef3079 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_output_schema/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_output_schema/out.sql @@ -1,19 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection', - endpoint => 'gemini-2.5-flash', - request_type => 'SHARED', - output_schema => 'x INT64, y FLOAT64' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE( + prompt => STRUCT( + `t0`.`string_col` AS `_field_1`, + ' is the same as ' AS `_field_2`, + `t0`.`string_col` AS `_field_3` + ), + connection_id => 'bigframes-dev.us.bigframes-default-connection', + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED', + output_schema => 'x INT64, y FLOAT64' + ) AS `result` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_if/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_if/out.sql index 275ba8d423..bda5d7a615 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_if/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_if/out.sql @@ -1,16 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.IF( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.IF( + prompt => STRUCT( + `t0`.`string_col` AS `_field_1`, + ' is the same as ' AS `_field_2`, + `t0`.`string_col` AS `_field_3` + ), + connection_id => 'bigframes-dev.us.bigframes-default-connection' + ) AS `result` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_score/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_score/out.sql index 01c71065b9..f8050b6059 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_score/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_score/out.sql @@ -1,16 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.SCORE( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.SCORE( + prompt => STRUCT( + `t0`.`string_col` AS `_field_1`, + ' is the same as ' AS `_field_2`, + `t0`.`string_col` AS `_field_3` + ), + connection_id => 'bigframes-dev.us.bigframes-default-connection' + ) AS `result` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_index/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_index/out.sql index d8e223d5f8..6b5c273f77 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_index/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_index/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - `string_list_col`[SAFE_OFFSET(1)] AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`string_list_col`[safe_offset(1)] AS `string_list_col` +FROM `bigframes-dev.sqlglot_test.repeated_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_slice_with_only_start/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_slice_with_only_start/out.sql index 0034ffd69c..63aed9f19b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_slice_with_only_start/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_slice_with_only_start/out.sql @@ -1,19 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY( - SELECT - el - FROM UNNEST(`string_list_col`) AS el WITH OFFSET AS slice_idx - WHERE - slice_idx >= 1 - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + ARRAY( + SELECT + el + FROM UNNEST(`t0`.`string_list_col`) AS el WITH OFFSET AS bq_arr_slice + WHERE + bq_arr_slice >= IF(1 < 0, ARRAY_LENGTH(`t0`.`string_list_col`) + 1, 1) + ) AS `string_list_col` +FROM `bigframes-dev.sqlglot_test.repeated_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_slice_with_start_and_stop/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_slice_with_start_and_stop/out.sql index f0638fa3af..cea5b171fe 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_slice_with_start_and_stop/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_slice_with_start_and_stop/out.sql @@ -1,19 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY( - SELECT - el - FROM UNNEST(`string_list_col`) AS el WITH OFFSET AS slice_idx - WHERE - slice_idx >= 1 AND slice_idx < 5 - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + ARRAY( + SELECT + el + FROM UNNEST(`t0`.`string_list_col`) AS el WITH OFFSET AS bq_arr_slice + WHERE + bq_arr_slice >= IF(1 < 0, ARRAY_LENGTH(`t0`.`string_list_col`) + 1, 1) + AND bq_arr_slice < IF(5 < 0, ARRAY_LENGTH(`t0`.`string_list_col`) + 5, 5) + ) AS `string_list_col` +FROM `bigframes-dev.sqlglot_test.repeated_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_to_string/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_to_string/out.sql index 09446bb8f5..a5313a9749 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_to_string/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_to_string/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY_TO_STRING(`string_list_col`, '.') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + ARRAY_TO_STRING(`t0`.`string_list_col`, '.') AS `string_list_col` +FROM `bigframes-dev.sqlglot_test.repeated_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_blob_ops/test_obj_fetch_metadata/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_blob_ops/test_obj_fetch_metadata/out.sql index bd99b86064..5f1684e56b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_blob_ops/test_obj_fetch_metadata/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_blob_ops/test_obj_fetch_metadata/out.sql @@ -1,25 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - OBJ.MAKE_REF(`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') AS `bfcol_4` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - OBJ.FETCH_METADATA(`bfcol_4`) AS `bfcol_7` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_7`.`version` AS `bfcol_10` - FROM `bfcte_2` -) SELECT - `rowindex`, - `bfcol_10` AS `version` -FROM `bfcte_3` \ No newline at end of file + `t1`.`rowindex`, + `OBJ.FETCH_METADATA`( + `OBJ.MAKE_REF`(`t1`.`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') + ).`version` AS `version` +FROM ( + SELECT + `t0`.`rowindex`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_blob_ops/test_obj_get_access_url/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_blob_ops/test_obj_get_access_url/out.sql index c65436e530..f341019dee 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_blob_ops/test_obj_get_access_url/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_blob_ops/test_obj_get_access_url/out.sql @@ -1,25 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - OBJ.MAKE_REF(`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') AS `bfcol_4` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - OBJ.GET_ACCESS_URL(`bfcol_4`) AS `bfcol_7` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - JSON_VALUE(`bfcol_7`, '$.access_urls.read_url') AS `bfcol_10` - FROM `bfcte_2` -) SELECT - `rowindex`, - `bfcol_10` AS `string_col` -FROM `bfcte_3` \ No newline at end of file + `t1`.`rowindex`, + json_value( + `OBJ.GET_ACCESS_URL`( + `OBJ.MAKE_REF`(`t1`.`string_col`, 'bigframes-dev.test-region.bigframes-default-connection'), + 'R' + ), + '$.access_urls.read_url' + ) AS `string_col` +FROM ( + SELECT + `t0`.`rowindex`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_blob_ops/test_obj_make_ref/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_blob_ops/test_obj_make_ref/out.sql index d74449c986..9c344200b6 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_blob_ops/test_obj_make_ref/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_blob_ops/test_obj_make_ref/out.sql @@ -1,15 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - OBJ.MAKE_REF(`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `rowindex`, - `bfcol_4` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + `t1`.`rowindex`, + `OBJ.MAKE_REF`(`t1`.`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') AS `string_col` +FROM ( + SELECT + `t0`.`rowindex`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_bool_ops/test_and_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_bool_ops/test_and_op/out.sql index 634a936a0e..17dd13b4b1 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_bool_ops/test_and_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_bool_ops/test_and_op/out.sql @@ -1,31 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `bool_col` AS `bfcol_7`, - `int64_col` AS `bfcol_8`, - `int64_col` & `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` AND `bfcol_7` AS `bfcol_18` - FROM `bfcte_1` -) SELECT - `bfcol_14` AS `rowindex`, - `bfcol_15` AS `bool_col`, - `bfcol_16` AS `int64_col`, - `bfcol_17` AS `int_and_int`, - `bfcol_18` AS `bool_and_bool` -FROM `bfcte_2` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`bool_col`, + `t0`.`int64_col`, + `t0`.`int64_col` & `t0`.`int64_col` AS `int_and_int`, + `t0`.`bool_col` AND `t0`.`bool_col` AS `bool_and_bool` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_bool_ops/test_or_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_bool_ops/test_or_op/out.sql index 0069b07d8f..94b0cf6b58 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_bool_ops/test_or_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_bool_ops/test_or_op/out.sql @@ -1,31 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `bool_col` AS `bfcol_7`, - `int64_col` AS `bfcol_8`, - `int64_col` | `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` OR `bfcol_7` AS `bfcol_18` - FROM `bfcte_1` -) SELECT - `bfcol_14` AS `rowindex`, - `bfcol_15` AS `bool_col`, - `bfcol_16` AS `int64_col`, - `bfcol_17` AS `int_and_int`, - `bfcol_18` AS `bool_and_bool` -FROM `bfcte_2` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`bool_col`, + `t0`.`int64_col`, + `t0`.`int64_col` | `t0`.`int64_col` AS `int_and_int`, + `t0`.`bool_col` OR `t0`.`bool_col` AS `bool_and_bool` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_bool_ops/test_xor_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_bool_ops/test_xor_op/out.sql index e4c87ed720..7517483e53 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_bool_ops/test_xor_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_bool_ops/test_xor_op/out.sql @@ -1,31 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `bool_col` AS `bfcol_7`, - `int64_col` AS `bfcol_8`, - `int64_col` ^ `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` AND NOT `bfcol_7` OR NOT `bfcol_7` AND `bfcol_7` AS `bfcol_18` - FROM `bfcte_1` -) SELECT - `bfcol_14` AS `rowindex`, - `bfcol_15` AS `bool_col`, - `bfcol_16` AS `int64_col`, - `bfcol_17` AS `int_and_int`, - `bfcol_18` AS `bool_and_bool` -FROM `bfcte_2` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`bool_col`, + `t0`.`int64_col`, + `t0`.`int64_col` ^ `t0`.`int64_col` AS `int_and_int`, + ( + `t0`.`bool_col` AND NOT `t0`.`bool_col` + ) + OR ( + NOT `t0`.`bool_col` AND `t0`.`bool_col` + ) AS `bool_and_bool` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_eq_null_match/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_eq_null_match/out.sql index 57af99a52b..3c84dc0999 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_eq_null_match/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_eq_null_match/out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COALESCE(CAST(`int64_col` AS STRING), '$NULL_SENTINEL$') = COALESCE(CAST(CAST(`bool_col` AS INT64) AS STRING), '$NULL_SENTINEL$') AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + COALESCE(CAST(`t0`.`int64_col` AS STRING), '$NULL_SENTINEL$') = COALESCE(CAST(CAST(`t0`.`bool_col` AS INT64) AS STRING), '$NULL_SENTINEL$') AS `int64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_eq_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_eq_numeric/out.sql index 9c7c19e61c..450ae2eea1 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_eq_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_eq_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` = `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` = 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` = CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) = `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_ne_int`, - `bfcol_40` AS `int_ne_1`, - `bfcol_41` AS `int_ne_bool`, - `bfcol_42` AS `bool_ne_int` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + `t0`.`int64_col` = `t0`.`int64_col` AS `int_ne_int`, + `t0`.`int64_col` = 1 AS `int_ne_1`, + `t0`.`int64_col` = CAST(`t0`.`bool_col` AS INT64) AS `int_ne_bool`, + CAST(`t0`.`bool_col` AS INT64) = `t0`.`int64_col` AS `bool_ne_int` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_ge_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_ge_numeric/out.sql index e99fe49c8e..fc258f9c74 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_ge_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_ge_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` >= `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` >= 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` >= CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) >= `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_ge_int`, - `bfcol_40` AS `int_ge_1`, - `bfcol_41` AS `int_ge_bool`, - `bfcol_42` AS `bool_ge_int` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + `t0`.`int64_col` >= `t0`.`int64_col` AS `int_ge_int`, + `t0`.`int64_col` >= 1 AS `int_ge_1`, + `t0`.`int64_col` >= CAST(`t0`.`bool_col` AS INT64) AS `int_ge_bool`, + CAST(`t0`.`bool_col` AS INT64) >= `t0`.`int64_col` AS `bool_ge_int` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_gt_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_gt_numeric/out.sql index 4e5aba3d31..ebb61888cf 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_gt_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_gt_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` > `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` > 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` > CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) > `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_gt_int`, - `bfcol_40` AS `int_gt_1`, - `bfcol_41` AS `int_gt_bool`, - `bfcol_42` AS `bool_gt_int` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + `t0`.`int64_col` > `t0`.`int64_col` AS `int_gt_int`, + `t0`.`int64_col` > 1 AS `int_gt_1`, + `t0`.`int64_col` > CAST(`t0`.`bool_col` AS INT64) AS `int_gt_bool`, + CAST(`t0`.`bool_col` AS INT64) > `t0`.`int64_col` AS `bool_gt_int` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_is_in/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_is_in/out.sql index 197ed279fa..17b2c5f139 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_is_in/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_is_in/out.sql @@ -1,32 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COALESCE(`int64_col` IN (1, 2, 3), FALSE) AS `bfcol_2`, - ( - `int64_col` IS NULL - ) OR `int64_col` IN (123456) AS `bfcol_3`, - COALESCE(`int64_col` IN (1.0, 2.0, 3.0), FALSE) AS `bfcol_4`, - FALSE AS `bfcol_5`, - COALESCE(`int64_col` IN (2.5, 3), FALSE) AS `bfcol_6`, - FALSE AS `bfcol_7`, - COALESCE(`int64_col` IN (123456), FALSE) AS `bfcol_8`, - ( - `float64_col` IS NULL - ) OR `float64_col` IN (1, 2, 3) AS `bfcol_9` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `ints`, - `bfcol_3` AS `ints_w_null`, - `bfcol_4` AS `floats`, - `bfcol_5` AS `strings`, - `bfcol_6` AS `mixed`, - `bfcol_7` AS `empty`, - `bfcol_8` AS `ints_wo_match_nulls`, - `bfcol_9` AS `float_in_ints` -FROM `bfcte_1` \ No newline at end of file + COALESCE(`t0`.`int64_col` IN (1, 2, 3), FALSE) AS `ints`, + ( + `t0`.`int64_col` IS NULL + ) OR `t0`.`int64_col` IN (123456) AS `ints_w_null`, + COALESCE(`t0`.`int64_col` IN (1.0, 2.0, 3.0), FALSE) AS `floats`, + COALESCE(FALSE, FALSE) AS `strings`, + COALESCE(`t0`.`int64_col` IN (2.5, 3), FALSE) AS `mixed`, + COALESCE(FALSE, FALSE) AS `empty`, + COALESCE(`t0`.`int64_col` IN (123456), FALSE) AS `ints_wo_match_nulls`, + ( + `t0`.`float64_col` IS NULL + ) OR `t0`.`float64_col` IN (1, 2, 3) AS `float_in_ints` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_le_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_le_numeric/out.sql index 97a00d1c88..688d395fa3 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_le_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_le_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` <= `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` <= 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` <= CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) <= `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_le_int`, - `bfcol_40` AS `int_le_1`, - `bfcol_41` AS `int_le_bool`, - `bfcol_42` AS `bool_le_int` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + `t0`.`int64_col` <= `t0`.`int64_col` AS `int_le_int`, + `t0`.`int64_col` <= 1 AS `int_le_1`, + `t0`.`int64_col` <= CAST(`t0`.`bool_col` AS INT64) AS `int_le_bool`, + CAST(`t0`.`bool_col` AS INT64) <= `t0`.`int64_col` AS `bool_le_int` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_lt_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_lt_numeric/out.sql index addebd3187..53d450db45 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_lt_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_lt_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` < `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` < 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` < CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) < `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_lt_int`, - `bfcol_40` AS `int_lt_1`, - `bfcol_41` AS `int_lt_bool`, - `bfcol_42` AS `bool_lt_int` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + `t0`.`int64_col` < `t0`.`int64_col` AS `int_lt_int`, + `t0`.`int64_col` < 1 AS `int_lt_1`, + `t0`.`int64_col` < CAST(`t0`.`bool_col` AS INT64) AS `int_lt_bool`, + CAST(`t0`.`bool_col` AS INT64) < `t0`.`int64_col` AS `bool_lt_int` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_maximum_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_maximum_op/out.sql index bbef212707..47ca500a47 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_maximum_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_maximum_op/out.sql @@ -1,14 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - GREATEST(`int64_col`, `float64_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN ( + `t0`.`float64_col` IS NULL + ) OR ( + `t0`.`int64_col` < `t0`.`float64_col` + ) + THEN `t0`.`float64_col` + ELSE `t0`.`int64_col` + END AS `int64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_minimum_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_minimum_op/out.sql index 1f00f5892e..d8d887c5bb 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_minimum_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_minimum_op/out.sql @@ -1,14 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LEAST(`int64_col`, `float64_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN ( + `t0`.`float64_col` IS NULL + ) OR ( + `t0`.`int64_col` > `t0`.`float64_col` + ) + THEN `t0`.`float64_col` + ELSE `t0`.`int64_col` + END AS `int64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_ne_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_ne_numeric/out.sql index 417d24aa72..d7c205f8da 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_ne_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_ne_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` <> `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` <> 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` <> CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) <> `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_ne_int`, - `bfcol_40` AS `int_ne_1`, - `bfcol_41` AS `int_ne_bool`, - `bfcol_42` AS `bool_ne_int` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + `t0`.`int64_col` <> `t0`.`int64_col` AS `int_ne_int`, + `t0`.`int64_col` <> 1 AS `int_ne_1`, + `t0`.`int64_col` <> CAST(`t0`.`bool_col` AS INT64) AS `int_ne_bool`, + CAST(`t0`.`bool_col` AS INT64) <> `t0`.`int64_col` AS `bool_ne_int` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_add_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_add_timedelta/out.sql index 2fef18eeb8..0670fac9a0 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_add_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_add_timedelta/out.sql @@ -1,60 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `timestamp_col` AS `bfcol_7`, - `date_col` AS `bfcol_8`, - TIMESTAMP_ADD(CAST(`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - TIMESTAMP_ADD(`bfcol_7`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - TIMESTAMP_ADD(CAST(`bfcol_16` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - TIMESTAMP_ADD(`bfcol_25`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_42` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - 172800000000 AS `bfcol_50` - FROM `bfcte_4` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `timestamp_col`, - `bfcol_38` AS `date_col`, - `bfcol_39` AS `date_add_timedelta`, - `bfcol_40` AS `timestamp_add_timedelta`, - `bfcol_41` AS `timedelta_add_date`, - `bfcol_42` AS `timedelta_add_timestamp`, - `bfcol_50` AS `timedelta_add_timedelta` -FROM `bfcte_5` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`timestamp_col`, + `t0`.`date_col`, + TIMESTAMP_ADD(CAST(`t0`.`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `date_add_timedelta`, + TIMESTAMP_ADD(`t0`.`timestamp_col`, INTERVAL 86400000000 MICROSECOND) AS `timestamp_add_timedelta`, + TIMESTAMP_ADD(CAST(`t0`.`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_date`, + TIMESTAMP_ADD(`t0`.`timestamp_col`, INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_timestamp`, + 172800000000 AS `timedelta_add_timedelta` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_date/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_date/out.sql index b8f46ceafe..aed0a0c199 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_date/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_date/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - DATE(`timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + DATE(`t0`.`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_day/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_day/out.sql index 52d80fd2a6..7963ea2a5e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_day/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_day/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(DAY FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(day FROM `t0`.`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_dayofweek/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_dayofweek/out.sql index 0119bbb4e9..24601abf2d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_dayofweek/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_dayofweek/out.sql @@ -1,19 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `datetime_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(MOD(EXTRACT(DAYOFWEEK FROM `datetime_col`) + 5, 7) AS INT64) AS `bfcol_6`, - CAST(MOD(EXTRACT(DAYOFWEEK FROM `timestamp_col`) + 5, 7) AS INT64) AS `bfcol_7`, - CAST(MOD(EXTRACT(DAYOFWEEK FROM `date_col`) + 5, 7) AS INT64) AS `bfcol_8` - FROM `bfcte_0` -) SELECT - `bfcol_6` AS `datetime_col`, - `bfcol_7` AS `timestamp_col`, - `bfcol_8` AS `date_col` -FROM `bfcte_1` \ No newline at end of file + CAST(MOD(EXTRACT(dayofweek FROM `t0`.`datetime_col`) + 5, 7) AS INT64) AS `datetime_col`, + CAST(MOD(EXTRACT(dayofweek FROM `t0`.`timestamp_col`) + 5, 7) AS INT64) AS `timestamp_col`, + CAST(MOD(EXTRACT(dayofweek FROM `t0`.`date_col`) + 5, 7) AS INT64) AS `date_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_dayofyear/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_dayofyear/out.sql index 521419757a..c62b63e766 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_dayofyear/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_dayofyear/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(DAYOFYEAR FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(dayofyear FROM `t0`.`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_floor_dt/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_floor_dt/out.sql index fe76efb609..990cd7b567 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_floor_dt/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_floor_dt/out.sql @@ -1,36 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `datetime_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIMESTAMP_TRUNC(`timestamp_col`, MICROSECOND) AS `bfcol_2`, - TIMESTAMP_TRUNC(`timestamp_col`, MILLISECOND) AS `bfcol_3`, - TIMESTAMP_TRUNC(`timestamp_col`, SECOND) AS `bfcol_4`, - TIMESTAMP_TRUNC(`timestamp_col`, MINUTE) AS `bfcol_5`, - TIMESTAMP_TRUNC(`timestamp_col`, HOUR) AS `bfcol_6`, - TIMESTAMP_TRUNC(`timestamp_col`, DAY) AS `bfcol_7`, - TIMESTAMP_TRUNC(`timestamp_col`, WEEK(MONDAY)) AS `bfcol_8`, - TIMESTAMP_TRUNC(`timestamp_col`, MONTH) AS `bfcol_9`, - TIMESTAMP_TRUNC(`timestamp_col`, QUARTER) AS `bfcol_10`, - TIMESTAMP_TRUNC(`timestamp_col`, YEAR) AS `bfcol_11`, - TIMESTAMP_TRUNC(`datetime_col`, MICROSECOND) AS `bfcol_12`, - TIMESTAMP_TRUNC(`datetime_col`, MICROSECOND) AS `bfcol_13` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `timestamp_col_us`, - `bfcol_3` AS `timestamp_col_ms`, - `bfcol_4` AS `timestamp_col_s`, - `bfcol_5` AS `timestamp_col_min`, - `bfcol_6` AS `timestamp_col_h`, - `bfcol_7` AS `timestamp_col_D`, - `bfcol_8` AS `timestamp_col_W`, - `bfcol_9` AS `timestamp_col_M`, - `bfcol_10` AS `timestamp_col_Q`, - `bfcol_11` AS `timestamp_col_Y`, - `bfcol_12` AS `datetime_col_q`, - `bfcol_13` AS `datetime_col_us` -FROM `bfcte_1` \ No newline at end of file + CAST(TIMESTAMP_TRUNC(`t0`.`timestamp_col`, MICROSECOND) AS TIMESTAMP) AS `timestamp_col_us`, + CAST(TIMESTAMP_TRUNC(`t0`.`timestamp_col`, MILLISECOND) AS TIMESTAMP) AS `timestamp_col_ms`, + CAST(TIMESTAMP_TRUNC(`t0`.`timestamp_col`, SECOND) AS TIMESTAMP) AS `timestamp_col_s`, + CAST(TIMESTAMP_TRUNC(`t0`.`timestamp_col`, MINUTE) AS TIMESTAMP) AS `timestamp_col_min`, + CAST(TIMESTAMP_TRUNC(`t0`.`timestamp_col`, HOUR) AS TIMESTAMP) AS `timestamp_col_h`, + CAST(TIMESTAMP_TRUNC(`t0`.`timestamp_col`, DAY) AS TIMESTAMP) AS `timestamp_col_D`, + CAST(TIMESTAMP_TRUNC(`t0`.`timestamp_col`, WEEK(MONDAY)) AS TIMESTAMP) AS `timestamp_col_W`, + CAST(TIMESTAMP_TRUNC(`t0`.`timestamp_col`, MONTH) AS TIMESTAMP) AS `timestamp_col_M`, + CAST(TIMESTAMP_TRUNC(`t0`.`timestamp_col`, QUARTER) AS TIMESTAMP) AS `timestamp_col_Q`, + CAST(TIMESTAMP_TRUNC(`t0`.`timestamp_col`, YEAR) AS TIMESTAMP) AS `timestamp_col_Y`, + TIMESTAMP_TRUNC(`t0`.`datetime_col`, MICROSECOND) AS `datetime_col_q`, + TIMESTAMP_TRUNC(`t0`.`datetime_col`, MICROSECOND) AS `datetime_col_us` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_hour/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_hour/out.sql index 5fc6621a7c..53e3c08a40 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_hour/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_hour/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(HOUR FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(hour FROM `t0`.`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_day/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_day/out.sql index 9422844b34..777550ea4f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_day/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_day/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(MOD(EXTRACT(DAYOFWEEK FROM `timestamp_col`) + 5, 7) AS INT64) + 1 AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(MOD(EXTRACT(dayofweek FROM `t0`.`timestamp_col`) + 5, 7) AS INT64) + 1 AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_week/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_week/out.sql index 4db49fb10f..2545005d2f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_week/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_week/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(ISOWEEK FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(isoweek FROM `t0`.`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_year/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_year/out.sql index 8d49933202..78c9b97f5b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_year/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_year/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(ISOYEAR FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(isoyear FROM `t0`.`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_minute/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_minute/out.sql index e089a77af5..a7acafbe15 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_minute/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_minute/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(MINUTE FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(minute FROM `t0`.`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_month/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_month/out.sql index 53d135903b..90d7a2028a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_month/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_month/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(MONTH FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(month FROM `t0`.`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_normalize/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_normalize/out.sql index b542dfea72..798f592a51 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_normalize/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_normalize/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIMESTAMP_TRUNC(`timestamp_col`, DAY) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(TIMESTAMP_TRUNC(`t0`.`timestamp_col`, DAY) AS TIMESTAMP) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_quarter/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_quarter/out.sql index 4a232cb5a3..b77731c110 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_quarter/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_quarter/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(QUARTER FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(quarter FROM `t0`.`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_second/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_second/out.sql index e86d830b73..2b302079a3 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_second/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_second/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(SECOND FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(second FROM `t0`.`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_strftime/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_strftime/out.sql index 190cd7895b..03a415b2f9 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_strftime/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_strftime/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FORMAT_TIMESTAMP('%Y-%m-%d', `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + format_timestamp('%Y-%m-%d', `t0`.`timestamp_col`, 'UTC') AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_sub_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_sub_timedelta/out.sql index ebcffd67f6..f643fb8f26 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_sub_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_sub_timedelta/out.sql @@ -1,82 +1,17 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `duration_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_8`, - `timestamp_col` AS `bfcol_9`, - `date_col` AS `bfcol_10`, - `duration_col` AS `bfcol_11` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_11` AS `bfcol_18`, - `bfcol_10` AS `bfcol_19`, - TIMESTAMP_SUB(CAST(`bfcol_10` AS DATETIME), INTERVAL `bfcol_11` MICROSECOND) AS `bfcol_20` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_19` AS `bfcol_29`, - `bfcol_20` AS `bfcol_30`, - TIMESTAMP_SUB(`bfcol_17`, INTERVAL `bfcol_18` MICROSECOND) AS `bfcol_31` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - `bfcol_30` AS `bfcol_42`, - `bfcol_31` AS `bfcol_43`, - TIMESTAMP_DIFF(CAST(`bfcol_29` AS DATETIME), CAST(`bfcol_29` AS DATETIME), MICROSECOND) AS `bfcol_44` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - `bfcol_38` AS `bfcol_52`, - `bfcol_39` AS `bfcol_53`, - `bfcol_40` AS `bfcol_54`, - `bfcol_41` AS `bfcol_55`, - `bfcol_42` AS `bfcol_56`, - `bfcol_43` AS `bfcol_57`, - `bfcol_44` AS `bfcol_58`, - TIMESTAMP_DIFF(`bfcol_39`, `bfcol_39`, MICROSECOND) AS `bfcol_59` - FROM `bfcte_4` -), `bfcte_6` AS ( - SELECT - *, - `bfcol_52` AS `bfcol_68`, - `bfcol_53` AS `bfcol_69`, - `bfcol_54` AS `bfcol_70`, - `bfcol_55` AS `bfcol_71`, - `bfcol_56` AS `bfcol_72`, - `bfcol_57` AS `bfcol_73`, - `bfcol_58` AS `bfcol_74`, - `bfcol_59` AS `bfcol_75`, - `bfcol_54` - `bfcol_54` AS `bfcol_76` - FROM `bfcte_5` -) SELECT - `bfcol_68` AS `rowindex`, - `bfcol_69` AS `timestamp_col`, - `bfcol_70` AS `duration_col`, - `bfcol_71` AS `date_col`, - `bfcol_72` AS `date_sub_timedelta`, - `bfcol_73` AS `timestamp_sub_timedelta`, - `bfcol_74` AS `timestamp_sub_date`, - `bfcol_75` AS `date_sub_timestamp`, - `bfcol_76` AS `timedelta_sub_timedelta` -FROM `bfcte_6` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`timestamp_col`, + CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64) AS `duration_col`, + `t0`.`date_col`, + TIMESTAMP_SUB( + CAST(`t0`.`date_col` AS DATETIME), + INTERVAL (CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64)) MICROSECOND + ) AS `date_sub_timedelta`, + TIMESTAMP_SUB( + `t0`.`timestamp_col`, + INTERVAL (CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64)) MICROSECOND + ) AS `timestamp_sub_timedelta`, + DATE_DIFF(`t0`.`date_col`, `t0`.`date_col`, DAY) * 86400000000 AS `timestamp_sub_date`, + TIMESTAMP_DIFF(`t0`.`timestamp_col`, `t0`.`timestamp_col`, MICROSECOND) AS `date_sub_timestamp`, + CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64) - CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64) AS `timedelta_sub_timedelta` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_time/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_time/out.sql index 5a8ab600ba..477d649a6b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_time/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_time/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIME(`timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + TIME(`t0`.`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_to_datetime/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_to_datetime/out.sql index bbba3b1533..06fcff0a26 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_to_datetime/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_to_datetime/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(TIMESTAMP_SECONDS(`int64_col`) AS DATETIME) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + CAST(CAST(timestamp_micros(CAST(trunc(`t0`.`int64_col` * 0.001) AS INT64)) AS TIMESTAMP) AS DATETIME) AS `int64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_to_timestamp/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_to_timestamp/out.sql index df01fb3269..5c3bcca681 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_to_timestamp/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_to_timestamp/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIMESTAMP_SECONDS(`int64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + CAST(timestamp_micros(CAST(trunc(`t0`.`int64_col` * 0.001) AS INT64)) AS TIMESTAMP) AS `int64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_micros/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_micros/out.sql index e6515017f2..bb0965b99b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_micros/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_micros/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_MICROS(`timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + UNIX_MICROS(`t1`.`timestamp_col`) AS `timestamp_col` +FROM ( + SELECT + `t0`.`timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_millis/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_millis/out.sql index caec5effe0..5c47285e4e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_millis/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_millis/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_MILLIS(`timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + UNIX_MILLIS(`t1`.`timestamp_col`) AS `timestamp_col` +FROM ( + SELECT + `t0`.`timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_seconds/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_seconds/out.sql index 6dc0ea2a02..05200c93a8 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_seconds/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_seconds/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_SECONDS(`timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + UNIX_SECONDS(`t0`.`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_year/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_year/out.sql index 1ceb674137..0240b77c07 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_year/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_year/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(YEAR FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(year FROM `t0`.`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_bool/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_bool/out.sql index 1f90accd0b..b897ea263e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_bool/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_bool/out.sql @@ -1,18 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bool_col` AS `bfcol_2`, - `float64_col` <> 0 AS `bfcol_3`, - `float64_col` <> 0 AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `bool_col`, - `bfcol_3` AS `float64_col`, - `bfcol_4` AS `float64_w_safe` -FROM `bfcte_1` \ No newline at end of file + `t0`.`bool_col`, + `t0`.`float64_col` <> 0 AS `float64_col`, + `t0`.`float64_col` <> 0 AS `float64_w_safe` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_float/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_float/out.sql index 32c8da56fa..29aaa46f64 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_float/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_float/out.sql @@ -1,17 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(CAST(`bool_col` AS INT64) AS FLOAT64) AS `bfcol_1`, - CAST('1.34235e4' AS FLOAT64) AS `bfcol_2`, - SAFE_CAST(SAFE_CAST(`bool_col` AS INT64) AS FLOAT64) AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `bool_col`, - `bfcol_2` AS `str_const`, - `bfcol_3` AS `bool_w_safe` -FROM `bfcte_1` \ No newline at end of file + CAST(CAST(`t0`.`bool_col` AS INT64) AS FLOAT64) AS `bool_col`, + CAST('1.34235e4' AS FLOAT64) AS `str_const`, + SAFE_CAST(SAFE_CAST(`t0`.`bool_col` AS INT64) AS FLOAT64) AS `bool_w_safe` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_from_json/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_from_json/out.sql index d1577c0664..c7c914ee89 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_from_json/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_from_json/out.sql @@ -1,21 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - INT64(`json_col`) AS `bfcol_1`, - FLOAT64(`json_col`) AS `bfcol_2`, - BOOL(`json_col`) AS `bfcol_3`, - STRING(`json_col`) AS `bfcol_4`, - SAFE.INT64(`json_col`) AS `bfcol_5` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col`, - `bfcol_2` AS `float64_col`, - `bfcol_3` AS `bool_col`, - `bfcol_4` AS `string_col`, - `bfcol_5` AS `int64_w_safe` -FROM `bfcte_1` \ No newline at end of file + INT64(`t1`.`json_col`) AS `int64_col`, + FLOAT64(`t1`.`json_col`) AS `float64_col`, + BOOL(`t1`.`json_col`) AS `bool_col`, + STRING(`t1`.`json_col`) AS `string_col`, + SAFE.INT64(`t1`.`json_col`) AS `int64_w_safe` +FROM ( + SELECT + `t0`.`json_col` + FROM `bigframes-dev.sqlglot_test.json_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_int/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_int/out.sql index e0fe2af9a9..2f96c3c7a8 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_int/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_int/out.sql @@ -1,33 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `datetime_col`, - `float64_col`, - `numeric_col`, - `time_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_MICROS(CAST(`datetime_col` AS TIMESTAMP)) AS `bfcol_5`, - UNIX_MICROS(SAFE_CAST(`datetime_col` AS TIMESTAMP)) AS `bfcol_6`, - TIME_DIFF(CAST(`time_col` AS TIME), '00:00:00', MICROSECOND) AS `bfcol_7`, - TIME_DIFF(SAFE_CAST(`time_col` AS TIME), '00:00:00', MICROSECOND) AS `bfcol_8`, - UNIX_MICROS(`timestamp_col`) AS `bfcol_9`, - CAST(TRUNC(`numeric_col`) AS INT64) AS `bfcol_10`, - CAST(TRUNC(`float64_col`) AS INT64) AS `bfcol_11`, - SAFE_CAST(TRUNC(`float64_col`) AS INT64) AS `bfcol_12`, - CAST('100' AS INT64) AS `bfcol_13` - FROM `bfcte_0` -) SELECT - `bfcol_5` AS `datetime_col`, - `bfcol_6` AS `datetime_w_safe`, - `bfcol_7` AS `time_col`, - `bfcol_8` AS `time_w_safe`, - `bfcol_9` AS `timestamp_col`, - `bfcol_10` AS `numeric_col`, - `bfcol_11` AS `float64_col`, - `bfcol_12` AS `float64_w_safe`, - `bfcol_13` AS `str_const` -FROM `bfcte_1` \ No newline at end of file + UNIX_MICROS(CAST(`t0`.`datetime_col` AS TIMESTAMP)) AS `datetime_col`, + SAFE_CAST(SAFE_CAST(`t0`.`datetime_col` AS TIMESTAMP) AS INT64) AS `datetime_w_safe`, + TIME_DIFF(`t0`.`time_col`, TIME(0, 0, 0), MICROSECOND) AS `time_col`, + TIME_DIFF(`t0`.`time_col`, TIME(0, 0, 0), MICROSECOND) AS `time_w_safe`, + UNIX_MICROS(`t0`.`timestamp_col`) AS `timestamp_col`, + CAST(trunc(`t0`.`numeric_col`) AS INT64) AS `numeric_col`, + CAST(trunc(`t0`.`float64_col`) AS INT64) AS `float64_col`, + SAFE_CAST(`t0`.`float64_col` AS INT64) AS `float64_w_safe`, + CAST('100' AS INT64) AS `str_const` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_json/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_json/out.sql index 2defc2e72b..58b7defa20 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_json/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_json/out.sql @@ -1,26 +1,61 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - PARSE_JSON(CAST(`int64_col` AS STRING)) AS `bfcol_4`, - PARSE_JSON(CAST(`float64_col` AS STRING)) AS `bfcol_5`, - PARSE_JSON(CAST(`bool_col` AS STRING)) AS `bfcol_6`, - PARSE_JSON(`string_col`) AS `bfcol_7`, - PARSE_JSON(CAST(`bool_col` AS STRING)) AS `bfcol_8`, - PARSE_JSON_IN_SAFE(`string_col`) AS `bfcol_9` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `int64_col`, - `bfcol_5` AS `float64_col`, - `bfcol_6` AS `bool_col`, - `bfcol_7` AS `string_col`, - `bfcol_8` AS `bool_w_safe`, - `bfcol_9` AS `string_w_safe` -FROM `bfcte_1` \ No newline at end of file + PARSE_JSON(CAST(`t1`.`int64_col` AS STRING)) AS `int64_col`, + PARSE_JSON(CAST(`t1`.`float64_col` AS STRING)) AS `float64_col`, + PARSE_JSON( + LOWER( + CONCAT( + UPPER( + SUBSTRING( + CAST(`t1`.`bool_col` AS STRING), + IF(( + 0 + 1 + ) >= 1, 0 + 1, 0 + 1 + LENGTH(CAST(`t1`.`bool_col` AS STRING))), + 1 + ) + ), + LOWER( + SUBSTRING( + CAST(`t1`.`bool_col` AS STRING), + IF(( + 1 + 1 + ) >= 1, 1 + 1, 1 + 1 + LENGTH(CAST(`t1`.`bool_col` AS STRING))), + LENGTH(CAST(`t1`.`bool_col` AS STRING)) + ) + ) + ) + ) + ) AS `bool_col`, + PARSE_JSON(`t1`.`string_col`) AS `string_col`, + SAFE.PARSE_JSON( + LOWER( + CONCAT( + UPPER( + SUBSTRING( + SAFE_CAST(`t1`.`bool_col` AS STRING), + IF(( + 0 + 1 + ) >= 1, 0 + 1, 0 + 1 + LENGTH(SAFE_CAST(`t1`.`bool_col` AS STRING))), + 1 + ) + ), + LOWER( + SUBSTRING( + SAFE_CAST(`t1`.`bool_col` AS STRING), + IF(( + 1 + 1 + ) >= 1, 1 + 1, 1 + 1 + LENGTH(SAFE_CAST(`t1`.`bool_col` AS STRING))), + LENGTH(SAFE_CAST(`t1`.`bool_col` AS STRING)) + ) + ) + ) + ) + ) AS `bool_w_safe`, + SAFE.PARSE_JSON(`t1`.`string_col`) AS `string_w_safe` +FROM ( + SELECT + `t0`.`bool_col`, + `t0`.`int64_col`, + `t0`.`float64_col`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_string/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_string/out.sql index da6eb6ce18..1d3a924019 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_string/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_string/out.sql @@ -1,18 +1,43 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(`int64_col` AS STRING) AS `bfcol_2`, - INITCAP(CAST(`bool_col` AS STRING)) AS `bfcol_3`, - INITCAP(SAFE_CAST(`bool_col` AS STRING)) AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int64_col`, - `bfcol_3` AS `bool_col`, - `bfcol_4` AS `bool_w_safe` -FROM `bfcte_1` \ No newline at end of file + CAST(`t0`.`int64_col` AS STRING) AS `int64_col`, + CONCAT( + UPPER( + SUBSTRING( + CAST(`t0`.`bool_col` AS STRING), + IF(( + 0 + 1 + ) >= 1, 0 + 1, 0 + 1 + LENGTH(CAST(`t0`.`bool_col` AS STRING))), + 1 + ) + ), + LOWER( + SUBSTRING( + CAST(`t0`.`bool_col` AS STRING), + IF(( + 1 + 1 + ) >= 1, 1 + 1, 1 + 1 + LENGTH(CAST(`t0`.`bool_col` AS STRING))), + LENGTH(CAST(`t0`.`bool_col` AS STRING)) + ) + ) + ) AS `bool_col`, + CONCAT( + UPPER( + SUBSTRING( + SAFE_CAST(`t0`.`bool_col` AS STRING), + IF(( + 0 + 1 + ) >= 1, 0 + 1, 0 + 1 + LENGTH(SAFE_CAST(`t0`.`bool_col` AS STRING))), + 1 + ) + ), + LOWER( + SUBSTRING( + SAFE_CAST(`t0`.`bool_col` AS STRING), + IF(( + 1 + 1 + ) >= 1, 1 + 1, 1 + 1 + LENGTH(SAFE_CAST(`t0`.`bool_col` AS STRING))), + LENGTH(SAFE_CAST(`t0`.`bool_col` AS STRING)) + ) + ) + ) AS `bool_w_safe` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_time_like/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_time_like/out.sql index 6523d8376c..b438994c73 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_time_like/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_time_like/out.sql @@ -1,19 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(TIMESTAMP_MICROS(`int64_col`) AS DATETIME) AS `bfcol_1`, - CAST(TIMESTAMP_MICROS(`int64_col`) AS TIME) AS `bfcol_2`, - CAST(TIMESTAMP_MICROS(`int64_col`) AS TIMESTAMP) AS `bfcol_3`, - SAFE_CAST(TIMESTAMP_MICROS(`int64_col`) AS TIME) AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_to_datetime`, - `bfcol_2` AS `int64_to_time`, - `bfcol_3` AS `int64_to_timestamp`, - `bfcol_4` AS `int64_to_time_safe` -FROM `bfcte_1` \ No newline at end of file + CAST(CAST(timestamp_micros(`t0`.`int64_col` * 1) AS TIMESTAMP) AS DATETIME) AS `int64_to_datetime`, + TIME(CAST(timestamp_micros(`t0`.`int64_col` * 1) AS TIMESTAMP)) AS `int64_to_time`, + CAST(timestamp_micros(`t0`.`int64_col` * 1) AS TIMESTAMP) AS `int64_to_timestamp`, + TIME(CAST(timestamp_micros(`t0`.`int64_col` * 1) AS TIMESTAMP)) AS `int64_to_time_safe` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_case_when_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_case_when_op/out.sql index 08a489e240..e8e227628d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_case_when_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_case_when_op/out.sql @@ -1,29 +1,26 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col`, - `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `bool_col` THEN `int64_col` END AS `bfcol_4`, - CASE WHEN `bool_col` THEN `int64_col` WHEN `bool_col` THEN `int64_too` END AS `bfcol_5`, - CASE WHEN `bool_col` THEN `bool_col` WHEN `bool_col` THEN `bool_col` END AS `bfcol_6`, - CASE - WHEN `bool_col` - THEN `int64_col` - WHEN `bool_col` - THEN CAST(`bool_col` AS INT64) - WHEN `bool_col` - THEN `float64_col` - END AS `bfcol_7` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `single_case`, - `bfcol_5` AS `double_case`, - `bfcol_6` AS `bool_types_case`, - `bfcol_7` AS `mixed_types_cast` -FROM `bfcte_1` \ No newline at end of file + CASE WHEN `t0`.`bool_col` THEN `t0`.`int64_col` ELSE CAST(NULL AS INT64) END AS `single_case`, + CASE + WHEN `t0`.`bool_col` + THEN `t0`.`int64_col` + WHEN `t0`.`bool_col` + THEN `t0`.`int64_too` + ELSE CAST(NULL AS INT64) + END AS `double_case`, + CASE + WHEN `t0`.`bool_col` + THEN `t0`.`bool_col` + WHEN `t0`.`bool_col` + THEN `t0`.`bool_col` + ELSE CAST(NULL AS BOOL) + END AS `bool_types_case`, + CASE + WHEN `t0`.`bool_col` + THEN `t0`.`int64_col` + WHEN `t0`.`bool_col` + THEN CAST(`t0`.`bool_col` AS INT64) + WHEN `t0`.`bool_col` + THEN `t0`.`float64_col` + ELSE CAST(NULL AS FLOAT64) + END AS `mixed_types_cast` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_clip/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_clip/out.sql index b162593147..22c4c34c1c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_clip/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_clip/out.sql @@ -1,15 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `int64_too`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - GREATEST(LEAST(`rowindex`, `int64_too`), `int64_col`) AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_3` AS `result_col` -FROM `bfcte_1` \ No newline at end of file + GREATEST(LEAST(`t0`.`rowindex`, `t0`.`int64_too`), `t0`.`int64_col`) AS `result_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_coalesce/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_coalesce/out.sql index 451de48b64..93ec10b57a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_coalesce/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_coalesce/out.sql @@ -1,16 +1,4 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `int64_col` AS `bfcol_2`, - COALESCE(`int64_too`, `int64_col`) AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int64_col`, - `bfcol_3` AS `int64_too` -FROM `bfcte_1` \ No newline at end of file + `t0`.`int64_col`, + COALESCE(`t0`.`int64_too`, `t0`.`int64_col`) AS `int64_too` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_fillna/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_fillna/out.sql index 07f2877e74..4d49261d0d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_fillna/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_fillna/out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COALESCE(`int64_col`, `float64_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + COALESCE(`t0`.`int64_col`, `t0`.`float64_col`) AS `int64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_hash/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_hash/out.sql index 19fce60091..52d0c3e667 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_hash/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_hash/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FARM_FINGERPRINT(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + FARM_FINGERPRINT(`t0`.`string_col`) AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_invert/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_invert/out.sql index 1bd2eb7426..836d7e4afb 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_invert/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_invert/out.sql @@ -1,25 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `bytes_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ~( - `int64_col` - ) AS `bfcol_6`, - ~( - `bytes_col` - ) AS `bfcol_7`, - NOT ( - `bool_col` - ) AS `bfcol_8` - FROM `bfcte_0` -) SELECT - `bfcol_6` AS `int64_col`, - `bfcol_7` AS `bytes_col`, - `bfcol_8` AS `bool_col` -FROM `bfcte_1` \ No newline at end of file + ~`t0`.`int64_col` AS `int64_col`, + ~`t0`.`bytes_col` AS `bytes_col`, + NOT ( + `t0`.`bool_col` + ) AS `bool_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_isnull/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_isnull/out.sql index 0a549bdd44..2726b766eb 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_isnull/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_isnull/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `float64_col` IS NULL AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`float64_col` IS NULL AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_map/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_map/out.sql index 52a3174cf9..45aedd2d03 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_map/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_map/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE `string_col` WHEN 'value1' THEN 'mapped1' END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CASE WHEN `t0`.`string_col` = 'value1' THEN 'mapped1' ELSE `t0`.`string_col` END AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_notnull/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_notnull/out.sql index bf3425fe6d..30ec6b1004 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_notnull/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_notnull/out.sql @@ -1,13 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - NOT `float64_col` IS NULL AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + ( + `t0`.`float64_col` + ) IS NOT NULL AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_row_key/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_row_key/out.sql index 13b27c2e14..4f3b727f40 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_row_key/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_row_key/out.sql @@ -1,70 +1,52 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `bytes_col`, - `date_col`, - `datetime_col`, - `duration_col`, - `float64_col`, - `geography_col`, - `int64_col`, - `int64_too`, - `numeric_col`, - `rowindex`, - `rowindex_2`, - `string_col`, - `time_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CONCAT( - CAST(FARM_FINGERPRINT( - CONCAT( - CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`bool_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`bytes_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`date_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`datetime_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(ST_ASTEXT(`geography_col`), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`int64_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`int64_too` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`numeric_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`float64_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex_2` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(`string_col`, ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`time_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`timestamp_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`duration_col` AS STRING), ''), '\\', '\\\\')) - ) - ) AS STRING), - CAST(FARM_FINGERPRINT( - CONCAT( - CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`bool_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`bytes_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`date_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`datetime_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(ST_ASTEXT(`geography_col`), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`int64_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`int64_too` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`numeric_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`float64_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex_2` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(`string_col`, ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`time_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`timestamp_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`duration_col` AS STRING), ''), '\\', '\\\\')), - '_' - ) - ) AS STRING), - CAST(RAND() AS STRING) - ) AS `bfcol_31` - FROM `bfcte_0` -) SELECT - `bfcol_31` AS `row_key` -FROM `bfcte_1` \ No newline at end of file + CONCAT( + CAST(FARM_FINGERPRINT( + CONCAT( + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`rowindex` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`bool_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`bytes_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`date_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`datetime_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(st_astext(`t1`.`geography_col`), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`int64_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`int64_too` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`numeric_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`float64_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`rowindex` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`rowindex_2` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(`t1`.`string_col`, ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`time_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`timestamp_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`duration_col` AS STRING), ''), '\\', '\\\\')) + ) + ) AS STRING), + CAST(FARM_FINGERPRINT( + CONCAT( + CONCAT( + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`rowindex` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`bool_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`bytes_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`date_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`datetime_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(st_astext(`t1`.`geography_col`), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`int64_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`int64_too` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`numeric_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`float64_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`rowindex` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`rowindex_2` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(`t1`.`string_col`, ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`time_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`timestamp_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`t1`.`duration_col` AS STRING), ''), '\\', '\\\\')) + ), + '_' + ) + ) AS STRING), + CAST(RAND() AS STRING) + ) AS `row_key` +FROM ( + SELECT + * + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_sql_scalar_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_sql_scalar_op/out.sql index 611cbf4e7e..ccfe1b5a47 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_sql_scalar_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_sql_scalar_op/out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `bytes_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(`bool_col` AS INT64) + BYTE_LENGTH(`bytes_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `bool_col` -FROM `bfcte_1` \ No newline at end of file + CAST(`t0`.`bool_col` AS INT64) + BYTE_LENGTH(`t0`.`bytes_col`) AS `bool_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_where/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_where/out.sql index 872c794333..a5dba8f5c1 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_where/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_where/out.sql @@ -1,15 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - IF(`bool_col`, `int64_col`, `float64_col`) AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_3` AS `result_col` -FROM `bfcte_1` \ No newline at end of file + CASE WHEN `t0`.`bool_col` THEN `t0`.`int64_col` ELSE `t0`.`float64_col` END AS `result_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_area/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_area/out.sql index 105b5f1665..684faca220 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_area/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_area/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_AREA(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_area(`t0`.`geography_col`) AS `geography_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_astext/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_astext/out.sql index c338baeb5f..8aa1d9d1f9 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_astext/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_astext/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_ASTEXT(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_astext(`t0`.`geography_col`) AS `geography_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_boundary/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_boundary/out.sql index 2d4ac2e960..8d23a150dd 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_boundary/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_boundary/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_BOUNDARY(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_boundary(`t1`.`geography_col`) AS `geography_col` +FROM ( + SELECT + `t0`.`geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_buffer/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_buffer/out.sql index 84b3ab1600..0137882f07 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_buffer/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_buffer/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_BUFFER(`geography_col`, 1.0, 8.0, FALSE) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_buffer(`t1`.`geography_col`, 1.0, 8.0, FALSE) AS `geography_col` +FROM ( + SELECT + `t0`.`geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_centroid/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_centroid/out.sql index 733f1e9495..9eee7dbcb6 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_centroid/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_centroid/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_CENTROID(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_centroid(`t0`.`geography_col`) AS `geography_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_convexhull/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_convexhull/out.sql index 11b3b7f691..2a49d0a89b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_convexhull/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_convexhull/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_CONVEXHULL(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_convexhull(`t1`.`geography_col`) AS `geography_col` +FROM ( + SELECT + `t0`.`geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_difference/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_difference/out.sql index 4e18216dda..05b101f700 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_difference/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_difference/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_DIFFERENCE(`geography_col`, `geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_difference(`t0`.`geography_col`, `t0`.`geography_col`) AS `geography_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogfromtext/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogfromtext/out.sql index 1bbb114349..2dd49a93da 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogfromtext/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogfromtext/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SAFE.ST_GEOGFROMTEXT(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + st_geogfromtext(`t1`.`string_col`) AS `string_col` +FROM ( + SELECT + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_isclosed/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_isclosed/out.sql index 516f175c13..8f68760b10 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_isclosed/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_isclosed/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_ISCLOSED(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_isclosed(`t1`.`geography_col`) AS `geography_col` +FROM ( + SELECT + `t0`.`geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_length/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_length/out.sql index 80eef1c906..269c962f3e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_length/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_length/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_LENGTH(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_length(`t1`.`geography_col`, TRUE) AS `geography_col` +FROM ( + SELECT + `t0`.`geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_x/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_x/out.sql index 09211270d1..91893d0b11 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_x/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_x/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SAFE.ST_X(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_x(`t0`.`geography_col`) AS `geography_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_y/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_y/out.sql index 625613ae2a..d8733ebee3 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_y/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_y/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SAFE.ST_Y(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_y(`t0`.`geography_col`) AS `geography_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_extract/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_extract/out.sql index 435ee96df1..c085b80120 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_extract/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_extract/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_EXTRACT(`json_col`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_EXTRACT(`t1`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `t0`.`json_col` + FROM `bigframes-dev.sqlglot_test.json_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_extract_array/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_extract_array/out.sql index 6c9c02594d..dc70b47e6c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_extract_array/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_extract_array/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_EXTRACT_ARRAY(`json_col`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_EXTRACT_ARRAY(`t1`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `t0`.`json_col` + FROM `bigframes-dev.sqlglot_test.json_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_extract_string_array/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_extract_string_array/out.sql index a3a51be378..8cac1d81e4 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_extract_string_array/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_extract_string_array/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_EXTRACT_STRING_ARRAY(`json_col`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + json_extract_string_array(`t1`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `t0`.`json_col` + FROM `bigframes-dev.sqlglot_test.json_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_query/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_query/out.sql index 164fe2e426..fa4c3d178c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_query/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_query/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_QUERY(`json_col`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + json_query(`t1`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `t0`.`json_col` + FROM `bigframes-dev.sqlglot_test.json_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_query_array/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_query_array/out.sql index 4c3fa8e7e9..983c1e9e12 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_query_array/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_query_array/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_QUERY_ARRAY(`json_col`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + json_query_array(`t1`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `t0`.`json_col` + FROM `bigframes-dev.sqlglot_test.json_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_set/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_set/out.sql index f41979ea2e..62bd358600 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_set/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_set/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_SET(`json_col`, '$.a', 100) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_SET(`t1`.`json_col`, '$.a', 100) AS `json_col` +FROM ( + SELECT + `t0`.`json_col` + FROM `bigframes-dev.sqlglot_test.json_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_value/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_value/out.sql index 72f7237240..d7b3317dbb 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_value/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_value/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_VALUE(`json_col`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + json_value(`t1`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `t0`.`json_col` + FROM `bigframes-dev.sqlglot_test.json_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_parse_json/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_parse_json/out.sql index 5f80187ba0..581cadeb5d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_parse_json/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_parse_json/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - PARSE_JSON(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + PARSE_JSON(`t1`.`string_col`) AS `string_col` +FROM ( + SELECT + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_to_json_string/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_to_json_string/out.sql index e282c89c80..ab2cc98d03 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_to_json_string/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_to_json_string/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - TO_JSON_STRING(`json_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + to_json_string(`t1`.`json_col`) AS `json_col` +FROM ( + SELECT + `t0`.`json_col` + FROM `bigframes-dev.sqlglot_test.json_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_abs/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_abs/out.sql index 0fb9589387..00b441e86c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_abs/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_abs/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ABS(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + ABS(`t0`.`float64_col`) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_numeric/out.sql index 1707aad8c1..782e5cf48f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` + `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` + 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` + CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) + `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_add_int`, - `bfcol_40` AS `int_add_1`, - `bfcol_41` AS `int_add_bool`, - `bfcol_42` AS `bool_add_int` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + `t0`.`int64_col` + `t0`.`int64_col` AS `int_add_int`, + `t0`.`int64_col` + 1 AS `int_add_1`, + `t0`.`int64_col` + CAST(`t0`.`bool_col` AS INT64) AS `int_add_bool`, + CAST(`t0`.`bool_col` AS INT64) + `t0`.`int64_col` AS `bool_add_int` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_string/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_string/out.sql index cb674787ff..ebdec70eed 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_string/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_string/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CONCAT(`string_col`, 'a') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CONCAT(`t0`.`string_col`, 'a') AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_timedelta/out.sql index 2fef18eeb8..0670fac9a0 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_timedelta/out.sql @@ -1,60 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `timestamp_col` AS `bfcol_7`, - `date_col` AS `bfcol_8`, - TIMESTAMP_ADD(CAST(`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - TIMESTAMP_ADD(`bfcol_7`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - TIMESTAMP_ADD(CAST(`bfcol_16` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - TIMESTAMP_ADD(`bfcol_25`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_42` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - 172800000000 AS `bfcol_50` - FROM `bfcte_4` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `timestamp_col`, - `bfcol_38` AS `date_col`, - `bfcol_39` AS `date_add_timedelta`, - `bfcol_40` AS `timestamp_add_timedelta`, - `bfcol_41` AS `timedelta_add_date`, - `bfcol_42` AS `timedelta_add_timestamp`, - `bfcol_50` AS `timedelta_add_timedelta` -FROM `bfcte_5` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`timestamp_col`, + `t0`.`date_col`, + TIMESTAMP_ADD(CAST(`t0`.`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `date_add_timedelta`, + TIMESTAMP_ADD(`t0`.`timestamp_col`, INTERVAL 86400000000 MICROSECOND) AS `timestamp_add_timedelta`, + TIMESTAMP_ADD(CAST(`t0`.`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_date`, + TIMESTAMP_ADD(`t0`.`timestamp_col`, INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_timestamp`, + 172800000000 AS `timedelta_add_timedelta` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arccos/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arccos/out.sql index bb1766adf3..5793fff44f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arccos/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arccos/out.sql @@ -1,17 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`float64_col`) > 1 - THEN CAST('NaN' AS FLOAT64) - ELSE ACOS(`float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ABS(`t0`.`float64_col`) <= 1 + ), + CAST('NaN' AS FLOAT64), + ACOS(`t0`.`float64_col`) + ) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arccosh/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arccosh/out.sql index af556b9c3a..1849069c61 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arccosh/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arccosh/out.sql @@ -1,17 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `float64_col` < 1 - THEN CAST('NaN' AS FLOAT64) - ELSE ACOSH(`float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + `t0`.`float64_col` >= 1 + ), + CAST('NaN' AS FLOAT64), + LN(`t0`.`float64_col` + SQRT(( + `t0`.`float64_col` * `t0`.`float64_col` + ) - 1)) + ) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arcsin/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arcsin/out.sql index 8243232e0b..5d84730f5c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arcsin/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arcsin/out.sql @@ -1,17 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`float64_col`) > 1 - THEN CAST('NaN' AS FLOAT64) - ELSE ASIN(`float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ABS(`t0`.`float64_col`) <= 1 + ), + CAST('NaN' AS FLOAT64), + ASIN(`t0`.`float64_col`) + ) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arcsinh/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arcsinh/out.sql index e6bf3b339c..7747757e86 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arcsinh/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arcsinh/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ASINH(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + LN( + ABS(`t0`.`float64_col`) + SQRT(( + `t0`.`float64_col` * `t0`.`float64_col` + ) + 1) + ) * SIGN(`t0`.`float64_col`) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan/out.sql index a85ff6403c..81add822e0 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ATAN(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + ATAN(`t0`.`float64_col`) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan2/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan2/out.sql index 28fc8c869d..bac125d279 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan2/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan2/out.sql @@ -1,17 +1,4 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ATAN2(`int64_col`, `float64_col`) AS `bfcol_6`, - ATAN2(CAST(`bool_col` AS INT64), `float64_col`) AS `bfcol_7` - FROM `bfcte_0` -) SELECT - `bfcol_6` AS `int64_col`, - `bfcol_7` AS `bool_col` -FROM `bfcte_1` \ No newline at end of file + ATAN2(`t0`.`int64_col`, `t0`.`float64_col`) AS `int64_col`, + ATAN2(`t0`.`bool_col`, `t0`.`float64_col`) AS `bool_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctanh/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctanh/out.sql index 197bf59306..b6f9b371dc 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctanh/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctanh/out.sql @@ -1,17 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`float64_col`) > 1 - THEN CAST('NaN' AS FLOAT64) - ELSE ATANH(`float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ABS(`t0`.`float64_col`) < 1 + ), + IF( + ABS(`t0`.`float64_col`) = 1, + CAST('Infinity' AS FLOAT64) * `t0`.`float64_col`, + CAST('NaN' AS FLOAT64) + ), + ieee_divide(LN(ieee_divide(`t0`.`float64_col` + 1, 1 - `t0`.`float64_col`)), 2) + ) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_ceil/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_ceil/out.sql index 922fe5c550..0bfa23f95e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_ceil/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_ceil/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CEIL(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CEIL(`t1`.`float64_col`) AS `float64_col` +FROM ( + SELECT + `t0`.`float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cos/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cos/out.sql index 0acb2bfa94..ce32af15cf 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cos/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cos/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COS(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + COS(`t0`.`float64_col`) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosh/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosh/out.sql index 8c84a25047..11a385d8c3 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosh/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosh/out.sql @@ -1,17 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`float64_col`) > 709.78 - THEN CAST('Infinity' AS FLOAT64) - ELSE COSH(`float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ABS(`t0`.`float64_col`) < 709.78 + ), + CAST('Infinity' AS FLOAT64), + ieee_divide(EXP(`t0`.`float64_col`) + EXP(-( + `t0`.`float64_col` + )), 2) + ) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosine_distance/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosine_distance/out.sql index ba6b6bfa9f..4dc27d2d16 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosine_distance/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosine_distance/out.sql @@ -1,16 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float_list_col`, - `int_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ML.DISTANCE(`int_list_col`, `int_list_col`, 'COSINE') AS `bfcol_2`, - ML.DISTANCE(`float_list_col`, `float_list_col`, 'COSINE') AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int_list_col`, - `bfcol_3` AS `float_list_col` -FROM `bfcte_1` \ No newline at end of file + `ML.DISTANCE`(`t1`.`int_list_col`, `t1`.`int_list_col`, 'COSINE') AS `int_list_col`, + `ML.DISTANCE`(`t1`.`float_list_col`, `t1`.`float_list_col`, 'COSINE') AS `float_list_col` +FROM ( + SELECT + `t0`.`int_list_col`, + `t0`.`float_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_div_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_div_numeric/out.sql index db11f1529f..121d9fd7c4 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_div_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_div_numeric/out.sql @@ -1,122 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_8`, - `int64_col` AS `bfcol_9`, - `bool_col` AS `bfcol_10`, - `float64_col` AS `bfcol_11`, - IEEE_DIVIDE(`int64_col`, `int64_col`) AS `bfcol_12` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_8` AS `bfcol_18`, - `bfcol_9` AS `bfcol_19`, - `bfcol_10` AS `bfcol_20`, - `bfcol_11` AS `bfcol_21`, - `bfcol_12` AS `bfcol_22`, - IEEE_DIVIDE(`bfcol_9`, 1) AS `bfcol_23` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_18` AS `bfcol_30`, - `bfcol_19` AS `bfcol_31`, - `bfcol_20` AS `bfcol_32`, - `bfcol_21` AS `bfcol_33`, - `bfcol_22` AS `bfcol_34`, - `bfcol_23` AS `bfcol_35`, - IEEE_DIVIDE(`bfcol_19`, 0.0) AS `bfcol_36` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_30` AS `bfcol_44`, - `bfcol_31` AS `bfcol_45`, - `bfcol_32` AS `bfcol_46`, - `bfcol_33` AS `bfcol_47`, - `bfcol_34` AS `bfcol_48`, - `bfcol_35` AS `bfcol_49`, - `bfcol_36` AS `bfcol_50`, - IEEE_DIVIDE(`bfcol_31`, `bfcol_33`) AS `bfcol_51` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - `bfcol_44` AS `bfcol_60`, - `bfcol_45` AS `bfcol_61`, - `bfcol_46` AS `bfcol_62`, - `bfcol_47` AS `bfcol_63`, - `bfcol_48` AS `bfcol_64`, - `bfcol_49` AS `bfcol_65`, - `bfcol_50` AS `bfcol_66`, - `bfcol_51` AS `bfcol_67`, - IEEE_DIVIDE(`bfcol_47`, `bfcol_45`) AS `bfcol_68` - FROM `bfcte_4` -), `bfcte_6` AS ( - SELECT - *, - `bfcol_60` AS `bfcol_78`, - `bfcol_61` AS `bfcol_79`, - `bfcol_62` AS `bfcol_80`, - `bfcol_63` AS `bfcol_81`, - `bfcol_64` AS `bfcol_82`, - `bfcol_65` AS `bfcol_83`, - `bfcol_66` AS `bfcol_84`, - `bfcol_67` AS `bfcol_85`, - `bfcol_68` AS `bfcol_86`, - IEEE_DIVIDE(`bfcol_63`, 0.0) AS `bfcol_87` - FROM `bfcte_5` -), `bfcte_7` AS ( - SELECT - *, - `bfcol_78` AS `bfcol_98`, - `bfcol_79` AS `bfcol_99`, - `bfcol_80` AS `bfcol_100`, - `bfcol_81` AS `bfcol_101`, - `bfcol_82` AS `bfcol_102`, - `bfcol_83` AS `bfcol_103`, - `bfcol_84` AS `bfcol_104`, - `bfcol_85` AS `bfcol_105`, - `bfcol_86` AS `bfcol_106`, - `bfcol_87` AS `bfcol_107`, - IEEE_DIVIDE(`bfcol_79`, CAST(`bfcol_80` AS INT64)) AS `bfcol_108` - FROM `bfcte_6` -), `bfcte_8` AS ( - SELECT - *, - `bfcol_98` AS `bfcol_120`, - `bfcol_99` AS `bfcol_121`, - `bfcol_100` AS `bfcol_122`, - `bfcol_101` AS `bfcol_123`, - `bfcol_102` AS `bfcol_124`, - `bfcol_103` AS `bfcol_125`, - `bfcol_104` AS `bfcol_126`, - `bfcol_105` AS `bfcol_127`, - `bfcol_106` AS `bfcol_128`, - `bfcol_107` AS `bfcol_129`, - `bfcol_108` AS `bfcol_130`, - IEEE_DIVIDE(CAST(`bfcol_100` AS INT64), `bfcol_99`) AS `bfcol_131` - FROM `bfcte_7` -) SELECT - `bfcol_120` AS `rowindex`, - `bfcol_121` AS `int64_col`, - `bfcol_122` AS `bool_col`, - `bfcol_123` AS `float64_col`, - `bfcol_124` AS `int_div_int`, - `bfcol_125` AS `int_div_1`, - `bfcol_126` AS `int_div_0`, - `bfcol_127` AS `int_div_float`, - `bfcol_128` AS `float_div_int`, - `bfcol_129` AS `float_div_0`, - `bfcol_130` AS `int_div_bool`, - `bfcol_131` AS `bool_div_int` -FROM `bfcte_8` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + `t0`.`float64_col`, + ieee_divide(`t0`.`int64_col`, `t0`.`int64_col`) AS `int_div_int`, + ieee_divide(`t0`.`int64_col`, 1) AS `int_div_1`, + ieee_divide(`t0`.`int64_col`, 0.0) AS `int_div_0`, + ieee_divide(`t0`.`int64_col`, `t0`.`float64_col`) AS `int_div_float`, + ieee_divide(`t0`.`float64_col`, `t0`.`int64_col`) AS `float_div_int`, + ieee_divide(`t0`.`float64_col`, 0.0) AS `float_div_0`, + ieee_divide(`t0`.`int64_col`, CAST(`t0`.`bool_col` AS INT64)) AS `int_div_bool`, + ieee_divide(CAST(`t0`.`bool_col` AS INT64), `t0`.`int64_col`) AS `bool_div_int` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_div_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_div_timedelta/out.sql index 1a82a67368..b5e51fe010 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_div_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_div_timedelta/out.sql @@ -1,21 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `timestamp_col` AS `bfcol_7`, - `int64_col` AS `bfcol_8`, - CAST(FLOOR(IEEE_DIVIDE(86400000000, `int64_col`)) AS INT64) AS `bfcol_9` - FROM `bfcte_0` -) SELECT - `bfcol_6` AS `rowindex`, - `bfcol_7` AS `timestamp_col`, - `bfcol_8` AS `int64_col`, - `bfcol_9` AS `timedelta_div_numeric` -FROM `bfcte_1` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`timestamp_col`, + `t0`.`int64_col`, + CAST(FLOOR(ieee_divide(86400000000, `t0`.`int64_col`)) AS INT64) AS `timedelta_div_numeric` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_euclidean_distance/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_euclidean_distance/out.sql index 3327a99f4b..13505c7212 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_euclidean_distance/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_euclidean_distance/out.sql @@ -1,16 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `int_list_col`, - `numeric_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ML.DISTANCE(`int_list_col`, `int_list_col`, 'EUCLIDEAN') AS `bfcol_2`, - ML.DISTANCE(`numeric_list_col`, `numeric_list_col`, 'EUCLIDEAN') AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int_list_col`, - `bfcol_3` AS `numeric_list_col` -FROM `bfcte_1` \ No newline at end of file + `ML.DISTANCE`(`t1`.`int_list_col`, `t1`.`int_list_col`, 'EUCLIDEAN') AS `int_list_col`, + `ML.DISTANCE`(`t1`.`numeric_list_col`, `t1`.`numeric_list_col`, 'EUCLIDEAN') AS `numeric_list_col` +FROM ( + SELECT + `t0`.`int_list_col`, + `t0`.`numeric_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_exp/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_exp/out.sql index 610b96cda7..b14171e01d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_exp/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_exp/out.sql @@ -1,17 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `float64_col` > 709.78 - THEN CAST('Infinity' AS FLOAT64) - ELSE EXP(`float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + `t0`.`float64_col` < 709.78 + ), + CAST('Infinity' AS FLOAT64), + EXP(`t0`.`float64_col`) + ) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_expm1/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_expm1/out.sql index 076ad584c2..159c8de0bb 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_expm1/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_expm1/out.sql @@ -1,17 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `float64_col` > 709.78 - THEN CAST('Infinity' AS FLOAT64) - ELSE EXP(`float64_col`) - END - 1 AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + `t0`.`float64_col` < 709.78 + ), + CAST('Infinity' AS FLOAT64), + EXP(`t0`.`float64_col`) + ) - 1 AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_floor/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_floor/out.sql index e0c2e1072e..fb5fb1a618 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_floor/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_floor/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FLOOR(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + FLOOR(`t1`.`float64_col`) AS `float64_col` +FROM ( + SELECT + `t0`.`float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_floordiv_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_floordiv_timedelta/out.sql index 2fe20fb618..bd04d7f4fe 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_floordiv_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_floordiv_timedelta/out.sql @@ -1,18 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - 43200000000 AS `bfcol_6` - FROM `bfcte_0` -) SELECT - `rowindex`, - `timestamp_col`, - `date_col`, - `bfcol_6` AS `timedelta_div_numeric` -FROM `bfcte_1` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`timestamp_col`, + `t0`.`date_col`, + 43200000000 AS `timedelta_div_numeric` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_ln/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_ln/out.sql index 776cc33e0f..5d88590efa 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_ln/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_ln/out.sql @@ -1,13 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `float64_col` <= 0 THEN CAST('NaN' AS FLOAT64) ELSE LN(`float64_col`) END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + `t0`.`float64_col` > 0 + ), + IF(`t0`.`float64_col` = 0, CAST('-Infinity' AS FLOAT64), CAST('NaN' AS FLOAT64)), + LN(`t0`.`float64_col`) + ) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_log10/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_log10/out.sql index 11a318c22d..cc01fc196f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_log10/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_log10/out.sql @@ -1,17 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `float64_col` <= 0 - THEN CAST('NaN' AS FLOAT64) - ELSE LOG(10, `float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + `t0`.`float64_col` > 0 + ), + IF(`t0`.`float64_col` = 0, CAST('-Infinity' AS FLOAT64), CAST('NaN' AS FLOAT64)), + LOG(`t0`.`float64_col`, 10) + ) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_log1p/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_log1p/out.sql index 4297fff227..878da9b96b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_log1p/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_log1p/out.sql @@ -1,17 +1,17 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `float64_col` <= -1 - THEN CAST('NaN' AS FLOAT64) - ELSE LN(1 + `float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ( + 1 + `t0`.`float64_col` + ) > 0 + ), + IF( + ( + 1 + `t0`.`float64_col` + ) = 0, + CAST('-Infinity' AS FLOAT64), + CAST('NaN' AS FLOAT64) + ), + LN(1 + `t0`.`float64_col`) + ) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mod_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mod_numeric/out.sql index 241ffa0b5e..7907bb5fc7 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mod_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mod_numeric/out.sql @@ -1,292 +1,222 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `float64_col` AS `bfcol_8`, - CASE - WHEN `int64_col` = CAST(0 AS INT64) - THEN CAST(0 AS INT64) * `int64_col` - WHEN `int64_col` < CAST(0 AS INT64) - AND ( - MOD(`int64_col`, `int64_col`) - ) > CAST(0 AS INT64) - THEN `int64_col` + ( - MOD(`int64_col`, `int64_col`) - ) - WHEN `int64_col` > CAST(0 AS INT64) - AND ( - MOD(`int64_col`, `int64_col`) - ) < CAST(0 AS INT64) - THEN `int64_col` + ( - MOD(`int64_col`, `int64_col`) - ) - ELSE MOD(`int64_col`, `int64_col`) - END AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - CASE - WHEN -( - `bfcol_7` - ) = CAST(0 AS INT64) - THEN CAST(0 AS INT64) * `bfcol_7` - WHEN -( - `bfcol_7` - ) < CAST(0 AS INT64) - AND ( - MOD(`bfcol_7`, -( - `bfcol_7` - )) - ) > CAST(0 AS INT64) - THEN -( - `bfcol_7` - ) + ( - MOD(`bfcol_7`, -( - `bfcol_7` - )) - ) - WHEN -( - `bfcol_7` - ) > CAST(0 AS INT64) - AND ( - MOD(`bfcol_7`, -( - `bfcol_7` +SELECT + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`float64_col`, + CASE + WHEN `t0`.`int64_col` = 0 + THEN 0 * `t0`.`int64_col` + WHEN ( + `t0`.`int64_col` < 0 + ) + AND ( + ( + MOD(`t0`.`int64_col`, `t0`.`int64_col`) + ) > 0 + ) + THEN `t0`.`int64_col` + ( + MOD(`t0`.`int64_col`, `t0`.`int64_col`) + ) + WHEN ( + `t0`.`int64_col` > 0 + ) + AND ( + ( + MOD(`t0`.`int64_col`, `t0`.`int64_col`) + ) < 0 + ) + THEN `t0`.`int64_col` + ( + MOD(`t0`.`int64_col`, `t0`.`int64_col`) + ) + ELSE MOD(`t0`.`int64_col`, `t0`.`int64_col`) + END AS `int_mod_int`, + CASE + WHEN -( + `t0`.`int64_col` + ) = 0 + THEN 0 * `t0`.`int64_col` + WHEN ( + -( + `t0`.`int64_col` + ) < 0 + ) + AND ( + ( + MOD(`t0`.`int64_col`, -( + `t0`.`int64_col` )) - ) < CAST(0 AS INT64) - THEN -( - `bfcol_7` - ) + ( - MOD(`bfcol_7`, -( - `bfcol_7` + ) > 0 + ) + THEN -( + `t0`.`int64_col` + ) + ( + MOD(`t0`.`int64_col`, -( + `t0`.`int64_col` + )) + ) + WHEN ( + -( + `t0`.`int64_col` + ) > 0 + ) + AND ( + ( + MOD(`t0`.`int64_col`, -( + `t0`.`int64_col` )) - ) - ELSE MOD(`bfcol_7`, -( - `bfcol_7` + ) < 0 + ) + THEN -( + `t0`.`int64_col` + ) + ( + MOD(`t0`.`int64_col`, -( + `t0`.`int64_col` )) - END AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - CASE - WHEN 1 = CAST(0 AS INT64) - THEN CAST(0 AS INT64) * `bfcol_15` - WHEN 1 < CAST(0 AS INT64) AND ( - MOD(`bfcol_15`, 1) - ) > CAST(0 AS INT64) - THEN 1 + ( - MOD(`bfcol_15`, 1) - ) - WHEN 1 > CAST(0 AS INT64) AND ( - MOD(`bfcol_15`, 1) - ) < CAST(0 AS INT64) - THEN 1 + ( - MOD(`bfcol_15`, 1) - ) - ELSE MOD(`bfcol_15`, 1) - END AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CASE - WHEN 0 = CAST(0 AS INT64) - THEN CAST(0 AS INT64) * `bfcol_25` - WHEN 0 < CAST(0 AS INT64) AND ( - MOD(`bfcol_25`, 0) - ) > CAST(0 AS INT64) - THEN 0 + ( - MOD(`bfcol_25`, 0) - ) - WHEN 0 > CAST(0 AS INT64) AND ( - MOD(`bfcol_25`, 0) - ) < CAST(0 AS INT64) - THEN 0 + ( - MOD(`bfcol_25`, 0) - ) - ELSE MOD(`bfcol_25`, 0) - END AS `bfcol_42` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - `bfcol_36` AS `bfcol_50`, - `bfcol_37` AS `bfcol_51`, - `bfcol_38` AS `bfcol_52`, - `bfcol_39` AS `bfcol_53`, - `bfcol_40` AS `bfcol_54`, - `bfcol_41` AS `bfcol_55`, - `bfcol_42` AS `bfcol_56`, - CASE - WHEN CAST(`bfcol_38` AS BIGNUMERIC) = CAST(0 AS INT64) - THEN CAST('NaN' AS FLOAT64) * CAST(`bfcol_38` AS BIGNUMERIC) - WHEN CAST(`bfcol_38` AS BIGNUMERIC) < CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_38` AS BIGNUMERIC), CAST(`bfcol_38` AS BIGNUMERIC)) - ) > CAST(0 AS INT64) - THEN CAST(`bfcol_38` AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_38` AS BIGNUMERIC), CAST(`bfcol_38` AS BIGNUMERIC)) - ) - WHEN CAST(`bfcol_38` AS BIGNUMERIC) > CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_38` AS BIGNUMERIC), CAST(`bfcol_38` AS BIGNUMERIC)) - ) < CAST(0 AS INT64) - THEN CAST(`bfcol_38` AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_38` AS BIGNUMERIC), CAST(`bfcol_38` AS BIGNUMERIC)) - ) - ELSE MOD(CAST(`bfcol_38` AS BIGNUMERIC), CAST(`bfcol_38` AS BIGNUMERIC)) - END AS `bfcol_57` - FROM `bfcte_4` -), `bfcte_6` AS ( - SELECT - *, - `bfcol_50` AS `bfcol_66`, - `bfcol_51` AS `bfcol_67`, - `bfcol_52` AS `bfcol_68`, - `bfcol_53` AS `bfcol_69`, - `bfcol_54` AS `bfcol_70`, - `bfcol_55` AS `bfcol_71`, - `bfcol_56` AS `bfcol_72`, - `bfcol_57` AS `bfcol_73`, - CASE - WHEN CAST(-( - `bfcol_52` - ) AS BIGNUMERIC) = CAST(0 AS INT64) - THEN CAST('NaN' AS FLOAT64) * CAST(`bfcol_52` AS BIGNUMERIC) - WHEN CAST(-( - `bfcol_52` - ) AS BIGNUMERIC) < CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-( - `bfcol_52` - ) AS BIGNUMERIC)) - ) > CAST(0 AS INT64) - THEN CAST(-( - `bfcol_52` - ) AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-( - `bfcol_52` - ) AS BIGNUMERIC)) - ) - WHEN CAST(-( - `bfcol_52` - ) AS BIGNUMERIC) > CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-( - `bfcol_52` - ) AS BIGNUMERIC)) - ) < CAST(0 AS INT64) - THEN CAST(-( - `bfcol_52` - ) AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-( - `bfcol_52` - ) AS BIGNUMERIC)) - ) - ELSE MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-( - `bfcol_52` - ) AS BIGNUMERIC)) - END AS `bfcol_74` - FROM `bfcte_5` -), `bfcte_7` AS ( - SELECT - *, - `bfcol_66` AS `bfcol_84`, - `bfcol_67` AS `bfcol_85`, - `bfcol_68` AS `bfcol_86`, - `bfcol_69` AS `bfcol_87`, - `bfcol_70` AS `bfcol_88`, - `bfcol_71` AS `bfcol_89`, - `bfcol_72` AS `bfcol_90`, - `bfcol_73` AS `bfcol_91`, - `bfcol_74` AS `bfcol_92`, - CASE - WHEN CAST(1 AS BIGNUMERIC) = CAST(0 AS INT64) - THEN CAST('NaN' AS FLOAT64) * CAST(`bfcol_68` AS BIGNUMERIC) - WHEN CAST(1 AS BIGNUMERIC) < CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_68` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) - ) > CAST(0 AS INT64) - THEN CAST(1 AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_68` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) - ) - WHEN CAST(1 AS BIGNUMERIC) > CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_68` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) - ) < CAST(0 AS INT64) - THEN CAST(1 AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_68` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) - ) - ELSE MOD(CAST(`bfcol_68` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) - END AS `bfcol_93` - FROM `bfcte_6` -), `bfcte_8` AS ( - SELECT - *, - `bfcol_84` AS `bfcol_104`, - `bfcol_85` AS `bfcol_105`, - `bfcol_86` AS `bfcol_106`, - `bfcol_87` AS `bfcol_107`, - `bfcol_88` AS `bfcol_108`, - `bfcol_89` AS `bfcol_109`, - `bfcol_90` AS `bfcol_110`, - `bfcol_91` AS `bfcol_111`, - `bfcol_92` AS `bfcol_112`, - `bfcol_93` AS `bfcol_113`, - CASE - WHEN CAST(0 AS BIGNUMERIC) = CAST(0 AS INT64) - THEN CAST('NaN' AS FLOAT64) * CAST(`bfcol_86` AS BIGNUMERIC) - WHEN CAST(0 AS BIGNUMERIC) < CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_86` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) - ) > CAST(0 AS INT64) - THEN CAST(0 AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_86` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) - ) - WHEN CAST(0 AS BIGNUMERIC) > CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_86` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) - ) < CAST(0 AS INT64) - THEN CAST(0 AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_86` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) - ) - ELSE MOD(CAST(`bfcol_86` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) - END AS `bfcol_114` - FROM `bfcte_7` -) -SELECT - `bfcol_104` AS `rowindex`, - `bfcol_105` AS `int64_col`, - `bfcol_106` AS `float64_col`, - `bfcol_107` AS `int_mod_int`, - `bfcol_108` AS `int_mod_int_neg`, - `bfcol_109` AS `int_mod_1`, - `bfcol_110` AS `int_mod_0`, - `bfcol_111` AS `float_mod_float`, - `bfcol_112` AS `float_mod_float_neg`, - `bfcol_113` AS `float_mod_1`, - `bfcol_114` AS `float_mod_0` -FROM `bfcte_8` \ No newline at end of file + ) + ELSE MOD(`t0`.`int64_col`, -( + `t0`.`int64_col` + )) + END AS `int_mod_int_neg`, + CASE + WHEN 1 = 0 + THEN 0 * `t0`.`int64_col` + WHEN ( + 1 < 0 + ) AND ( + ( + MOD(`t0`.`int64_col`, 1) + ) > 0 + ) + THEN 1 + ( + MOD(`t0`.`int64_col`, 1) + ) + WHEN ( + 1 > 0 + ) AND ( + ( + MOD(`t0`.`int64_col`, 1) + ) < 0 + ) + THEN 1 + ( + MOD(`t0`.`int64_col`, 1) + ) + ELSE MOD(`t0`.`int64_col`, 1) + END AS `int_mod_1`, + CAST(NULL AS INT64) AS `int_mod_0`, + CAST(CASE + WHEN CAST(`t0`.`float64_col` AS BIGNUMERIC) = 0 + THEN CAST('NaN' AS FLOAT64) * CAST(`t0`.`float64_col` AS BIGNUMERIC) + WHEN ( + CAST(`t0`.`float64_col` AS BIGNUMERIC) < 0 + ) + AND ( + ( + MOD(CAST(`t0`.`float64_col` AS BIGNUMERIC), CAST(`t0`.`float64_col` AS BIGNUMERIC)) + ) > 0 + ) + THEN CAST(`t0`.`float64_col` AS BIGNUMERIC) + ( + MOD(CAST(`t0`.`float64_col` AS BIGNUMERIC), CAST(`t0`.`float64_col` AS BIGNUMERIC)) + ) + WHEN ( + CAST(`t0`.`float64_col` AS BIGNUMERIC) > 0 + ) + AND ( + ( + MOD(CAST(`t0`.`float64_col` AS BIGNUMERIC), CAST(`t0`.`float64_col` AS BIGNUMERIC)) + ) < 0 + ) + THEN CAST(`t0`.`float64_col` AS BIGNUMERIC) + ( + MOD(CAST(`t0`.`float64_col` AS BIGNUMERIC), CAST(`t0`.`float64_col` AS BIGNUMERIC)) + ) + ELSE MOD(CAST(`t0`.`float64_col` AS BIGNUMERIC), CAST(`t0`.`float64_col` AS BIGNUMERIC)) + END AS FLOAT64) AS `float_mod_float`, + CAST(CASE + WHEN CAST(-( + `t0`.`float64_col` + ) AS BIGNUMERIC) = 0 + THEN CAST('NaN' AS FLOAT64) * CAST(`t0`.`float64_col` AS BIGNUMERIC) + WHEN ( + CAST(-( + `t0`.`float64_col` + ) AS BIGNUMERIC) < 0 + ) + AND ( + ( + MOD( + CAST(`t0`.`float64_col` AS BIGNUMERIC), + CAST(-( + `t0`.`float64_col` + ) AS BIGNUMERIC) + ) + ) > 0 + ) + THEN CAST(-( + `t0`.`float64_col` + ) AS BIGNUMERIC) + ( + MOD( + CAST(`t0`.`float64_col` AS BIGNUMERIC), + CAST(-( + `t0`.`float64_col` + ) AS BIGNUMERIC) + ) + ) + WHEN ( + CAST(-( + `t0`.`float64_col` + ) AS BIGNUMERIC) > 0 + ) + AND ( + ( + MOD( + CAST(`t0`.`float64_col` AS BIGNUMERIC), + CAST(-( + `t0`.`float64_col` + ) AS BIGNUMERIC) + ) + ) < 0 + ) + THEN CAST(-( + `t0`.`float64_col` + ) AS BIGNUMERIC) + ( + MOD( + CAST(`t0`.`float64_col` AS BIGNUMERIC), + CAST(-( + `t0`.`float64_col` + ) AS BIGNUMERIC) + ) + ) + ELSE MOD( + CAST(`t0`.`float64_col` AS BIGNUMERIC), + CAST(-( + `t0`.`float64_col` + ) AS BIGNUMERIC) + ) + END AS FLOAT64) AS `float_mod_float_neg`, + CAST(CASE + WHEN CAST(1 AS BIGNUMERIC) = 0 + THEN CAST('NaN' AS FLOAT64) * CAST(`t0`.`float64_col` AS BIGNUMERIC) + WHEN ( + CAST(1 AS BIGNUMERIC) < 0 + ) + AND ( + ( + MOD(CAST(`t0`.`float64_col` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) + ) > 0 + ) + THEN CAST(1 AS BIGNUMERIC) + ( + MOD(CAST(`t0`.`float64_col` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) + ) + WHEN ( + CAST(1 AS BIGNUMERIC) > 0 + ) + AND ( + ( + MOD(CAST(`t0`.`float64_col` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) + ) < 0 + ) + THEN CAST(1 AS BIGNUMERIC) + ( + MOD(CAST(`t0`.`float64_col` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) + ) + ELSE MOD(CAST(`t0`.`float64_col` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) + END AS FLOAT64) AS `float_mod_1`, + CAST(NULL AS FLOAT64) AS `float_mod_0` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_numeric/out.sql index d0c537e482..6e2add636b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` * `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` * 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` * CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) * `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_mul_int`, - `bfcol_40` AS `int_mul_1`, - `bfcol_41` AS `int_mul_bool`, - `bfcol_42` AS `bool_mul_int` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + `t0`.`int64_col` * `t0`.`int64_col` AS `int_mul_int`, + `t0`.`int64_col` * 1 AS `int_mul_1`, + `t0`.`int64_col` * CAST(`t0`.`bool_col` AS INT64) AS `int_mul_bool`, + CAST(`t0`.`bool_col` AS INT64) * `t0`.`int64_col` AS `bool_mul_int` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_timedelta/out.sql index ebdf296b2b..6dc56b29b8 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_timedelta/out.sql @@ -1,43 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `duration_col`, - `int64_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_8`, - `timestamp_col` AS `bfcol_9`, - `int64_col` AS `bfcol_10`, - `duration_col` AS `bfcol_11` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_10` AS `bfcol_18`, - `bfcol_11` AS `bfcol_19`, - CAST(FLOOR(`bfcol_11` * `bfcol_10`) AS INT64) AS `bfcol_20` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_19` AS `bfcol_29`, - `bfcol_20` AS `bfcol_30`, - CAST(FLOOR(`bfcol_18` * `bfcol_19`) AS INT64) AS `bfcol_31` - FROM `bfcte_2` -) SELECT - `bfcol_26` AS `rowindex`, - `bfcol_27` AS `timestamp_col`, - `bfcol_28` AS `int64_col`, - `bfcol_29` AS `duration_col`, - `bfcol_30` AS `timedelta_mul_numeric`, - `bfcol_31` AS `numeric_mul_timedelta` -FROM `bfcte_3` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`timestamp_col`, + `t0`.`int64_col`, + CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64) AS `duration_col`, + CAST(FLOOR(CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64) * `t0`.`int64_col`) AS INT64) AS `timedelta_mul_numeric`, + CAST(FLOOR(`t0`.`int64_col` * CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64)) AS INT64) AS `numeric_mul_timedelta` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_neg/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_neg/out.sql index 4374af349b..e08a6e49f1 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_neg/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_neg/out.sql @@ -1,15 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - -( - `float64_col` - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + -( + `t0`.`float64_col` + ) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pos/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pos/out.sql index 1ed016029a..0b71d304d6 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pos/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pos/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `float64_col` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_round/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_round/out.sql index 9ce76f7c63..ddfec39992 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_round/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_round/out.sql @@ -1,81 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `float64_col` AS `bfcol_8`, - CAST(ROUND(`int64_col`, 0) AS INT64) AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - CAST(ROUND(`bfcol_7`, 1) AS INT64) AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - CAST(ROUND(`bfcol_15`, -1) AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - ROUND(`bfcol_26`, 0) AS `bfcol_42` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - `bfcol_36` AS `bfcol_50`, - `bfcol_37` AS `bfcol_51`, - `bfcol_38` AS `bfcol_52`, - `bfcol_39` AS `bfcol_53`, - `bfcol_40` AS `bfcol_54`, - `bfcol_41` AS `bfcol_55`, - `bfcol_42` AS `bfcol_56`, - ROUND(`bfcol_38`, 1) AS `bfcol_57` - FROM `bfcte_4` -), `bfcte_6` AS ( - SELECT - *, - `bfcol_50` AS `bfcol_66`, - `bfcol_51` AS `bfcol_67`, - `bfcol_52` AS `bfcol_68`, - `bfcol_53` AS `bfcol_69`, - `bfcol_54` AS `bfcol_70`, - `bfcol_55` AS `bfcol_71`, - `bfcol_56` AS `bfcol_72`, - `bfcol_57` AS `bfcol_73`, - ROUND(`bfcol_52`, -1) AS `bfcol_74` - FROM `bfcte_5` -) SELECT - `bfcol_66` AS `rowindex`, - `bfcol_67` AS `int64_col`, - `bfcol_68` AS `float64_col`, - `bfcol_69` AS `int_round_0`, - `bfcol_70` AS `int_round_1`, - `bfcol_71` AS `int_round_m1`, - `bfcol_72` AS `float_round_0`, - `bfcol_73` AS `float_round_1`, - `bfcol_74` AS `float_round_m1` -FROM `bfcte_6` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`float64_col`, + CAST(trunc(ROUND(`t0`.`int64_col`, 0)) AS INT64) AS `int_round_0`, + CAST(trunc(ROUND(`t0`.`int64_col`, 1)) AS INT64) AS `int_round_1`, + CAST(trunc(ROUND(`t0`.`int64_col`, -1)) AS INT64) AS `int_round_m1`, + ROUND(`t0`.`float64_col`, 0) AS `float_round_0`, + ROUND(`t0`.`float64_col`, 1) AS `float_round_1`, + ROUND(`t0`.`float64_col`, -1) AS `float_round_m1` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sin/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sin/out.sql index 1699b6d8df..9bccc3c6fe 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sin/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sin/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SIN(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + SIN(`t0`.`float64_col`) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sinh/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sinh/out.sql index c1ea003e2d..97abc38f2e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sinh/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sinh/out.sql @@ -1,17 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`float64_col`) > 709.78 - THEN SIGN(`float64_col`) * CAST('Infinity' AS FLOAT64) - ELSE SINH(`float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ABS(`t0`.`float64_col`) < 709.78 + ), + CAST('Infinity' AS FLOAT64) * SIGN(`t0`.`float64_col`), + ieee_divide(EXP(`t0`.`float64_col`) - EXP(-( + `t0`.`float64_col` + )), 2) + ) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sqrt/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sqrt/out.sql index 152545d550..928c82ee5b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sqrt/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sqrt/out.sql @@ -1,13 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `float64_col` < 0 THEN CAST('NaN' AS FLOAT64) ELSE SQRT(`float64_col`) END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF(NOT ( + `t0`.`float64_col` >= 0 + ), CAST('NaN' AS FLOAT64), SQRT(`t0`.`float64_col`)) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_numeric/out.sql index 7e0f07af7b..8199a031f9 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` - `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` - 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` - CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) - `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_add_int`, - `bfcol_40` AS `int_add_1`, - `bfcol_41` AS `int_add_bool`, - `bfcol_42` AS `bool_add_int` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + `t0`.`int64_col` - `t0`.`int64_col` AS `int_add_int`, + `t0`.`int64_col` - 1 AS `int_add_1`, + `t0`.`int64_col` - CAST(`t0`.`bool_col` AS INT64) AS `int_add_bool`, + CAST(`t0`.`bool_col` AS INT64) - `t0`.`int64_col` AS `bool_add_int` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_timedelta/out.sql index ebcffd67f6..f643fb8f26 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_timedelta/out.sql @@ -1,82 +1,17 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `duration_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_8`, - `timestamp_col` AS `bfcol_9`, - `date_col` AS `bfcol_10`, - `duration_col` AS `bfcol_11` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_11` AS `bfcol_18`, - `bfcol_10` AS `bfcol_19`, - TIMESTAMP_SUB(CAST(`bfcol_10` AS DATETIME), INTERVAL `bfcol_11` MICROSECOND) AS `bfcol_20` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_19` AS `bfcol_29`, - `bfcol_20` AS `bfcol_30`, - TIMESTAMP_SUB(`bfcol_17`, INTERVAL `bfcol_18` MICROSECOND) AS `bfcol_31` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - `bfcol_30` AS `bfcol_42`, - `bfcol_31` AS `bfcol_43`, - TIMESTAMP_DIFF(CAST(`bfcol_29` AS DATETIME), CAST(`bfcol_29` AS DATETIME), MICROSECOND) AS `bfcol_44` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - `bfcol_38` AS `bfcol_52`, - `bfcol_39` AS `bfcol_53`, - `bfcol_40` AS `bfcol_54`, - `bfcol_41` AS `bfcol_55`, - `bfcol_42` AS `bfcol_56`, - `bfcol_43` AS `bfcol_57`, - `bfcol_44` AS `bfcol_58`, - TIMESTAMP_DIFF(`bfcol_39`, `bfcol_39`, MICROSECOND) AS `bfcol_59` - FROM `bfcte_4` -), `bfcte_6` AS ( - SELECT - *, - `bfcol_52` AS `bfcol_68`, - `bfcol_53` AS `bfcol_69`, - `bfcol_54` AS `bfcol_70`, - `bfcol_55` AS `bfcol_71`, - `bfcol_56` AS `bfcol_72`, - `bfcol_57` AS `bfcol_73`, - `bfcol_58` AS `bfcol_74`, - `bfcol_59` AS `bfcol_75`, - `bfcol_54` - `bfcol_54` AS `bfcol_76` - FROM `bfcte_5` -) SELECT - `bfcol_68` AS `rowindex`, - `bfcol_69` AS `timestamp_col`, - `bfcol_70` AS `duration_col`, - `bfcol_71` AS `date_col`, - `bfcol_72` AS `date_sub_timedelta`, - `bfcol_73` AS `timestamp_sub_timedelta`, - `bfcol_74` AS `timestamp_sub_date`, - `bfcol_75` AS `date_sub_timestamp`, - `bfcol_76` AS `timedelta_sub_timedelta` -FROM `bfcte_6` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`timestamp_col`, + CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64) AS `duration_col`, + `t0`.`date_col`, + TIMESTAMP_SUB( + CAST(`t0`.`date_col` AS DATETIME), + INTERVAL (CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64)) MICROSECOND + ) AS `date_sub_timedelta`, + TIMESTAMP_SUB( + `t0`.`timestamp_col`, + INTERVAL (CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64)) MICROSECOND + ) AS `timestamp_sub_timedelta`, + DATE_DIFF(`t0`.`date_col`, `t0`.`date_col`, DAY) * 86400000000 AS `timestamp_sub_date`, + TIMESTAMP_DIFF(`t0`.`timestamp_col`, `t0`.`timestamp_col`, MICROSECOND) AS `date_sub_timestamp`, + CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64) - CAST(FLOOR(`t0`.`duration_col` * 1) AS INT64) AS `timedelta_sub_timedelta` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_tan/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_tan/out.sql index f09d26a188..88f6f2cc58 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_tan/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_tan/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TAN(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + TAN(`t0`.`float64_col`) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_tanh/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_tanh/out.sql index a5e5a87fbc..fbd89ac47a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_tanh/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_tanh/out.sql @@ -1,13 +1,16 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TANH(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ABS(`t0`.`float64_col`) < 20 + ), + SIGN(`t0`.`float64_col`), + ieee_divide( + EXP(`t0`.`float64_col`) - EXP(-( + `t0`.`float64_col` + )), + EXP(`t0`.`float64_col`) + EXP(-( + `t0`.`float64_col` + )) + ) + ) AS `float64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_add_string/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_add_string/out.sql index cb674787ff..ebdec70eed 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_add_string/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_add_string/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CONCAT(`string_col`, 'a') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CONCAT(`t0`.`string_col`, 'a') AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_capitalize/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_capitalize/out.sql index b429007ffc..824a1d521d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_capitalize/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_capitalize/out.sql @@ -1,13 +1,18 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - INITCAP(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CONCAT( + UPPER( + SUBSTRING(`t0`.`string_col`, IF(( + 0 + 1 + ) >= 1, 0 + 1, 0 + 1 + LENGTH(`t0`.`string_col`)), 1) + ), + LOWER( + SUBSTRING( + `t0`.`string_col`, + IF(( + 1 + 1 + ) >= 1, 1 + 1, 1 + 1 + LENGTH(`t0`.`string_col`)), + LENGTH(`t0`.`string_col`) + ) + ) + ) AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_endswith/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_endswith/out.sql index eeb2574094..45f50b9d4d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_endswith/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_endswith/out.sql @@ -1,17 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ENDS_WITH(`string_col`, 'ab') AS `bfcol_1`, - ENDS_WITH(`string_col`, 'ab') OR ENDS_WITH(`string_col`, 'cd') AS `bfcol_2`, - FALSE AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `single`, - `bfcol_2` AS `double`, - `bfcol_3` AS `empty` -FROM `bfcte_1` \ No newline at end of file + ENDS_WITH(`t0`.`string_col`, 'ab') AS `single`, + ENDS_WITH(`t0`.`string_col`, 'ab') OR ENDS_WITH(`t0`.`string_col`, 'cd') AS `double`, + FALSE AS `empty` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isalnum/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isalnum/out.sql index 61c2643f16..2b8254929a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isalnum/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isalnum/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`string_col`, '^(\\p{N}|\\p{L})+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '^(\\p{N}|\\p{Lm}|\\p{Lt}|\\p{Lu}|\\p{Ll}|\\p{Lo})+$') AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isalpha/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isalpha/out.sql index 2b086f3e3d..63b73b399e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isalpha/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isalpha/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`string_col`, '^\\p{L}+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '^(\\p{Lm}|\\p{Lt}|\\p{Lu}|\\p{Ll}|\\p{Lo})+$') AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isdecimal/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isdecimal/out.sql index 7355ab7aa7..fe68642182 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isdecimal/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isdecimal/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`string_col`, '^\\d+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '^(\\p{Nd})+$') AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isdigit/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isdigit/out.sql index d7dd8c0729..056674ac9a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isdigit/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isdigit/out.sql @@ -1,13 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`string_col`, '^\\p{Nd}+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains( + `t0`.`string_col`, + '^[\\p{Nd}\\x{00B9}\\x{00B2}\\x{00B3}\\x{2070}\\x{2074}-\\x{2079}\\x{2080}-\\x{2089}]+$' + ) AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_islower/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_islower/out.sql index b6ff57797c..f0fd996c68 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_islower/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_islower/out.sql @@ -1,13 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LOWER(`string_col`) = `string_col` AND UPPER(`string_col`) <> `string_col` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '\\p{Ll}') + AND NOT ( + regexp_contains(`t0`.`string_col`, '\\p{Lu}|\\p{Lt}') + ) AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isnumeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isnumeric/out.sql index 6143b3685a..c5ce5e1def 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isnumeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isnumeric/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`string_col`, '^\\pN+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '^(\\pN+)$') AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isspace/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isspace/out.sql index 47ccd642d4..c3e23887ae 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isspace/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isspace/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`string_col`, '^\\s+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '^\\s+$') AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isupper/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isupper/out.sql index 54f7b55ce3..c313f95674 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isupper/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isupper/out.sql @@ -1,13 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UPPER(`string_col`) = `string_col` AND LOWER(`string_col`) <> `string_col` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '\\p{Lu}') + AND NOT ( + regexp_contains(`t0`.`string_col`, '\\p{Ll}|\\p{Lt}') + ) AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len/out.sql index 63e8e160bf..24d02e7a82 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LENGTH(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + LENGTH(`t0`.`string_col`) AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_lower/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_lower/out.sql index 0a9623162a..adb0abb11c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_lower/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_lower/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LOWER(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + LOWER(`t0`.`string_col`) AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_lstrip/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_lstrip/out.sql index ebe4c39bbf..19e962745d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_lstrip/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_lstrip/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TRIM(`string_col`, ' ') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + LTRIM(`t1`.`string_col`, ' ') AS `string_col` +FROM ( + SELECT + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_regex_replace_str/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_regex_replace_str/out.sql index 2fd3365a80..d5cbf731a5 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_regex_replace_str/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_regex_replace_str/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_REPLACE(`string_col`, 'e', 'a') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REGEXP_REPLACE(`t0`.`string_col`, 'e', 'a') AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_replace_str/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_replace_str/out.sql index 61b2e2f432..b3ac03b2d9 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_replace_str/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_replace_str/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REPLACE(`string_col`, 'e', 'a') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REPLACE(`t0`.`string_col`, 'e', 'a') AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_reverse/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_reverse/out.sql index f9d287a591..ecf2bf376e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_reverse/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_reverse/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REVERSE(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REVERSE(`t0`.`string_col`) AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_rstrip/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_rstrip/out.sql index ebe4c39bbf..b3b3597f31 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_rstrip/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_rstrip/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TRIM(`string_col`, ' ') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + RTRIM(`t1`.`string_col`, ' ') AS `string_col` +FROM ( + SELECT + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_startswith/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_startswith/out.sql index 54c8adb7b8..97be6ccd93 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_startswith/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_startswith/out.sql @@ -1,17 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - STARTS_WITH(`string_col`, 'ab') AS `bfcol_1`, - STARTS_WITH(`string_col`, 'ab') OR STARTS_WITH(`string_col`, 'cd') AS `bfcol_2`, - FALSE AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `single`, - `bfcol_2` AS `double`, - `bfcol_3` AS `empty` -FROM `bfcte_1` \ No newline at end of file + STARTS_WITH(`t0`.`string_col`, 'ab') AS `single`, + STARTS_WITH(`t0`.`string_col`, 'ab') OR STARTS_WITH(`t0`.`string_col`, 'cd') AS `double`, + FALSE AS `empty` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_contains/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_contains/out.sql index e973a97136..5f21bd2161 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_contains/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_contains/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `string_col` LIKE '%e%' AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + INSTR(`t0`.`string_col`, 'e') > 0 AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_contains_regex/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_contains_regex/out.sql index 510e52e254..797ccb8292 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_contains_regex/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_contains_regex/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`string_col`, 'e') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, 'e') AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_extract/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_extract/out.sql index 3e59f617ac..6dd306afc7 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_extract/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_extract/out.sql @@ -1,13 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_EXTRACT(`string_col`, '([a-z]*)') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + IF( + regexp_contains(`t0`.`string_col`, '([a-z]*)'), + IF( + 1 = 0, + REGEXP_REPLACE(`t0`.`string_col`, CONCAT('.*?', CONCAT('(', '([a-z]*)', ')'), '.*'), '\\1'), + REGEXP_REPLACE(`t0`.`string_col`, CONCAT('.*?', '([a-z]*)', '.*'), CONCAT('\\', CAST(1 AS STRING))) + ), + NULL + ) AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_get/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_get/out.sql index b2a08e0e9d..6fa2ba7cbc 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_get/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_get/out.sql @@ -1,13 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SUBSTRING(`string_col`, 2, 1) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + NULLIF( + SUBSTRING(`t0`.`string_col`, IF(( + 1 + 1 + ) >= 1, 1 + 1, 1 + 1 + LENGTH(`t0`.`string_col`)), 1), + '' + ) AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_pad/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_pad/out.sql index 5f157bc5cb..22024bba91 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_pad/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_pad/out.sql @@ -1,25 +1,17 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LPAD(`string_col`, GREATEST(LENGTH(`string_col`), 10), '-') AS `bfcol_1`, - RPAD(`string_col`, GREATEST(LENGTH(`string_col`), 10), '-') AS `bfcol_2`, - RPAD( - LPAD( - `string_col`, - CAST(SAFE_DIVIDE(GREATEST(LENGTH(`string_col`), 10) - LENGTH(`string_col`), 2) AS INT64) + LENGTH(`string_col`), - '-' - ), - GREATEST(LENGTH(`string_col`), 10), - '-' - ) AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `left`, - `bfcol_2` AS `right`, - `bfcol_3` AS `both` -FROM `bfcte_1` \ No newline at end of file + LPAD(`t0`.`string_col`, GREATEST(LENGTH(`t0`.`string_col`), 10), '-') AS `left`, + RPAD(`t0`.`string_col`, GREATEST(LENGTH(`t0`.`string_col`), 10), '-') AS `right`, + RPAD( + LPAD( + `t0`.`string_col`, + ( + CAST(FLOOR( + ieee_divide(GREATEST(LENGTH(`t0`.`string_col`), 10) - LENGTH(`t0`.`string_col`), 2) + ) AS INT64) + ) + LENGTH(`t0`.`string_col`), + '-' + ), + GREATEST(LENGTH(`t0`.`string_col`), 10), + '-' + ) AS `both` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_repeat/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_repeat/out.sql index 90a52a40b1..8577b9cfc9 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_repeat/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_repeat/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REPEAT(`string_col`, 2) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REPEAT(`t0`.`string_col`, 2) AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_slice/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_slice/out.sql index 8bd2a5f7fe..fa67fb9f80 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_slice/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_slice/out.sql @@ -1,13 +1,16 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SUBSTRING(`string_col`, 2, 2) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + SUBSTRING( + `t0`.`string_col`, + IF( + ( + IF(1 >= 0, 1, GREATEST(0, LENGTH(`t0`.`string_col`) + 1)) + 1 + ) >= 1, + IF(1 >= 0, 1, GREATEST(0, LENGTH(`t0`.`string_col`) + 1)) + 1, + IF(1 >= 0, 1, GREATEST(0, LENGTH(`t0`.`string_col`) + 1)) + 1 + LENGTH(`t0`.`string_col`) + ), + GREATEST( + 0, + IF(3 >= 0, 3, GREATEST(0, LENGTH(`t0`.`string_col`) + 3)) - IF(1 >= 0, 1, GREATEST(0, LENGTH(`t0`.`string_col`) + 1)) + ) + ) AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strconcat/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strconcat/out.sql index cb674787ff..ebdec70eed 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strconcat/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strconcat/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CONCAT(`string_col`, 'a') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CONCAT(`t0`.`string_col`, 'a') AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_string_split/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_string_split/out.sql index 37b15a0cf9..6014bd9b34 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_string_split/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_string_split/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SPLIT(`string_col`, ',') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + SPLIT(`t0`.`string_col`, ',') AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strip/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strip/out.sql index 771bb9c49f..a4781b21fc 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strip/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strip/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TRIM(' ', `string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + TRIM(`t1`.`string_col`, ' ') AS `string_col` +FROM ( + SELECT + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_upper/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_upper/out.sql index aa14c5f05d..27ac52e78d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_upper/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_upper/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UPPER(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + UPPER(`t0`.`string_col`) AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_zfill/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_zfill/out.sql index 97651ece49..f768c62c22 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_zfill/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_zfill/out.sql @@ -1,17 +1,25 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN SUBSTRING(`string_col`, 1, 1) = '-' - THEN CONCAT('-', LPAD(SUBSTRING(`string_col`, 1), 9, '0')) - ELSE LPAD(`string_col`, 10, '0') - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN SUBSTRING(`t0`.`string_col`, IF(( + 0 + 1 + ) >= 1, 0 + 1, 0 + 1 + LENGTH(`t0`.`string_col`)), 1) = '-' + THEN CONCAT( + '-', + LPAD( + SUBSTRING(`t0`.`string_col`, IF(( + 1 + 1 + ) >= 1, 1 + 1, 1 + 1 + LENGTH(`t0`.`string_col`))), + GREATEST( + LENGTH( + SUBSTRING(`t0`.`string_col`, IF(( + 1 + 1 + ) >= 1, 1 + 1, 1 + 1 + LENGTH(`t0`.`string_col`))) + ), + 9 + ), + '0' + ) + ) + ELSE LPAD(`t0`.`string_col`, GREATEST(LENGTH(`t0`.`string_col`), 10), '0') + END AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_field/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_field/out.sql index b85e88a90a..99128904cc 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_field/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_field/out.sql @@ -1,15 +1,4 @@ -WITH `bfcte_0` AS ( - SELECT - `people` - FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` -), `bfcte_1` AS ( - SELECT - *, - `people`.`name` AS `bfcol_1`, - `people`.`name` AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string`, - `bfcol_2` AS `int` -FROM `bfcte_1` \ No newline at end of file + `t0`.`people`.`name` AS `string`, + `t0`.`people`.`name` AS `int` +FROM `bigframes-dev.sqlglot_test.nested_structs_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_op/out.sql index 575a162080..9cecc317bd 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_op/out.sql @@ -1,21 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - STRUCT( - `bool_col` AS bool_col, - `int64_col` AS int64_col, - `float64_col` AS float64_col, - `string_col` AS string_col - ) AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `result_col` -FROM `bfcte_1` \ No newline at end of file + STRUCT( + `t0`.`bool_col` AS `bool_col`, + `t0`.`int64_col` AS `int64_col`, + `t0`.`float64_col` AS `float64_col`, + `t0`.`string_col` AS `string_col` + ) AS `result_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_timedelta_ops/test_timedelta_floor/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_timedelta_ops/test_timedelta_floor/out.sql index 432aefd7f6..f708741639 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_timedelta_ops/test_timedelta_floor/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_timedelta_ops/test_timedelta_floor/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FLOOR(`int64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + CAST(FLOOR(`t0`.`int64_col`) AS INT64) AS `int64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_timedelta_ops/test_to_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_timedelta_ops/test_to_timedelta/out.sql index 3c75cc3e89..043ec0f7ab 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_timedelta_ops/test_to_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_timedelta_ops/test_to_timedelta/out.sql @@ -1,37 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_4`, - `int64_col` AS `bfcol_5`, - `int64_col` AS `bfcol_6` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_4` AS `bfcol_10`, - `bfcol_5` AS `bfcol_11`, - `bfcol_6` AS `bfcol_12`, - `bfcol_5` * 1000000 AS `bfcol_13` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_10` AS `bfcol_18`, - `bfcol_11` AS `bfcol_19`, - `bfcol_12` AS `bfcol_20`, - `bfcol_13` AS `bfcol_21`, - `bfcol_11` * 604800000000 AS `bfcol_22` - FROM `bfcte_2` -) SELECT - `bfcol_18` AS `rowindex`, - `bfcol_19` AS `int64_col`, - `bfcol_20` AS `duration_us`, - `bfcol_21` AS `duration_s`, - `bfcol_22` AS `duration_w` -FROM `bfcte_3` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + CAST(FLOOR(`t0`.`int64_col` * 1) AS INT64) AS `duration_us`, + CAST(FLOOR(`t0`.`int64_col` * 1000000) AS INT64) AS `duration_s`, + CAST(FLOOR(`t0`.`int64_col` * 604800000000) AS INT64) AS `duration_w` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate/out.sql index 949ed82574..914d9f15d1 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate/out.sql @@ -1,27 +1,25 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `int64_too` AS `bfcol_2`, - `bool_col` AS `bfcol_3` - FROM `bfcte_0` -), `bfcte_2` AS ( +SELECT +`bool_col` AS `bool_col`, +`int64_too` AS `int64_too` +FROM +(SELECT + `t2`.`bfuid_col_1142` AS `bool_col`, + `t2`.`bfuid_col_1143` AS `int64_too` +FROM ( SELECT - `bfcol_3`, - COALESCE(SUM(`bfcol_2`), 0) AS `bfcol_6` - FROM `bfcte_1` - WHERE - NOT `bfcol_3` IS NULL + `t1`.`bfuid_col_1142`, + COALESCE(SUM(`t1`.`bfuid_col_1141`), 0) AS `bfuid_col_1143` + FROM ( + SELECT + `t0`.`int64_too` AS `bfuid_col_1141`, + `t0`.`bool_col` AS `bfuid_col_1142` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` GROUP BY - `bfcol_3` -) -SELECT - `bfcol_3` AS `bool_col`, - `bfcol_6` AS `int64_too` -FROM `bfcte_2` -ORDER BY - `bfcol_3` ASC NULLS LAST \ No newline at end of file + 1 +) AS `t2` +WHERE + ( + `t2`.`bfuid_col_1142` + ) IS NOT NULL) +ORDER BY `bool_col` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate_wo_dropna/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate_wo_dropna/out.sql index 3c09250858..037df4bf5a 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate_wo_dropna/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate_wo_dropna/out.sql @@ -1,25 +1,21 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `int64_too` AS `bfcol_2`, - `bool_col` AS `bfcol_3` - FROM `bfcte_0` -), `bfcte_2` AS ( +SELECT +`bool_col` AS `bool_col`, +`int64_too` AS `int64_too` +FROM +(SELECT + `t2`.`bfuid_col_1146` AS `bool_col`, + `t2`.`bfuid_col_1147` AS `int64_too` +FROM ( SELECT - `bfcol_3`, - COALESCE(SUM(`bfcol_2`), 0) AS `bfcol_6` - FROM `bfcte_1` + `t1`.`bfuid_col_1146`, + COALESCE(SUM(`t1`.`bfuid_col_1145`), 0) AS `bfuid_col_1147` + FROM ( + SELECT + `t0`.`int64_too` AS `bfuid_col_1145`, + `t0`.`bool_col` AS `bfuid_col_1146` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t1` GROUP BY - `bfcol_3` -) -SELECT - `bfcol_3` AS `bool_col`, - `bfcol_6` AS `int64_too` -FROM `bfcte_2` -ORDER BY - `bfcol_3` ASC NULLS LAST \ No newline at end of file + 1 +) AS `t2`) +ORDER BY `bool_col` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat/out.sql index f606de4ed3..4a862c2a04 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat/out.sql @@ -1,82 +1,61 @@ -WITH `bfcte_1` AS ( - SELECT - `int64_col`, - `rowindex`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( - SELECT - *, - ROW_NUMBER() OVER () AS `bfcol_7` - FROM `bfcte_1` -), `bfcte_5` AS ( - SELECT - *, - 0 AS `bfcol_8` - FROM `bfcte_3` -), `bfcte_6` AS ( - SELECT - `rowindex` AS `bfcol_9`, - `rowindex` AS `bfcol_10`, - `int64_col` AS `bfcol_11`, - `string_col` AS `bfcol_12`, - `bfcol_8` AS `bfcol_13`, - `bfcol_7` AS `bfcol_14` - FROM `bfcte_5` -), `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - *, - ROW_NUMBER() OVER () AS `bfcol_22` - FROM `bfcte_0` -), `bfcte_4` AS ( - SELECT - *, - 1 AS `bfcol_23` - FROM `bfcte_2` -), `bfcte_7` AS ( - SELECT - `rowindex` AS `bfcol_24`, - `rowindex` AS `bfcol_25`, - `int64_col` AS `bfcol_26`, - `string_col` AS `bfcol_27`, - `bfcol_23` AS `bfcol_28`, - `bfcol_22` AS `bfcol_29` - FROM `bfcte_4` -), `bfcte_8` AS ( +SELECT +`rowindex` AS `rowindex`, +`rowindex_1` AS `rowindex_1`, +`int64_col` AS `int64_col`, +`string_col` AS `string_col` +FROM +(WITH `t1` AS ( + SELECT + `t0`.`int64_col`, + `t0`.`rowindex`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) +SELECT + * +FROM ( SELECT * FROM ( SELECT - `bfcol_9` AS `bfcol_30`, - `bfcol_10` AS `bfcol_31`, - `bfcol_11` AS `bfcol_32`, - `bfcol_12` AS `bfcol_33`, - `bfcol_13` AS `bfcol_34`, - `bfcol_14` AS `bfcol_35` - FROM `bfcte_6` - UNION ALL + `t3`.`bfuid_col_1` AS `rowindex`, + `t3`.`rowindex` AS `rowindex_1`, + `t3`.`int64_col`, + `t3`.`string_col`, + `t3`.`bfuid_col_1153` AS `bfuid_col_1157`, + `t3`.`bfuid_col_1152` AS `bfuid_col_1156` + FROM ( + SELECT + `t2`.`rowindex` AS `bfuid_col_1`, + `t2`.`rowindex`, + `t2`.`int64_col`, + `t2`.`string_col`, + 0 AS `bfuid_col_1153`, + ROW_NUMBER() OVER (ORDER BY NULL ASC) - 1 AS `bfuid_col_1152` + FROM `t1` AS `t2` + ) AS `t3` + ) AS `t5` + UNION ALL + SELECT + * + FROM ( SELECT - `bfcol_24` AS `bfcol_30`, - `bfcol_25` AS `bfcol_31`, - `bfcol_26` AS `bfcol_32`, - `bfcol_27` AS `bfcol_33`, - `bfcol_28` AS `bfcol_34`, - `bfcol_29` AS `bfcol_35` - FROM `bfcte_7` - ) -) -SELECT - `bfcol_30` AS `rowindex`, - `bfcol_31` AS `rowindex_1`, - `bfcol_32` AS `int64_col`, - `bfcol_33` AS `string_col` -FROM `bfcte_8` -ORDER BY - `bfcol_34` ASC NULLS LAST, - `bfcol_35` ASC NULLS LAST \ No newline at end of file + `t4`.`bfuid_col_1` AS `rowindex`, + `t4`.`rowindex` AS `rowindex_1`, + `t4`.`int64_col`, + `t4`.`string_col`, + `t4`.`bfuid_col_1155` AS `bfuid_col_1157`, + `t4`.`bfuid_col_1154` AS `bfuid_col_1156` + FROM ( + SELECT + `t2`.`rowindex` AS `bfuid_col_1`, + `t2`.`rowindex`, + `t2`.`int64_col`, + `t2`.`string_col`, + 1 AS `bfuid_col_1155`, + ROW_NUMBER() OVER (ORDER BY NULL ASC) - 1 AS `bfuid_col_1154` + FROM `t1` AS `t2` + ) AS `t4` + ) AS `t6` +) AS `t7`) +ORDER BY `bfuid_col_1157` ASC NULLS LAST ,`bfuid_col_1156` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat_filter_sorted/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat_filter_sorted/out.sql index a67d1943a2..0779728602 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat_filter_sorted/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat_filter_sorted/out.sql @@ -1,142 +1,102 @@ -WITH `bfcte_2` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_6` AS ( - SELECT - *, - ROW_NUMBER() OVER (ORDER BY `int64_col` ASC NULLS LAST) AS `bfcol_4` - FROM `bfcte_2` -), `bfcte_10` AS ( - SELECT - *, - 0 AS `bfcol_5` - FROM `bfcte_6` -), `bfcte_13` AS ( - SELECT - `float64_col` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bfcol_5` AS `bfcol_8`, - `bfcol_4` AS `bfcol_9` - FROM `bfcte_10` -), `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_4` AS ( - SELECT - * - FROM `bfcte_0` - WHERE - `bool_col` -), `bfcte_8` AS ( - SELECT - *, - ROW_NUMBER() OVER () AS `bfcol_15` - FROM `bfcte_4` -), `bfcte_12` AS ( - SELECT - *, - 1 AS `bfcol_16` - FROM `bfcte_8` -), `bfcte_14` AS ( - SELECT - `float64_col` AS `bfcol_17`, - `int64_too` AS `bfcol_18`, - `bfcol_16` AS `bfcol_19`, - `bfcol_15` AS `bfcol_20` - FROM `bfcte_12` -), `bfcte_1` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_5` AS ( - SELECT - *, - ROW_NUMBER() OVER (ORDER BY `int64_col` ASC NULLS LAST) AS `bfcol_25` - FROM `bfcte_1` -), `bfcte_9` AS ( - SELECT - *, - 2 AS `bfcol_26` - FROM `bfcte_5` -), `bfcte_15` AS ( - SELECT - `float64_col` AS `bfcol_27`, - `int64_col` AS `bfcol_28`, - `bfcol_26` AS `bfcol_29`, - `bfcol_25` AS `bfcol_30` - FROM `bfcte_9` -), `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( - SELECT - * - FROM `bfcte_0` +SELECT +`float64_col` AS `float64_col`, +`int64_col` AS `int64_col` +FROM +(WITH `t1` AS ( + SELECT + `t0`.`int64_col`, + `t0`.`float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +), `t2` AS ( + SELECT + `t0`.`bool_col`, + `t0`.`int64_too`, + `t0`.`float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` WHERE - `bool_col` -), `bfcte_7` AS ( - SELECT - *, - ROW_NUMBER() OVER () AS `bfcol_36` - FROM `bfcte_3` -), `bfcte_11` AS ( - SELECT - *, - 3 AS `bfcol_37` - FROM `bfcte_7` -), `bfcte_16` AS ( - SELECT - `float64_col` AS `bfcol_38`, - `int64_too` AS `bfcol_39`, - `bfcol_37` AS `bfcol_40`, - `bfcol_36` AS `bfcol_41` - FROM `bfcte_11` -), `bfcte_17` AS ( + `t0`.`bool_col` +) +SELECT + * +FROM ( SELECT * FROM ( SELECT - `bfcol_6` AS `bfcol_42`, - `bfcol_7` AS `bfcol_43`, - `bfcol_8` AS `bfcol_44`, - `bfcol_9` AS `bfcol_45` - FROM `bfcte_13` + * + FROM ( + SELECT + `t9`.`float64_col`, + `t9`.`int64_col`, + `t9`.`bfuid_col_1161` AS `bfuid_col_1169`, + `t9`.`bfuid_col_1160` AS `bfuid_col_1168` + FROM ( + SELECT + `t3`.`float64_col`, + `t3`.`int64_col`, + 0 AS `bfuid_col_1161`, + ROW_NUMBER() OVER (ORDER BY `t3`.`int64_col` IS NULL ASC, `t3`.`int64_col` ASC) - 1 AS `bfuid_col_1160` + FROM `t1` AS `t3` + ) AS `t9` + ) AS `t11` UNION ALL SELECT - `bfcol_17` AS `bfcol_42`, - `bfcol_18` AS `bfcol_43`, - `bfcol_19` AS `bfcol_44`, - `bfcol_20` AS `bfcol_45` - FROM `bfcte_14` - UNION ALL + * + FROM ( + SELECT + `t5`.`float64_col`, + `t5`.`int64_too` AS `int64_col`, + `t5`.`bfuid_col_1163` AS `bfuid_col_1169`, + `t5`.`bfuid_col_1162` AS `bfuid_col_1168` + FROM ( + SELECT + `t4`.`float64_col`, + `t4`.`int64_too`, + 1 AS `bfuid_col_1163`, + ROW_NUMBER() OVER (ORDER BY NULL ASC) - 1 AS `bfuid_col_1162` + FROM `t2` AS `t4` + ) AS `t5` + ) AS `t7` + ) AS `t13` + UNION ALL + SELECT + * + FROM ( SELECT - `bfcol_27` AS `bfcol_42`, - `bfcol_28` AS `bfcol_43`, - `bfcol_29` AS `bfcol_44`, - `bfcol_30` AS `bfcol_45` - FROM `bfcte_15` + * + FROM ( + SELECT + `t10`.`float64_col`, + `t10`.`int64_col`, + `t10`.`bfuid_col_1165` AS `bfuid_col_1169`, + `t10`.`bfuid_col_1164` AS `bfuid_col_1168` + FROM ( + SELECT + `t3`.`float64_col`, + `t3`.`int64_col`, + 2 AS `bfuid_col_1165`, + ROW_NUMBER() OVER (ORDER BY `t3`.`int64_col` IS NULL ASC, `t3`.`int64_col` ASC) - 1 AS `bfuid_col_1164` + FROM `t1` AS `t3` + ) AS `t10` + ) AS `t12` UNION ALL SELECT - `bfcol_38` AS `bfcol_42`, - `bfcol_39` AS `bfcol_43`, - `bfcol_40` AS `bfcol_44`, - `bfcol_41` AS `bfcol_45` - FROM `bfcte_16` - ) -) -SELECT - `bfcol_42` AS `float64_col`, - `bfcol_43` AS `int64_col` -FROM `bfcte_17` -ORDER BY - `bfcol_44` ASC NULLS LAST, - `bfcol_45` ASC NULLS LAST \ No newline at end of file + * + FROM ( + SELECT + `t6`.`float64_col`, + `t6`.`int64_too` AS `int64_col`, + `t6`.`bfuid_col_1167` AS `bfuid_col_1169`, + `t6`.`bfuid_col_1166` AS `bfuid_col_1168` + FROM ( + SELECT + `t4`.`float64_col`, + `t4`.`int64_too`, + 3 AS `bfuid_col_1167`, + ROW_NUMBER() OVER (ORDER BY NULL ASC) - 1 AS `bfuid_col_1166` + FROM `t2` AS `t4` + ) AS `t6` + ) AS `t8` + ) AS `t14` +) AS `t15`) +ORDER BY `bfuid_col_1169` ASC NULLS LAST ,`bfuid_col_1168` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_dataframe/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_dataframe/out.sql index e594b67669..2379daaf23 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_dataframe/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_dataframe/out.sql @@ -1,21 +1,59 @@ -WITH `bfcte_0` AS ( - SELECT - `int_list_col`, - `rowindex`, - `string_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - * - REPLACE (`int_list_col`[SAFE_OFFSET(`bfcol_13`)] AS `int_list_col`, `string_list_col`[SAFE_OFFSET(`bfcol_13`)] AS `string_list_col`) - FROM `bfcte_0` - CROSS JOIN UNNEST(GENERATE_ARRAY(0, LEAST(ARRAY_LENGTH(`int_list_col`) - 1, ARRAY_LENGTH(`string_list_col`) - 1))) AS `bfcol_13` WITH OFFSET AS `bfcol_7` -) SELECT - `rowindex`, - `rowindex` AS `rowindex_1`, - `int_list_col`, - `string_list_col` -FROM `bfcte_1` -ORDER BY - `bfcol_7` ASC NULLS LAST \ No newline at end of file +`rowindex` AS `rowindex`, +`rowindex_1` AS `rowindex_1`, +`int_list_col` AS `int_list_col`, +`string_list_col` AS `string_list_col` +FROM +(SELECT + `t2`.`bfuid_col_26` AS `rowindex`, + `t2`.`rowindex` AS `rowindex_1`, + `t2`.`int_list_col`[safe_offset(`t2`.`bfuid_col_1173`)] AS `int_list_col`, + `t2`.`string_list_col`[safe_offset(`t2`.`bfuid_col_1173`)] AS `string_list_col`, + `t2`.`bfuid_col_1173` AS `bfuid_col_1174` +FROM ( + SELECT + IF(pos = pos_2, `bfuid_col_1173`, NULL) AS `bfuid_col_1173`, + `t1`.`bfuid_col_26`, + `t1`.`rowindex`, + `t1`.`int_list_col`, + `t1`.`string_list_col` + FROM ( + SELECT + IF( + NOT NULLIF(1, 0) IS NULL + AND SIGN(1) = SIGN( + GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`), ARRAY_LENGTH(`t0`.`string_list_col`))) - 0 + ), + ARRAY( + SELECT + ibis_bq_arr_range_35bkrvij2bfxdkztwtq3xo4yle + FROM UNNEST(generate_array( + 0, + GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`), ARRAY_LENGTH(`t0`.`string_list_col`))), + 1 + )) AS ibis_bq_arr_range_35bkrvij2bfxdkztwtq3xo4yle + WHERE + ibis_bq_arr_range_35bkrvij2bfxdkztwtq3xo4yle <> GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`), ARRAY_LENGTH(`t0`.`string_list_col`))) + ), + [] + ) AS `bfuid_offset_array_1175`, + `t0`.`rowindex` AS `bfuid_col_26`, + `t0`.`rowindex`, + `t0`.`int_list_col`, + `t0`.`string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` AS `t0` + ) AS `t1` + CROSS JOIN UNNEST(GENERATE_ARRAY(0, GREATEST(ARRAY_LENGTH(`t1`.`bfuid_offset_array_1175`)) - 1)) AS pos + CROSS JOIN UNNEST(`t1`.`bfuid_offset_array_1175`) AS `bfuid_col_1173` WITH OFFSET AS pos_2 + WHERE + pos = pos_2 + OR ( + pos > ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_1175`) - 1 + ) + AND pos_2 = ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_1175`) - 1 + ) + ) +) AS `t2`) +ORDER BY `bfuid_col_1174` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_series/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_series/out.sql index 5af0aa0092..37cfe8fa63 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_series/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_series/out.sql @@ -1,18 +1,45 @@ -WITH `bfcte_0` AS ( - SELECT - `int_list_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - * - REPLACE (`bfcol_8` AS `int_list_col`) - FROM `bfcte_0` - CROSS JOIN UNNEST(`int_list_col`) AS `bfcol_8` WITH OFFSET AS `bfcol_4` -) SELECT - `rowindex`, - `int_list_col` -FROM `bfcte_1` -ORDER BY - `bfcol_4` ASC NULLS LAST \ No newline at end of file +`rowindex` AS `rowindex`, +`int_list_col` AS `int_list_col` +FROM +(SELECT + `t2`.`bfuid_col_26` AS `rowindex`, + `t2`.`int_list_col`[safe_offset(`t2`.`bfuid_col_1170`)] AS `int_list_col`, + `t2`.`bfuid_col_1170` AS `bfuid_col_1171` +FROM ( + SELECT + IF(pos = pos_2, `bfuid_col_1170`, NULL) AS `bfuid_col_1170`, + `t1`.`bfuid_col_26`, + `t1`.`int_list_col` + FROM ( + SELECT + IF( + NOT NULLIF(1, 0) IS NULL + AND SIGN(1) = SIGN(GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`))) - 0), + ARRAY( + SELECT + ibis_bq_arr_range_li2ozhtdyfeklfr6d7ee6xjygq + FROM UNNEST(generate_array(0, GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`))), 1)) AS ibis_bq_arr_range_li2ozhtdyfeklfr6d7ee6xjygq + WHERE + ibis_bq_arr_range_li2ozhtdyfeklfr6d7ee6xjygq <> GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`))) + ), + [] + ) AS `bfuid_offset_array_1172`, + `t0`.`rowindex` AS `bfuid_col_26`, + `t0`.`int_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` AS `t0` + ) AS `t1` + CROSS JOIN UNNEST(GENERATE_ARRAY(0, GREATEST(ARRAY_LENGTH(`t1`.`bfuid_offset_array_1172`)) - 1)) AS pos + CROSS JOIN UNNEST(`t1`.`bfuid_offset_array_1172`) AS `bfuid_col_1170` WITH OFFSET AS pos_2 + WHERE + pos = pos_2 + OR ( + pos > ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_1172`) - 1 + ) + AND pos_2 = ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_1172`) - 1 + ) + ) +) AS `t2`) +ORDER BY `bfuid_col_1171` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_filter/test_compile_filter/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_filter/test_compile_filter/out.sql index f5fff16f60..d0ab658b69 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_filter/test_compile_filter/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_filter/test_compile_filter/out.sql @@ -1,25 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_5`, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `rowindex` >= 1 AS `bfcol_8` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - * - FROM `bfcte_1` - WHERE - `bfcol_8` -) SELECT - `bfcol_5` AS `rowindex`, - `bfcol_6` AS `rowindex_1`, - `bfcol_7` AS `int64_col` -FROM `bfcte_2` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`rowindex` AS `rowindex_1`, + `t0`.`int64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +WHERE + `t0`.`rowindex` >= 1 \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_isin/test_compile_isin/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_isin/test_compile_isin/out.sql index 77aef6ad8b..827b943ccb 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_isin/test_compile_isin/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_isin/test_compile_isin/out.sql @@ -1,41 +1,30 @@ -WITH `bfcte_1` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( - SELECT - `rowindex` AS `bfcol_2`, - `int64_col` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `int64_too` - FROM `bfcte_0` - GROUP BY - `int64_too` -), `bfcte_4` AS ( - SELECT - `bfcte_3`.*, - EXISTS( +SELECT + `t1`.`bfuid_col_1` AS `rowindex`, + EXISTS( + SELECT + 1 + FROM ( SELECT - 1 + `t2`.`int64_too` FROM ( SELECT - `int64_too` AS `bfcol_4` - FROM `bfcte_2` - ) AS `bft_0` - WHERE - COALESCE(`bfcte_3`.`bfcol_3`, 0) = COALESCE(`bft_0`.`bfcol_4`, 0) - AND COALESCE(`bfcte_3`.`bfcol_3`, 1) = COALESCE(`bft_0`.`bfcol_4`, 1) - ) AS `bfcol_5` - FROM `bfcte_3` -) -SELECT - `bfcol_2` AS `rowindex`, - `bfcol_5` AS `int64_col` -FROM `bfcte_4` \ No newline at end of file + `t0`.`int64_too` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t2` + GROUP BY + 1 + ) AS `t3` + WHERE + ( + COALESCE(`t1`.`int64_col`, 0) = COALESCE(`t3`.`int64_too`, 0) + ) + AND ( + COALESCE(`t1`.`int64_col`, 1) = COALESCE(`t3`.`int64_too`, 1) + ) + ) AS `int64_col` +FROM ( + SELECT + `t0`.`rowindex` AS `bfuid_col_1`, + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_isin/test_compile_isin_not_nullable/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_isin/test_compile_isin_not_nullable/out.sql index 8089c5b462..30e0dc2916 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_isin/test_compile_isin_not_nullable/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_isin/test_compile_isin_not_nullable/out.sql @@ -1,34 +1,23 @@ -WITH `bfcte_1` AS ( - SELECT - `rowindex`, - `rowindex_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( - SELECT - `rowindex` AS `bfcol_2`, - `rowindex_2` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `rowindex_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `rowindex_2` - FROM `bfcte_0` - GROUP BY - `rowindex_2` -), `bfcte_4` AS ( - SELECT - `bfcte_3`.*, - `bfcte_3`.`bfcol_3` IN (( - SELECT - `rowindex_2` AS `bfcol_4` - FROM `bfcte_2` - )) AS `bfcol_5` - FROM `bfcte_3` -) SELECT - `bfcol_2` AS `rowindex`, - `bfcol_5` AS `rowindex_2` -FROM `bfcte_4` \ No newline at end of file + `t1`.`bfuid_col_1` AS `rowindex`, + `t1`.`rowindex_2` IN ( + SELECT + * + FROM ( + SELECT + `t2`.`rowindex_2` + FROM ( + SELECT + `t0`.`rowindex_2` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + ) AS `t2` + GROUP BY + 1 + ) AS `t3` + ) AS `rowindex_2` +FROM ( + SELECT + `t0`.`rowindex` AS `bfuid_col_1`, + `t0`.`rowindex_2` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join/out.sql index 3a7ff60d3e..4f40156e95 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join/out.sql @@ -1,32 +1,17 @@ -WITH `bfcte_1` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `rowindex` AS `bfcol_2`, - `int64_col` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `int64_col`, - `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`int64_col`, + `t4`.`int64_too` +FROM ( SELECT - `int64_col` AS `bfcol_6`, - `int64_too` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex` AS `bfuid_col_1`, + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t3` +LEFT OUTER JOIN ( SELECT - * - FROM `bfcte_2` - LEFT JOIN `bfcte_3` - ON COALESCE(`bfcol_2`, 0) = COALESCE(`bfcol_6`, 0) - AND COALESCE(`bfcol_2`, 1) = COALESCE(`bfcol_6`, 1) -) -SELECT - `bfcol_3` AS `int64_col`, - `bfcol_7` AS `int64_too` -FROM `bfcte_4` \ No newline at end of file + `t0`.`int64_col` AS `bfuid_col_1256`, + `t0`.`int64_too` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON COALESCE(`t3`.`bfuid_col_1`, 0) = COALESCE(`t4`.`bfuid_col_1256`, 0) + AND COALESCE(`t3`.`bfuid_col_1`, 1) = COALESCE(`t4`.`bfuid_col_1256`, 1) \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/bool_col/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/bool_col/out.sql index 30f363e900..b07c6e3b26 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/bool_col/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/bool_col/out.sql @@ -1,33 +1,18 @@ -WITH `bfcte_1` AS ( - SELECT - `bool_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `rowindex` AS `bfcol_2`, - `bool_col` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `bool_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`bool_col`, + `t4`.`bfuid_col_1259` AS `rowindex_y` +FROM ( SELECT - `rowindex` AS `bfcol_6`, - `bool_col` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`bool_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_2` - INNER JOIN `bfcte_3` - ON COALESCE(CAST(`bfcol_3` AS STRING), '0') = COALESCE(CAST(`bfcol_7` AS STRING), '0') - AND COALESCE(CAST(`bfcol_3` AS STRING), '1') = COALESCE(CAST(`bfcol_7` AS STRING), '1') -) -SELECT - `bfcol_2` AS `rowindex_x`, - `bfcol_3` AS `bool_col`, - `bfcol_6` AS `rowindex_y` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_1259`, + `t0`.`bool_col` AS `bfuid_col_1260` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON COALESCE(CAST(`t3`.`bool_col` AS STRING), '0') = COALESCE(CAST(`t4`.`bfuid_col_1260` AS STRING), '0') + AND COALESCE(CAST(`t3`.`bool_col` AS STRING), '1') = COALESCE(CAST(`t4`.`bfuid_col_1260` AS STRING), '1') \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/float64_col/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/float64_col/out.sql index 9fa7673fb3..96c78be2fb 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/float64_col/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/float64_col/out.sql @@ -1,33 +1,18 @@ -WITH `bfcte_1` AS ( - SELECT - `float64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `rowindex` AS `bfcol_2`, - `float64_col` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `float64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`float64_col`, + `t4`.`bfuid_col_1265` AS `rowindex_y` +FROM ( SELECT - `rowindex` AS `bfcol_6`, - `float64_col` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_2` - INNER JOIN `bfcte_3` - ON IF(IS_NAN(`bfcol_3`), 2, COALESCE(`bfcol_3`, 0)) = IF(IS_NAN(`bfcol_7`), 2, COALESCE(`bfcol_7`, 0)) - AND IF(IS_NAN(`bfcol_3`), 3, COALESCE(`bfcol_3`, 1)) = IF(IS_NAN(`bfcol_7`), 3, COALESCE(`bfcol_7`, 1)) -) -SELECT - `bfcol_2` AS `rowindex_x`, - `bfcol_3` AS `float64_col`, - `bfcol_6` AS `rowindex_y` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_1265`, + `t0`.`float64_col` AS `bfuid_col_1266` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON IF(IS_NAN(`t3`.`float64_col`), 2, COALESCE(`t3`.`float64_col`, 0)) = IF(IS_NAN(`t4`.`bfuid_col_1266`), 2, COALESCE(`t4`.`bfuid_col_1266`, 0)) + AND IF(IS_NAN(`t3`.`float64_col`), 3, COALESCE(`t3`.`float64_col`, 1)) = IF(IS_NAN(`t4`.`bfuid_col_1266`), 3, COALESCE(`t4`.`bfuid_col_1266`, 1)) \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/int64_col/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/int64_col/out.sql index c9fca069d6..8b45ee2690 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/int64_col/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/int64_col/out.sql @@ -1,33 +1,18 @@ -WITH `bfcte_1` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `rowindex` AS `bfcol_2`, - `int64_col` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`int64_col`, + `t4`.`bfuid_col_1262` AS `rowindex_y` +FROM ( SELECT - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_2` - INNER JOIN `bfcte_3` - ON COALESCE(`bfcol_3`, 0) = COALESCE(`bfcol_7`, 0) - AND COALESCE(`bfcol_3`, 1) = COALESCE(`bfcol_7`, 1) -) -SELECT - `bfcol_2` AS `rowindex_x`, - `bfcol_3` AS `int64_col`, - `bfcol_6` AS `rowindex_y` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_1262`, + `t0`.`int64_col` AS `bfuid_col_1263` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON COALESCE(`t3`.`int64_col`, 0) = COALESCE(`t4`.`bfuid_col_1263`, 0) + AND COALESCE(`t3`.`int64_col`, 1) = COALESCE(`t4`.`bfuid_col_1263`, 1) \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/numeric_col/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/numeric_col/out.sql index 88649c6518..8ed828f72e 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/numeric_col/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/numeric_col/out.sql @@ -1,33 +1,18 @@ -WITH `bfcte_1` AS ( - SELECT - `numeric_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `rowindex` AS `bfcol_2`, - `numeric_col` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `numeric_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`numeric_col`, + `t4`.`bfuid_col_1274` AS `rowindex_y` +FROM ( SELECT - `rowindex` AS `bfcol_6`, - `numeric_col` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`numeric_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_2` - INNER JOIN `bfcte_3` - ON COALESCE(`bfcol_3`, CAST(0 AS NUMERIC)) = COALESCE(`bfcol_7`, CAST(0 AS NUMERIC)) - AND COALESCE(`bfcol_3`, CAST(1 AS NUMERIC)) = COALESCE(`bfcol_7`, CAST(1 AS NUMERIC)) -) -SELECT - `bfcol_2` AS `rowindex_x`, - `bfcol_3` AS `numeric_col`, - `bfcol_6` AS `rowindex_y` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_1274`, + `t0`.`numeric_col` AS `bfuid_col_1275` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON COALESCE(`t3`.`numeric_col`, 0) = COALESCE(`t4`.`bfuid_col_1275`, 0) + AND COALESCE(`t3`.`numeric_col`, 1) = COALESCE(`t4`.`bfuid_col_1275`, 1) \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/string_col/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/string_col/out.sql index 8758ec8340..4ba04a4222 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/string_col/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/string_col/out.sql @@ -1,33 +1,18 @@ -WITH `bfcte_1` AS ( - SELECT - `rowindex`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `string_col` AS `bfcol_1` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `rowindex`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`string_col`, + `t4`.`bfuid_col_1268` AS `rowindex_y` +FROM ( SELECT - `rowindex` AS `bfcol_4`, - `string_col` AS `bfcol_5` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_2` - INNER JOIN `bfcte_3` - ON COALESCE(CAST(`bfcol_1` AS STRING), '0') = COALESCE(CAST(`bfcol_5` AS STRING), '0') - AND COALESCE(CAST(`bfcol_1` AS STRING), '1') = COALESCE(CAST(`bfcol_5` AS STRING), '1') -) -SELECT - `bfcol_0` AS `rowindex_x`, - `bfcol_1` AS `string_col`, - `bfcol_4` AS `rowindex_y` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_1268`, + `t0`.`string_col` AS `bfuid_col_1269` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON COALESCE(`t3`.`string_col`, '0') = COALESCE(`t4`.`bfuid_col_1269`, '0') + AND COALESCE(`t3`.`string_col`, '1') = COALESCE(`t4`.`bfuid_col_1269`, '1') \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/time_col/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/time_col/out.sql index 42fc15cd1d..e971400400 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/time_col/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/time_col/out.sql @@ -1,33 +1,18 @@ -WITH `bfcte_1` AS ( - SELECT - `rowindex`, - `time_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `time_col` AS `bfcol_1` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `rowindex`, - `time_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`time_col`, + `t4`.`bfuid_col_1271` AS `rowindex_y` +FROM ( SELECT - `rowindex` AS `bfcol_4`, - `time_col` AS `bfcol_5` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`time_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_2` - INNER JOIN `bfcte_3` - ON COALESCE(CAST(`bfcol_1` AS STRING), '0') = COALESCE(CAST(`bfcol_5` AS STRING), '0') - AND COALESCE(CAST(`bfcol_1` AS STRING), '1') = COALESCE(CAST(`bfcol_5` AS STRING), '1') -) -SELECT - `bfcol_0` AS `rowindex_x`, - `bfcol_1` AS `time_col`, - `bfcol_4` AS `rowindex_y` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_1271`, + `t0`.`time_col` AS `bfuid_col_1272` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON COALESCE(CAST(`t3`.`time_col` AS STRING), '0') = COALESCE(CAST(`t4`.`bfuid_col_1272` AS STRING), '0') + AND COALESCE(CAST(`t3`.`time_col` AS STRING), '1') = COALESCE(CAST(`t4`.`bfuid_col_1272` AS STRING), '1') \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal/out.sql index 2b080b0b7c..dd564006ae 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal/out.sql @@ -1,63 +1,99 @@ -WITH `bfcte_0` AS ( +SELECT +`rowindex` AS `rowindex`, +`bool_col` AS `bool_col`, +`bytes_col` AS `bytes_col`, +`date_col` AS `date_col`, +`datetime_col` AS `datetime_col`, +`geography_col` AS `geography_col`, +`int64_col` AS `int64_col`, +`int64_too` AS `int64_too`, +`numeric_col` AS `numeric_col`, +`float64_col` AS `float64_col`, +`rowindex_1` AS `rowindex_1`, +`rowindex_2` AS `rowindex_2`, +`string_col` AS `string_col`, +`time_col` AS `time_col`, +`timestamp_col` AS `timestamp_col`, +`duration_col` AS `duration_col` +FROM +(SELECT + `t0`.`level_0` AS `rowindex`, + `t0`.`column_0` AS `bool_col`, + `t0`.`column_1` AS `bytes_col`, + `t0`.`column_2` AS `date_col`, + `t0`.`column_3` AS `datetime_col`, + `t0`.`column_4` AS `geography_col`, + `t0`.`column_5` AS `int64_col`, + `t0`.`column_6` AS `int64_too`, + `t0`.`column_7` AS `numeric_col`, + `t0`.`column_8` AS `float64_col`, + `t0`.`column_9` AS `rowindex_1`, + `t0`.`column_10` AS `rowindex_2`, + `t0`.`column_11` AS `string_col`, + `t0`.`column_12` AS `time_col`, + `t0`.`column_13` AS `timestamp_col`, + `t0`.`column_14` AS `duration_col`, + `t0`.`bfuid_col_1277` AS `bfuid_col_1278` +FROM ( SELECT * - FROM UNNEST(ARRAY>[STRUCT( + FROM UNNEST(ARRAY>[STRUCT( 0, TRUE, - CAST(b'Hello, World!' AS BYTES), - CAST('2021-07-21' AS DATE), - CAST('2021-07-21T11:39:45' AS DATETIME), - ST_GEOGFROMTEXT('POINT(-122.0838511 37.3860517)'), + CAST('48656c6c6f2c20576f726c6421' AS BYTES FORMAT 'HEX'), + DATE(2021, 7, 21), + DATETIME('2021-07-21T11:39:45'), + st_geogfromtext('POINT(-122.0838511 37.3860517)'), 123456789, 0, - CAST(1.234567890 AS NUMERIC), + CAST('1.234567890' AS NUMERIC), 1.25, 0, 0, 'Hello, World!', - CAST('11:41:43.076160' AS TIME), - CAST('2021-07-21T17:43:43.945289+00:00' AS TIMESTAMP), + TIME_ADD(TIME(11, 41, 43), INTERVAL 76160 MICROSECOND), + TIMESTAMP('2021-07-21T17:43:43.945289+00:00'), 4, 0 ), STRUCT( 1, FALSE, - CAST(b'\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x81\xaf' AS BYTES), - CAST('1991-02-03' AS DATE), - CAST('1991-01-02T03:45:06' AS DATETIME), - ST_GEOGFROMTEXT('POINT(-71.104 42.315)'), + CAST('e38193e38293e381abe381a1e381af' AS BYTES FORMAT 'HEX'), + DATE(1991, 2, 3), + DATETIME('1991-01-02T03:45:06'), + st_geogfromtext('POINT(-71.104 42.315)'), -987654321, 1, - CAST(1.234567890 AS NUMERIC), + CAST('1.234567890' AS NUMERIC), 2.51, 1, 1, 'こんにちは', - CAST('11:14:34.701606' AS TIME), - CAST('2021-07-21T17:43:43.945289+00:00' AS TIMESTAMP), + TIME_ADD(TIME(11, 14, 34), INTERVAL 701606 MICROSECOND), + TIMESTAMP('2021-07-21T17:43:43.945289+00:00'), -1000000, 1 ), STRUCT( 2, TRUE, - CAST(b'\xc2\xa1Hola Mundo!' AS BYTES), - CAST('2023-03-01' AS DATE), - CAST('2023-03-01T10:55:13' AS DATETIME), - ST_GEOGFROMTEXT('POINT(-0.124474760143016 51.5007826749545)'), + CAST('c2a1486f6c61204d756e646f21' AS BYTES FORMAT 'HEX'), + DATE(2023, 3, 1), + DATETIME('2023-03-01T10:55:13'), + st_geogfromtext('POINT(-0.124474760143016 51.5007826749545)'), 314159, 0, - CAST(101.101010100 AS NUMERIC), + CAST('101.101010100' AS NUMERIC), 25000000000.0, 2, 2, ' ¡Hola Mundo! ', - CAST('23:59:59.999999' AS TIME), - CAST('2023-03-01T10:55:13.250125+00:00' AS TIMESTAMP), + TIME_ADD(TIME(23, 59, 59), INTERVAL 999999 MICROSECOND), + TIMESTAMP('2023-03-01T10:55:13.250125+00:00'), 0, 2 ), STRUCT( 3, - CAST(NULL AS BOOLEAN), + CAST(NULL AS BOOL), CAST(NULL AS BYTES), CAST(NULL AS DATE), CAST(NULL AS DATETIME), @@ -76,8 +112,8 @@ WITH `bfcte_0` AS ( ), STRUCT( 4, FALSE, - CAST(b'\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x81\xaf' AS BYTES), - CAST('2021-07-21' AS DATE), + CAST('e38193e38293e381abe381a1e381af' AS BYTES FORMAT 'HEX'), + DATE(2021, 7, 21), CAST(NULL AS DATETIME), CAST(NULL AS GEOGRAPHY), -234892, @@ -94,55 +130,55 @@ WITH `bfcte_0` AS ( ), STRUCT( 5, FALSE, - CAST(b'G\xc3\xbcten Tag' AS BYTES), - CAST('1980-03-14' AS DATE), - CAST('1980-03-14T15:16:17' AS DATETIME), + CAST('47c3bc74656e20546167' AS BYTES FORMAT 'HEX'), + DATE(1980, 3, 14), + DATETIME('1980-03-14T15:16:17'), CAST(NULL AS GEOGRAPHY), 55555, 0, - CAST(5.555555000 AS NUMERIC), + CAST('5.555555000' AS NUMERIC), 555.555, 5, 5, 'Güten Tag!', - CAST('15:16:17.181921' AS TIME), - CAST('1980-03-14T15:16:17.181921+00:00' AS TIMESTAMP), + TIME_ADD(TIME(15, 16, 17), INTERVAL 181921 MICROSECOND), + TIMESTAMP('1980-03-14T15:16:17.181921+00:00'), 4, 5 ), STRUCT( 6, TRUE, - CAST(b'Hello\tBigFrames!\x07' AS BYTES), - CAST('2023-05-23' AS DATE), - CAST('2023-05-23T11:37:01' AS DATETIME), - ST_GEOGFROMTEXT('LINESTRING(-0.127959 51.507728, -0.127026 51.507473)'), + CAST('48656c6c6f094269674672616d65732107' AS BYTES FORMAT 'HEX'), + DATE(2023, 5, 23), + DATETIME('2023-05-23T11:37:01'), + st_geogfromtext('LINESTRING(-0.127959 51.507728, -0.127026 51.507473)'), 101202303, 2, - CAST(-10.090807000 AS NUMERIC), + CAST('-10.090807000' AS NUMERIC), -123.456, 6, 6, 'capitalize, This ', - CAST('01:02:03.456789' AS TIME), - CAST('2023-05-23T11:42:55.000001+00:00' AS TIMESTAMP), + TIME_ADD(TIME(1, 2, 3), INTERVAL 456789 MICROSECOND), + TIMESTAMP('2023-05-23T11:42:55.000001+00:00'), CAST(NULL AS INT64), 6 ), STRUCT( 7, TRUE, CAST(NULL AS BYTES), - CAST('2038-01-20' AS DATE), - CAST('2038-01-19T03:14:08' AS DATETIME), + DATE(2038, 1, 20), + DATETIME('2038-01-19T03:14:08'), CAST(NULL AS GEOGRAPHY), -214748367, 2, - CAST(11111111.100000000 AS NUMERIC), + CAST('11111111.100000000' AS NUMERIC), 42.42, 7, 7, ' سلام', - CAST('12:00:00.000001' AS TIME), - CAST('2038-01-19T03:14:17.999999+00:00' AS TIMESTAMP), + TIME_ADD(TIME(12, 0, 0), INTERVAL 1 MICROSECOND), + TIMESTAMP('2038-01-19T03:14:17.999999+00:00'), 4, 7 ), STRUCT( @@ -163,25 +199,6 @@ WITH `bfcte_0` AS ( CAST(NULL AS TIMESTAMP), 432000000000, 8 - )]) -) -SELECT - `bfcol_0` AS `rowindex`, - `bfcol_1` AS `bool_col`, - `bfcol_2` AS `bytes_col`, - `bfcol_3` AS `date_col`, - `bfcol_4` AS `datetime_col`, - `bfcol_5` AS `geography_col`, - `bfcol_6` AS `int64_col`, - `bfcol_7` AS `int64_too`, - `bfcol_8` AS `numeric_col`, - `bfcol_9` AS `float64_col`, - `bfcol_10` AS `rowindex_1`, - `bfcol_11` AS `rowindex_2`, - `bfcol_12` AS `string_col`, - `bfcol_13` AS `time_col`, - `bfcol_14` AS `timestamp_col`, - `bfcol_15` AS `duration_col` -FROM `bfcte_0` -ORDER BY - `bfcol_16` ASC NULLS LAST \ No newline at end of file + )]) AS `level_0` +) AS `t0`) +ORDER BY `bfuid_col_1278` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_json_df/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_json_df/out.sql index 4e21266b87..d244edb673 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_json_df/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_json_df/out.sql @@ -1,11 +1,14 @@ -WITH `bfcte_0` AS ( +SELECT +`rowindex` AS `rowindex`, +`json_col` AS `json_col` +FROM +(SELECT + `t0`.`level_0` AS `rowindex`, + `t0`.`column_0` AS `json_col`, + `t0`.`bfuid_col_1283` AS `bfuid_col_1284` +FROM ( SELECT * - FROM UNNEST(ARRAY>[STRUCT(0, PARSE_JSON('null'), 0), STRUCT(1, PARSE_JSON('true'), 1), STRUCT(2, PARSE_JSON('100'), 2), STRUCT(3, PARSE_JSON('0.98'), 3), STRUCT(4, PARSE_JSON('"a string"'), 4), STRUCT(5, PARSE_JSON('[]'), 5), STRUCT(6, PARSE_JSON('[1,2,3]'), 6), STRUCT(7, PARSE_JSON('[{"a":1},{"a":2},{"a":null},{}]'), 7), STRUCT(8, PARSE_JSON('"100"'), 8), STRUCT(9, PARSE_JSON('{"date":"2024-07-16"}'), 9), STRUCT(10, PARSE_JSON('{"int_value":2,"null_filed":null}'), 10), STRUCT(11, PARSE_JSON('{"list_data":[10,20,30]}'), 11)]) -) -SELECT - `bfcol_0` AS `rowindex`, - `bfcol_1` AS `json_col` -FROM `bfcte_0` -ORDER BY - `bfcol_2` ASC NULLS LAST \ No newline at end of file + FROM UNNEST(ARRAY>[STRUCT(0, JSON 'null', 0), STRUCT(1, JSON 'true', 1), STRUCT(2, JSON '100', 2), STRUCT(3, JSON '0.98', 3), STRUCT(4, JSON '"a string"', 4), STRUCT(5, JSON '[]', 5), STRUCT(6, JSON '[1,2,3]', 6), STRUCT(7, JSON '[{"a":1},{"a":2},{"a":null},{}]', 7), STRUCT(8, JSON '"100"', 8), STRUCT(9, JSON '{"date":"2024-07-16"}', 9), STRUCT(10, JSON '{"int_value":2,"null_filed":null}', 10), STRUCT(11, JSON '{"list_data":[10,20,30]}', 11)]) AS `level_0` +) AS `t0`) +ORDER BY `bfuid_col_1284` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_lists_df/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_lists_df/out.sql index 923476aafd..1e393332c8 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_lists_df/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_lists_df/out.sql @@ -1,7 +1,27 @@ -WITH `bfcte_0` AS ( +SELECT +`rowindex` AS `rowindex`, +`int_list_col` AS `int_list_col`, +`bool_list_col` AS `bool_list_col`, +`float_list_col` AS `float_list_col`, +`date_list_col` AS `date_list_col`, +`date_time_list_col` AS `date_time_list_col`, +`numeric_list_col` AS `numeric_list_col`, +`string_list_col` AS `string_list_col` +FROM +(SELECT + `t0`.`level_0` AS `rowindex`, + `t0`.`column_0` AS `int_list_col`, + `t0`.`column_1` AS `bool_list_col`, + `t0`.`column_2` AS `float_list_col`, + `t0`.`column_3` AS `date_list_col`, + `t0`.`column_4` AS `date_time_list_col`, + `t0`.`column_5` AS `numeric_list_col`, + `t0`.`column_6` AS `string_list_col`, + `t0`.`bfuid_col_1281` AS `bfuid_col_1282` +FROM ( SELECT * - FROM UNNEST(ARRAY, `bfcol_2` ARRAY, `bfcol_3` ARRAY, `bfcol_4` ARRAY, `bfcol_5` ARRAY, `bfcol_6` ARRAY, `bfcol_7` ARRAY, `bfcol_8` INT64>>[STRUCT( + FROM UNNEST(ARRAY, `column_1` ARRAY, `column_2` ARRAY, `column_3` ARRAY, `column_4` ARRAY, `column_5` ARRAY, `column_6` ARRAY, `bfuid_col_1281` INT64>>[STRUCT( 0, [1], [TRUE], @@ -31,17 +51,6 @@ WITH `bfcte_0` AS ( [1.7000000000000002], ['', 'a'], 2 - )]) -) -SELECT - `bfcol_0` AS `rowindex`, - `bfcol_1` AS `int_list_col`, - `bfcol_2` AS `bool_list_col`, - `bfcol_3` AS `float_list_col`, - `bfcol_4` AS `date_list_col`, - `bfcol_5` AS `date_time_list_col`, - `bfcol_6` AS `numeric_list_col`, - `bfcol_7` AS `string_list_col` -FROM `bfcte_0` -ORDER BY - `bfcol_8` ASC NULLS LAST \ No newline at end of file + )]) AS `level_0` +) AS `t0`) +ORDER BY `bfuid_col_1282` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_structs_df/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_structs_df/out.sql index 7ded9cf5ff..63fa03bf77 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_structs_df/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_structs_df/out.sql @@ -1,7 +1,15 @@ -WITH `bfcte_0` AS ( +SELECT +`id` AS `id`, +`person` AS `person` +FROM +(SELECT + `t0`.`level_0` AS `id`, + `t0`.`column_0` AS `person`, + `t0`.`bfuid_col_1279` AS `bfuid_col_1280` +FROM ( SELECT * - FROM UNNEST(ARRAY>, `bfcol_2` INT64>>[STRUCT( + FROM UNNEST(ARRAY>, `bfuid_col_1279` INT64>>[STRUCT( 1, STRUCT( 'Alice' AS `name`, @@ -17,11 +25,6 @@ WITH `bfcte_0` AS ( STRUCT('London' AS `city`, 'UK' AS `country`) AS `address` ), 1 - )]) -) -SELECT - `bfcol_0` AS `id`, - `bfcol_1` AS `person` -FROM `bfcte_0` -ORDER BY - `bfcol_2` ASC NULLS LAST \ No newline at end of file + )]) AS `level_0` +) AS `t0`) +ORDER BY `bfuid_col_1280` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable/out.sql index 959a31a2a3..7f967a48ca 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable/out.sql @@ -1,37 +1,18 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `bytes_col`, - `date_col`, - `datetime_col`, - `duration_col`, - `float64_col`, - `geography_col`, - `int64_col`, - `int64_too`, - `numeric_col`, - `rowindex`, - `rowindex_2`, - `string_col`, - `time_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -) SELECT - `rowindex`, - `bool_col`, - `bytes_col`, - `date_col`, - `datetime_col`, - `geography_col`, - `int64_col`, - `int64_too`, - `numeric_col`, - `float64_col`, - `rowindex` AS `rowindex_1`, - `rowindex_2`, - `string_col`, - `time_col`, - `timestamp_col`, - `duration_col` -FROM `bfcte_0` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`bool_col`, + `t0`.`bytes_col`, + `t0`.`date_col`, + `t0`.`datetime_col`, + `t0`.`geography_col`, + `t0`.`int64_col`, + `t0`.`int64_too`, + `t0`.`numeric_col`, + `t0`.`float64_col`, + `t0`.`rowindex` AS `rowindex_1`, + `t0`.`rowindex_2`, + `t0`.`string_col`, + `t0`.`time_col`, + `t0`.`timestamp_col`, + `t0`.`duration_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_json_types/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_json_types/out.sql index 4b5750d7aa..d8e2f36527 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_json_types/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_json_types/out.sql @@ -1,10 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -) SELECT - `rowindex`, - `json_col` -FROM `bfcte_0` \ No newline at end of file + * +FROM `bigframes-dev.sqlglot_test.json_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_limit/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_limit/out.sql index 856c7061da..5ecd1f95be 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_limit/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_limit/out.sql @@ -1,13 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -) SELECT - `rowindex`, - `int64_col` -FROM `bfcte_0` -ORDER BY - `rowindex` ASC NULLS LAST +`rowindex` AS `rowindex`, +`int64_col` AS `int64_col` +FROM +(SELECT + `t0`.`rowindex`, + `t0`.`int64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0`) +ORDER BY `rowindex` ASC NULLS LAST LIMIT 10 \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_nested_structs_types/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_nested_structs_types/out.sql index 79ae1ac907..ffcb3dcf49 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_nested_structs_types/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_nested_structs_types/out.sql @@ -1,11 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `id`, - `people` - FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` -) SELECT - `id`, - `id` AS `id_1`, - `people` -FROM `bfcte_0` \ No newline at end of file + `t0`.`id`, + `t0`.`id` AS `id_1`, + `t0`.`people` +FROM `bigframes-dev.sqlglot_test.nested_structs_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_ordering/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_ordering/out.sql index edb8d7fbf4..fe2612044d 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_ordering/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_ordering/out.sql @@ -1,12 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -) SELECT - `rowindex`, - `int64_col` -FROM `bfcte_0` -ORDER BY - `int64_col` ASC NULLS LAST \ No newline at end of file +`rowindex` AS `rowindex`, +`int64_col` AS `int64_col` +FROM +(SELECT + `t0`.`rowindex`, + `t0`.`int64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0`) +ORDER BY `int64_col` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_repeated_types/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_repeated_types/out.sql index a22c845ef1..5acbf7ea29 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_repeated_types/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_repeated_types/out.sql @@ -1,23 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_list_col`, - `date_list_col`, - `date_time_list_col`, - `float_list_col`, - `int_list_col`, - `numeric_list_col`, - `rowindex`, - `string_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -) SELECT - `rowindex`, - `rowindex` AS `rowindex_1`, - `int_list_col`, - `bool_list_col`, - `float_list_col`, - `date_list_col`, - `date_time_list_col`, - `numeric_list_col`, - `string_list_col` -FROM `bfcte_0` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`rowindex` AS `rowindex_1`, + `t0`.`int_list_col`, + `t0`.`bool_list_col`, + `t0`.`float_list_col`, + `t0`.`date_list_col`, + `t0`.`date_time_list_col`, + `t0`.`numeric_list_col`, + `t0`.`string_list_col` +FROM `bigframes-dev.sqlglot_test.repeated_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql index 59c3687080..50cae2f799 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql @@ -1,36 +1,21 @@ -WITH `bfcte_0` AS ( +SELECT + * +FROM ( SELECT `bool_col`, `bytes_col`, `date_col`, `datetime_col`, - `duration_col`, - `float64_col`, `geography_col`, `int64_col`, `int64_too`, `numeric_col`, + `float64_col`, `rowindex`, `rowindex_2`, `string_col`, `time_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` FOR SYSTEM_TIME AS OF '2025-11-09T03:04:05.678901+00:00' -) -SELECT - `bool_col`, - `bytes_col`, - `date_col`, - `datetime_col`, - `geography_col`, - `int64_col`, - `int64_too`, - `numeric_col`, - `float64_col`, - `rowindex`, - `rowindex_2`, - `string_col`, - `time_col`, - `timestamp_col`, - `duration_col` -FROM `bfcte_0` \ No newline at end of file + `timestamp_col`, + `duration_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF TIMESTAMP('2025-11-09T03:04:05.678901+00:00') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_groupby_rolling/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_groupby_rolling/out.sql index 11e3f4773e..db08c0dda0 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_groupby_rolling/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_groupby_rolling/out.sql @@ -1,76 +1,86 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `bool_col` AS `bfcol_7`, - `int64_col` AS `bfcol_8`, - `bool_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - * - FROM `bfcte_1` - WHERE - NOT `bfcol_9` IS NULL -), `bfcte_3` AS ( - SELECT - *, - CASE - WHEN SUM(CAST(NOT `bfcol_7` IS NULL AS INT64)) OVER ( - PARTITION BY `bfcol_9` - ORDER BY `bfcol_9` ASC NULLS LAST, `rowindex` ASC NULLS LAST - ROWS BETWEEN 3 PRECEDING AND CURRENT ROW - ) < 3 - THEN NULL - ELSE COALESCE( - SUM(CAST(`bfcol_7` AS INT64)) OVER ( - PARTITION BY `bfcol_9` - ORDER BY `bfcol_9` ASC NULLS LAST, `rowindex` ASC NULLS LAST - ROWS BETWEEN 3 PRECEDING AND CURRENT ROW - ), - 0 - ) - END AS `bfcol_15` - FROM `bfcte_2` -), `bfcte_4` AS ( +SELECT +`bool_col` AS `bool_col`, +`rowindex` AS `rowindex`, +`bool_col_1` AS `bool_col_1`, +`int64_col` AS `int64_col` +FROM +(SELECT + `t3`.`bfuid_col_1290` AS `bool_col`, + `t3`.`bfuid_col_1287` AS `rowindex`, + `t3`.`bfuid_col_1291` AS `bool_col_1`, + CASE + WHEN COALESCE( + SUM(CAST(( + `t3`.`bfuid_col_1289` + ) IS NOT NULL AS INT64)) OVER ( + PARTITION BY `t3`.`bfuid_col_1290` + ORDER BY `t3`.`bfuid_col_1290` IS NULL ASC, `t3`.`bfuid_col_1290` ASC, `t3`.`bfuid_col_1296` IS NULL ASC, `t3`.`bfuid_col_1296` ASC + ROWS BETWEEN 3 preceding AND CURRENT ROW + ), + 0 + ) < 3 + THEN NULL + WHEN TRUE + THEN COALESCE( + SUM(`t3`.`bfuid_col_1289`) OVER ( + PARTITION BY `t3`.`bfuid_col_1290` + ORDER BY `t3`.`bfuid_col_1290` IS NULL ASC, `t3`.`bfuid_col_1290` ASC, `t3`.`bfuid_col_1296` IS NULL ASC, `t3`.`bfuid_col_1296` ASC + ROWS BETWEEN 3 preceding AND CURRENT ROW + ), + 0 + ) + ELSE CAST(NULL AS INT64) + END AS `int64_col`, + `t3`.`bfuid_col_1296` AS `bfuid_col_1297` +FROM ( SELECT * - FROM `bfcte_3` + FROM ( + SELECT + `t1`.`bfuid_col_1287`, + `t1`.`bfuid_col_1289`, + `t1`.`bfuid_col_1290`, + CASE + WHEN COALESCE( + SUM(CAST(( + `t1`.`bfuid_col_1288` + ) IS NOT NULL AS INT64)) OVER ( + PARTITION BY `t1`.`bfuid_col_1290` + ORDER BY `t1`.`bfuid_col_1290` IS NULL ASC, `t1`.`bfuid_col_1290` ASC, `t1`.`bfuid_col_1295` IS NULL ASC, `t1`.`bfuid_col_1295` ASC + ROWS BETWEEN 3 preceding AND CURRENT ROW + ), + 0 + ) < 3 + THEN NULL + WHEN TRUE + THEN COALESCE( + SUM(CAST(`t1`.`bfuid_col_1288` AS INT64)) OVER ( + PARTITION BY `t1`.`bfuid_col_1290` + ORDER BY `t1`.`bfuid_col_1290` IS NULL ASC, `t1`.`bfuid_col_1290` ASC, `t1`.`bfuid_col_1295` IS NULL ASC, `t1`.`bfuid_col_1295` ASC + ROWS BETWEEN 3 preceding AND CURRENT ROW + ), + 0 + ) + ELSE CAST(NULL AS INT64) + END AS `bfuid_col_1291`, + `t1`.`bfuid_col_1295` AS `bfuid_col_1296` + FROM ( + SELECT + `t0`.`rowindex` AS `bfuid_col_1287`, + `t0`.`bool_col` AS `bfuid_col_1288`, + `t0`.`int64_col` AS `bfuid_col_1289`, + `t0`.`bool_col` AS `bfuid_col_1290`, + `t0`.`rowindex` AS `bfuid_col_1295` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` + WHERE + ( + `t0`.`bool_col` + ) IS NOT NULL + ) AS `t1` + ) AS `t2` WHERE - NOT `bfcol_9` IS NULL -), `bfcte_5` AS ( - SELECT - *, - CASE - WHEN SUM(CAST(NOT `bfcol_8` IS NULL AS INT64)) OVER ( - PARTITION BY `bfcol_9` - ORDER BY `bfcol_9` ASC NULLS LAST, `rowindex` ASC NULLS LAST - ROWS BETWEEN 3 PRECEDING AND CURRENT ROW - ) < 3 - THEN NULL - ELSE COALESCE( - SUM(`bfcol_8`) OVER ( - PARTITION BY `bfcol_9` - ORDER BY `bfcol_9` ASC NULLS LAST, `rowindex` ASC NULLS LAST - ROWS BETWEEN 3 PRECEDING AND CURRENT ROW - ), - 0 - ) - END AS `bfcol_21` - FROM `bfcte_4` -) -SELECT - `bfcol_9` AS `bool_col`, - `bfcol_6` AS `rowindex`, - `bfcol_15` AS `bool_col_1`, - `bfcol_21` AS `int64_col` -FROM `bfcte_5` -ORDER BY - `bfcol_9` ASC NULLS LAST, - `rowindex` ASC NULLS LAST \ No newline at end of file + ( + `t2`.`bfuid_col_1290` + ) IS NOT NULL +) AS `t3`) +ORDER BY `bool_col` ASC NULLS LAST ,`bfuid_col_1297` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_range_rolling/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_range_rolling/out.sql index 581c81c6b4..c148634f67 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_range_rolling/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_range_rolling/out.sql @@ -1,30 +1,34 @@ -WITH `bfcte_0` AS ( +SELECT +`ts_col` AS `ts_col`, +`int_col` AS `int_col` +FROM +(SELECT + `t0`.`column_0` AS `ts_col`, + CASE + WHEN COALESCE( + SUM(CAST(( + `t0`.`column_1` + ) IS NOT NULL AS INT64)) OVER ( + ORDER BY UNIX_MICROS(`t0`.`column_0`) ASC + RANGE BETWEEN 2999999 preceding AND CURRENT ROW + ), + 0 + ) < 1 + THEN NULL + WHEN TRUE + THEN COALESCE( + SUM(`t0`.`column_1`) OVER ( + ORDER BY UNIX_MICROS(`t0`.`column_0`) ASC + RANGE BETWEEN 2999999 preceding AND CURRENT ROW + ), + 0 + ) + ELSE CAST(NULL AS INT64) + END AS `int_col`, + `t0`.`bfuid_col_1300` AS `bfuid_col_1302` +FROM ( SELECT * - FROM UNNEST(ARRAY>[STRUCT(CAST('2025-01-01T00:00:00+00:00' AS TIMESTAMP), 0, 0), STRUCT(CAST('2025-01-01T00:00:01+00:00' AS TIMESTAMP), 1, 1), STRUCT(CAST('2025-01-01T00:00:02+00:00' AS TIMESTAMP), 2, 2), STRUCT(CAST('2025-01-01T00:00:03+00:00' AS TIMESTAMP), 3, 3), STRUCT(CAST('2025-01-01T00:00:04+00:00' AS TIMESTAMP), 0, 4), STRUCT(CAST('2025-01-01T00:00:05+00:00' AS TIMESTAMP), 1, 5), STRUCT(CAST('2025-01-01T00:00:06+00:00' AS TIMESTAMP), 2, 6), STRUCT(CAST('2025-01-01T00:00:07+00:00' AS TIMESTAMP), 3, 7), STRUCT(CAST('2025-01-01T00:00:08+00:00' AS TIMESTAMP), 0, 8), STRUCT(CAST('2025-01-01T00:00:09+00:00' AS TIMESTAMP), 1, 9), STRUCT(CAST('2025-01-01T00:00:10+00:00' AS TIMESTAMP), 2, 10), STRUCT(CAST('2025-01-01T00:00:11+00:00' AS TIMESTAMP), 3, 11), STRUCT(CAST('2025-01-01T00:00:12+00:00' AS TIMESTAMP), 0, 12), STRUCT(CAST('2025-01-01T00:00:13+00:00' AS TIMESTAMP), 1, 13), STRUCT(CAST('2025-01-01T00:00:14+00:00' AS TIMESTAMP), 2, 14), STRUCT(CAST('2025-01-01T00:00:15+00:00' AS TIMESTAMP), 3, 15), STRUCT(CAST('2025-01-01T00:00:16+00:00' AS TIMESTAMP), 0, 16), STRUCT(CAST('2025-01-01T00:00:17+00:00' AS TIMESTAMP), 1, 17), STRUCT(CAST('2025-01-01T00:00:18+00:00' AS TIMESTAMP), 2, 18), STRUCT(CAST('2025-01-01T00:00:19+00:00' AS TIMESTAMP), 3, 19)]) -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN SUM(CAST(NOT `bfcol_1` IS NULL AS INT64)) OVER ( - ORDER BY UNIX_MICROS(`bfcol_0`) ASC NULLS LAST - RANGE BETWEEN 2999999 PRECEDING AND CURRENT ROW - ) < 1 - THEN NULL - ELSE COALESCE( - SUM(`bfcol_1`) OVER ( - ORDER BY UNIX_MICROS(`bfcol_0`) ASC NULLS LAST - RANGE BETWEEN 2999999 PRECEDING AND CURRENT ROW - ), - 0 - ) - END AS `bfcol_6` - FROM `bfcte_0` -) -SELECT - `bfcol_0` AS `ts_col`, - `bfcol_6` AS `int_col` -FROM `bfcte_1` -ORDER BY - `bfcol_0` ASC NULLS LAST, - `bfcol_2` ASC NULLS LAST \ No newline at end of file + FROM UNNEST(ARRAY>[STRUCT(TIMESTAMP('2025-01-01T00:00:00+00:00'), 0, 0), STRUCT(TIMESTAMP('2025-01-01T00:00:01+00:00'), 1, 1), STRUCT(TIMESTAMP('2025-01-01T00:00:02+00:00'), 2, 2), STRUCT(TIMESTAMP('2025-01-01T00:00:03+00:00'), 3, 3), STRUCT(TIMESTAMP('2025-01-01T00:00:04+00:00'), 0, 4), STRUCT(TIMESTAMP('2025-01-01T00:00:05+00:00'), 1, 5), STRUCT(TIMESTAMP('2025-01-01T00:00:06+00:00'), 2, 6), STRUCT(TIMESTAMP('2025-01-01T00:00:07+00:00'), 3, 7), STRUCT(TIMESTAMP('2025-01-01T00:00:08+00:00'), 0, 8), STRUCT(TIMESTAMP('2025-01-01T00:00:09+00:00'), 1, 9), STRUCT(TIMESTAMP('2025-01-01T00:00:10+00:00'), 2, 10), STRUCT(TIMESTAMP('2025-01-01T00:00:11+00:00'), 3, 11), STRUCT(TIMESTAMP('2025-01-01T00:00:12+00:00'), 0, 12), STRUCT(TIMESTAMP('2025-01-01T00:00:13+00:00'), 1, 13), STRUCT(TIMESTAMP('2025-01-01T00:00:14+00:00'), 2, 14), STRUCT(TIMESTAMP('2025-01-01T00:00:15+00:00'), 3, 15), STRUCT(TIMESTAMP('2025-01-01T00:00:16+00:00'), 0, 16), STRUCT(TIMESTAMP('2025-01-01T00:00:17+00:00'), 1, 17), STRUCT(TIMESTAMP('2025-01-01T00:00:18+00:00'), 2, 18), STRUCT(TIMESTAMP('2025-01-01T00:00:19+00:00'), 3, 19)]) AS `column_0` +) AS `t0`) +ORDER BY `ts_col` ASC NULLS LAST ,`bfuid_col_1302` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_skips_nulls_op/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_skips_nulls_op/out.sql index 788eb49ddf..df0043fb1c 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_skips_nulls_op/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_skips_nulls_op/out.sql @@ -1,24 +1,34 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN SUM(CAST(NOT `int64_col` IS NULL AS INT64)) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) < 3 - THEN NULL - ELSE COALESCE( - SUM(`int64_col`) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), - 0 - ) - END AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `rowindex`, - `bfcol_4` AS `int64_col` -FROM `bfcte_1` -ORDER BY - `rowindex` ASC NULLS LAST \ No newline at end of file +`rowindex` AS `rowindex`, +`int64_col` AS `int64_col` +FROM +(SELECT + `t1`.`rowindex`, + CASE + WHEN COALESCE( + SUM(CAST(( + `t1`.`int64_col` + ) IS NOT NULL AS INT64)) OVER ( + ORDER BY `t1`.`rowindex` IS NULL ASC, `t1`.`rowindex` ASC + ROWS BETWEEN 2 preceding AND CURRENT ROW + ), + 0 + ) < 3 + THEN NULL + WHEN TRUE + THEN COALESCE( + SUM(`t1`.`int64_col`) OVER ( + ORDER BY `t1`.`rowindex` IS NULL ASC, `t1`.`rowindex` ASC + ROWS BETWEEN 2 preceding AND CURRENT ROW + ), + 0 + ) + ELSE CAST(NULL AS INT64) + END AS `int64_col` +FROM ( + SELECT + `t0`.`int64_col`, + `t0`.`rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1`) +ORDER BY `rowindex` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_wo_skips_nulls_op/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_wo_skips_nulls_op/out.sql index 5ad435ddbb..8bf5fb979a 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_wo_skips_nulls_op/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_wo_skips_nulls_op/out.sql @@ -1,21 +1,28 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN COUNT(CAST(NOT `int64_col` IS NULL AS INT64)) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) < 5 - THEN NULL - ELSE COUNT(`int64_col`) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) - END AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `rowindex`, - `bfcol_4` AS `int64_col` -FROM `bfcte_1` -ORDER BY - `rowindex` ASC NULLS LAST \ No newline at end of file +`rowindex` AS `rowindex`, +`int64_col` AS `int64_col` +FROM +(SELECT + `t1`.`rowindex`, + CASE + WHEN COUNT(( + `t1`.`int64_col` + ) IS NOT NULL) OVER ( + ORDER BY `t1`.`rowindex` IS NULL ASC, `t1`.`rowindex` ASC + ROWS BETWEEN 4 preceding AND CURRENT ROW + ) < 5 + THEN NULL + WHEN TRUE + THEN COUNT(`t1`.`int64_col`) OVER ( + ORDER BY `t1`.`rowindex` IS NULL ASC, `t1`.`rowindex` ASC + ROWS BETWEEN 4 preceding AND CURRENT ROW + ) + ELSE CAST(NULL AS INT64) + END AS `int64_col` +FROM ( + SELECT + `t0`.`int64_col`, + `t0`.`rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1`) +ORDER BY `rowindex` ASC NULLS LAST \ No newline at end of file