diff --git a/bigframes/testing/compiler_session.py b/bigframes/testing/compiler_session.py index 289b2600fd..d5067a5c84 100644 --- a/bigframes/testing/compiler_session.py +++ b/bigframes/testing/compiler_session.py @@ -16,7 +16,9 @@ import typing import bigframes.core -import bigframes.core.compile.sqlglot as sqlglot +from bigframes.core.compile import configs +from bigframes.core.compile.ibis_compiler import ibis_compiler + import bigframes.session.executor @@ -24,8 +26,6 @@ class SQLCompilerExecutor(bigframes.session.executor.Executor): """Executor for SQL compilation using sqlglot.""" - compiler = sqlglot - def to_sql( self, array_value: bigframes.core.ArrayValue, @@ -38,9 +38,9 @@ def to_sql( # Compared with BigQueryCachingExecutor, SQLCompilerExecutor skips # caching the subtree. - return self.compiler.SQLGlotCompiler().compile( - array_value.node, ordered=ordered - ) + request = configs.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 8922a71de4..eb3d851e42 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,17 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `float64_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - CORR(`bfcol_0`, `bfcol_1`) 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 ( + SELECT + `int64_col`, + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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 6cf189da31..d10a6f978c 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,17 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `float64_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - COVAR_SAMP(`bfcol_0`, `bfcol_1`) 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 ( + SELECT + `int64_col`, + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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 d20a635e3d..dd56558ed2 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,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ROW_NUMBER() OVER () 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 NULL ASC) - 1 AS `row_number` +FROM ( + SELECT + `bool_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 2cee8a228f..89f21b405a 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ROW_NUMBER() OVER (ORDER BY `bfcol_0` IS NULL ASC NULLS LAST, `bfcol_0` 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 `t0`.`int64_col` IS NULL ASC, `t0`.`int64_col` ASC) - 1 AS `row_number` +FROM ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 19ae8aa3fd..edb27d5e44 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,12 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - COUNT(1) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` 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 ( + SELECT + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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_quartiles/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_approx_quartiles/out.sql index e7bb16e57c..73cb8c40f4 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,17 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - APPROX_QUANTILES(`bfcol_0`, 4)[OFFSET(1)] AS `bfcol_1`, - APPROX_QUANTILES(`bfcol_0`, 4)[OFFSET(2)] AS `bfcol_2`, - APPROX_QUANTILES(`bfcol_0`, 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 ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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 b61a72d1b2..22d9040352 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - APPROX_TOP_COUNT(`bfcol_0`, 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 ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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 01684b4af6..1d7e80ffd5 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - COUNT(`bfcol_0`) 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 ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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_dense_rank/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_dense_rank/out.sql index 38b6ed9f5c..917bdc6680 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_dense_rank/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_dense_rank/out.sql @@ -1,13 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - DENSE_RANK() OVER (ORDER BY `bfcol_0` IS NULL ASC NULLS LAST, `bfcol_0` ASC NULLS LAST) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + ( + dense_rank() OVER (ORDER BY `t0`.`int64_col` IS NULL ASC, `t0`.`int64_col` ASC) - 1 + ) + 1 AS `agg_int64` +FROM ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 c88fa58d0f..7bfb1f85db 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - MAX(`bfcol_0`) 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 ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/out.sql index 6d4bb6f89a..3b13776d6c 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,22 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `duration_col` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_6`, - `bfcol_0` AS `bfcol_7`, - `bfcol_2` 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 ( + SELECT + `bool_col`, + `int64_col`, + `duration_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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_median/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_median/out.sql index bf7006ef87..055bd6a47f 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,21 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `string_col` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - APPROX_QUANTILES(`bfcol_1`, 2)[OFFSET(1)] AS `bfcol_3`, - APPROX_QUANTILES(`bfcol_0`, 2)[OFFSET(1)] AS `bfcol_4`, - APPROX_QUANTILES(`bfcol_2`, 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 ( + SELECT + `date_col`, + `int64_col`, + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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 b067817218..397759f952 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - MIN(`bfcol_0`) 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 ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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_quantile/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_quantile/out.sql index c1b3d1fffa..89727f4aac 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,16 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - PERCENTILE_CONT(`bfcol_0`, 0.5) OVER () AS `bfcol_1`, - CAST(FLOOR(PERCENTILE_CONT(`bfcol_0`, 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 ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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 5de2330ef6..3a10eef2ae 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - RANK() OVER (ORDER BY `bfcol_0` IS NULL ASC NULLS LAST, `bfcol_0` ASC NULLS LAST) 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 `t0`.`int64_col` IS NULL ASC, `t0`.`int64_col` ASC) - 1 + ) + 1 AS `agg_int64` +FROM ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 be684f6768..f859e20518 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,18 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - COALESCE(SUM(`bfcol_1`), 0) AS `bfcol_4`, - COALESCE(SUM(CAST(`bfcol_0` 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 ( + SELECT + `bool_col`, + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t0` + ) AS `t1` +) AS `t2` \ 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 584ccd9ce1..92968e791f 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,16 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_BOOL( - prompt => (`bfcol_0`, ' is the same as ', `bfcol_0`), - connection_id => 'test_connection_id', - 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 => 'test_connection_id', + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 fca2b965bf..603057a22d 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,16 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_BOOL( - prompt => (`bfcol_0`, ' is the same as ', `bfcol_0`), - connection_id => 'test_connection_id', - 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 => 'test_connection_id', + request_type => 'SHARED', + model_params => JSON '{}' + ) AS `result` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 0baab06c3b..3fb0fa5d90 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,16 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_DOUBLE( - prompt => (`bfcol_0`, ' is the same as ', `bfcol_0`), - connection_id => 'test_connection_id', - 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 => 'test_connection_id', + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 4756cbb509..4eefa979f5 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,16 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_DOUBLE( - prompt => (`bfcol_0`, ' is the same as ', `bfcol_0`), - connection_id => 'test_connection_id', - 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 => 'test_connection_id', + request_type => 'SHARED', + model_params => JSON '{}' + ) AS `result` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 e48b64bead..1094075ab0 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,16 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_INT( - prompt => (`bfcol_0`, ' is the same as ', `bfcol_0`), - connection_id => 'test_connection_id', - 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 => 'test_connection_id', + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 6f406dea18..b03d2c7adf 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,16 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_INT( - prompt => (`bfcol_0`, ' is the same as ', `bfcol_0`), - connection_id => 'test_connection_id', - 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 => 'test_connection_id', + request_type => 'SHARED', + model_params => JSON '{}' + ) AS `result` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 4398084227..f9aa744a2d 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_0`[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 ( + SELECT + `string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:49.414285') +) 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 1ffc3ee8f9..4872ee92ad 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,13 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY( - SELECT - el - FROM UNNEST(`bfcol_0`) 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 ( + SELECT + `string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:49.414285') +) 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 878b60e5e2..8c23820a8c 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,14 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY( - SELECT - el - FROM UNNEST(`bfcol_0`) 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 ( + SELECT + `string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:49.414285') +) 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 4dbd602bea..326e2b8fe9 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY_TO_STRING(`bfcol_0`, '.') 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 ( + SELECT + `string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:49.414285') +) 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 134fdc363b..68566456a1 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` AS `bfcol_0`, - `string_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - OBJ.MAKE_REF(`bfcol_1`, '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 - `bfcol_0` AS `rowindex`, - `bfcol_10` AS `version` -FROM `bfcte_3` \ No newline at end of file + `t0`.`rowindex`, + `OBJ.FETCH_METADATA`( + `OBJ.MAKE_REF`(`t0`.`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') + ).`version` AS `version` +FROM ( + SELECT + `rowindex`, + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 4a963b4972..ca656c878c 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` AS `bfcol_0`, - `string_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - OBJ.MAKE_REF(`bfcol_1`, '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 - `bfcol_0` AS `rowindex`, - `bfcol_10` AS `string_col` -FROM `bfcte_3` \ No newline at end of file + `t0`.`rowindex`, + json_value( + `OBJ.GET_ACCESS_URL`( + `OBJ.MAKE_REF`(`t0`.`string_col`, 'bigframes-dev.test-region.bigframes-default-connection'), + 'R' + ), + '$.access_urls.read_url' + ) AS `string_col` +FROM ( + SELECT + `rowindex`, + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 e3228feaaa..f1f81eab81 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` AS `bfcol_0`, - `string_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - OBJ.MAKE_REF(`bfcol_1`, 'bigframes-dev.test-region.bigframes-default-connection') AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_4` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`rowindex`, + `OBJ.MAKE_REF`(`t0`.`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') AS `string_col` +FROM ( + SELECT + `rowindex`, + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 42c5847401..1b035179b2 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,13 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_0` AS `bfcol_7`, - `bfcol_1` AS `bfcol_8`, - `bfcol_1` & `bfcol_1` 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 ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 d1e7bd1822..534afe8bcf 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,13 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_0` AS `bfcol_7`, - `bfcol_1` AS `bfcol_8`, - `bfcol_1` | `bfcol_1` 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 ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 7d5f74ede7..99650e76f2 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,18 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_0` AS `bfcol_7`, - `bfcol_1` AS `bfcol_8`, - `bfcol_1` ^ `bfcol_1` 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 ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 90cbcfe5c7..a9aa80a683 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,8 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COALESCE(CAST(`bfcol_1` AS STRING), '$NULL_SENTINEL$') = COALESCE(CAST(CAST(`bfcol_0` 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 ( + SELECT + `bool_col`, + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 8e3c52310d..18ff1b3925 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_1` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - `bfcol_1` = `bfcol_1` 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 ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 494cb861a7..6408342a29 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_1` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - `bfcol_1` >= `bfcol_1` 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 ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 b0c8768850..c409c00e60 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_1` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - `bfcol_1` > `bfcol_1` 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 ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 7a1a2a743d..648f7788fc 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,19 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `float64_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COALESCE(`bfcol_0` IN (1, 2, 3), FALSE) AS `bfcol_2`, - ( - `bfcol_0` IS NULL - ) OR `bfcol_0` IN (123456) AS `bfcol_3`, - COALESCE(`bfcol_0` IN (1.0, 2.0, 3.0), FALSE) AS `bfcol_4`, - FALSE AS `bfcol_5`, - COALESCE(`bfcol_0` IN (2.5, 3), FALSE) AS `bfcol_6`, - FALSE AS `bfcol_7`, - COALESCE(`bfcol_0` IN (123456), FALSE) AS `bfcol_8`, - ( - `bfcol_1` IS NULL - ) OR `bfcol_1` 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 ( + SELECT + `int64_col`, + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 2f642d8cbb..0d15d69010 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_1` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - `bfcol_1` <= `bfcol_1` 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 ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 b244e3cbcc..3b2e479a24 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_1` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - `bfcol_1` < `bfcol_1` 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 ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 6fba4b960f..856db48120 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_1` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - `bfcol_1` <> `bfcol_1` 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 ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 a47531999b..4685ae7b4b 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,16 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1`, - `timestamp_col` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_6`, - `bfcol_2` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - TIMESTAMP_ADD(CAST(`bfcol_0` 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 ( + SELECT + `date_col`, + `rowindex`, + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 615a4a92bb..092eab9ecd 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - DATE(`bfcol_0`) 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 ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 460823fa20..fcba29edc3 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(DAY FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(day FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 e6c17587d0..274a2b53a9 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,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(DAYOFWEEK FROM `bfcol_0`) - 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) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 4b60bcc4ca..80f151d497 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(DAYOFYEAR FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(dayofyear FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 ad4fdb23a1..4f317f2d63 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,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIMESTAMP_TRUNC(`bfcol_0`, D) 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 ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 8cc9b9081f..45005c620c 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(HOUR FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(hour FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 d389172fda..766a4efc85 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(DAYOFWEEK FROM `bfcol_0`) 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 ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 f22e963bc3..6f6893fa5e 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(ISOWEEK FROM `bfcol_0`) 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 ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 13b56f709c..25bd4c3c23 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(ISOYEAR FROM `bfcol_0`) 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 ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 4ef9b8142f..cbd871d1c5 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(MINUTE FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(minute FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 4912622898..d245a75a19 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(MONTH FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(month FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 3c7efd3098..4f317f2d63 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIMESTAMP_TRUNC(`bfcol_0`, 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 ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 2be2866661..c1b23753f9 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(QUARTER FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(quarter FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 144b704788..15973e7a6e 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(SECOND FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(second FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 077c30e7cb..44440af1ae 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FORMAT_TIMESTAMP('%Y-%m-%d', `bfcol_0`) 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 ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 2d615fcca6..fc35f95412 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,24 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1`, - `timestamp_col` AS `bfcol_2`, - `duration_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_8`, - `bfcol_2` AS `bfcol_9`, - `bfcol_0` AS `bfcol_10`, - `bfcol_3` 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 ( + SELECT + `date_col`, + `rowindex`, + `timestamp_col`, + `duration_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 6b74efafd5..ad40bc9e3e 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIME(`bfcol_0`) 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 ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 096f14cc85..7f4e89bcc3 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(TIMESTAMP_SECONDS(`bfcol_0`) 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 ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 b1e66ce3e7..dfa4bfc7d2 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIMESTAMP_SECONDS(`bfcol_0`) 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 ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 dcbf0be5c2..d3b66c12c6 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_MICROS(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + unix_micros(`t0`.`timestamp_col`) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 ca58fbc97c..f44301daab 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_MILLIS(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + unix_millis(`t0`.`timestamp_col`) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 21f0b7b8c8..205b775ca3 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_SECONDS(`bfcol_0`) 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 ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 8352a65e9e..234777b9b4 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(YEAR FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(year FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 440aea9161..61df5e7ae0 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,10 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `float64_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_0` AS `bfcol_2`, - `bfcol_1` <> 0 AS `bfcol_3`, - `bfcol_1` <> 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 ( + SELECT + `bool_col`, + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 81a8805f47..943d62875a 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,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(CAST(`bfcol_0` AS INT64) AS FLOAT64) AS `bfcol_1`, - CAST('1.34235e4' AS FLOAT64) AS `bfcol_2`, - SAFE_CAST(SAFE_CAST(`bfcol_0` 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 ( + SELECT + `bool_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 25d51b26b3..09b0df97f4 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - INT64(`bfcol_0`) AS `bfcol_1`, - FLOAT64(`bfcol_0`) AS `bfcol_2`, - BOOL(`bfcol_0`) AS `bfcol_3`, - STRING(`bfcol_0`) AS `bfcol_4`, - SAFE.INT64(`bfcol_0`) 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(`t0`.`json_col`) AS `int64_col`, + FLOAT64(`t0`.`json_col`) AS `float64_col`, + BOOL(`t0`.`json_col`) AS `bool_col`, + STRING(`t0`.`json_col`) AS `string_col`, + SAFE.INT64(`t0`.`json_col`) AS `int64_w_safe` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:50.715543') +) AS `t0` \ 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 22aa2cf91a..eb36e00b3f 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,19 @@ -WITH `bfcte_0` AS ( - SELECT - `datetime_col` AS `bfcol_0`, - `numeric_col` AS `bfcol_1`, - `float64_col` AS `bfcol_2`, - `time_col` AS `bfcol_3`, - `timestamp_col` AS `bfcol_4` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_MICROS(CAST(`bfcol_0` AS TIMESTAMP)) AS `bfcol_5`, - UNIX_MICROS(SAFE_CAST(`bfcol_0` AS TIMESTAMP)) AS `bfcol_6`, - TIME_DIFF(CAST(`bfcol_3` AS TIME), '00:00:00', MICROSECOND) AS `bfcol_7`, - TIME_DIFF(SAFE_CAST(`bfcol_3` AS TIME), '00:00:00', MICROSECOND) AS `bfcol_8`, - UNIX_MICROS(`bfcol_4`) AS `bfcol_9`, - CAST(TRUNC(`bfcol_1`) AS INT64) AS `bfcol_10`, - CAST(TRUNC(`bfcol_2`) AS INT64) AS `bfcol_11`, - SAFE_CAST(TRUNC(`bfcol_2`) 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 ( + SELECT + `datetime_col`, + `numeric_col`, + `float64_col`, + `time_col`, + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 8230b4a60b..183c0e1251 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` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `float64_col` AS `bfcol_2`, - `string_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - PARSE_JSON(CAST(`bfcol_1` AS STRING)) AS `bfcol_4`, - PARSE_JSON(CAST(`bfcol_2` AS STRING)) AS `bfcol_5`, - PARSE_JSON(CAST(`bfcol_0` AS STRING)) AS `bfcol_6`, - PARSE_JSON(`bfcol_3`) AS `bfcol_7`, - PARSE_JSON(CAST(`bfcol_0` AS STRING)) AS `bfcol_8`, - PARSE_JSON_IN_SAFE(`bfcol_3`) 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(`t0`.`int64_col` AS STRING)) AS `int64_col`, + PARSE_JSON(CAST(`t0`.`float64_col` AS STRING)) AS `float64_col`, + PARSE_JSON( + LOWER( + 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`, + PARSE_JSON(`t0`.`string_col`) AS `string_col`, + SAFE.PARSE_JSON( + LOWER( + 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`, + SAFE.PARSE_JSON(`t0`.`string_col`) AS `string_w_safe` +FROM ( + SELECT + `bool_col`, + `int64_col`, + `float64_col`, + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 f230a3799e..b1ac406dde 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,48 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(`bfcol_1` AS STRING) AS `bfcol_2`, - INITCAP(CAST(`bfcol_0` AS STRING)) AS `bfcol_3`, - INITCAP(SAFE_CAST(`bfcol_0` 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 ( + SELECT + `bool_col`, + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 141b7ffa9a..cb5772df23 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,10 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(TIMESTAMP_MICROS(`bfcol_0`) AS DATETIME) AS `bfcol_1`, - CAST(TIMESTAMP_MICROS(`bfcol_0`) AS TIME) AS `bfcol_2`, - CAST(TIMESTAMP_MICROS(`bfcol_0`) AS TIMESTAMP) AS `bfcol_3`, - SAFE_CAST(TIMESTAMP_MICROS(`bfcol_0`) 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 ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 14d6df6d22..2ae6dc0145 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FARM_FINGERPRINT(`bfcol_0`) 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 55a2ebb970..7af4fe0365 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_0` 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 a17d6584ce..0c883e9aeb 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE `bfcol_0` 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 c1961f9d62..273480c217 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,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - NOT `bfcol_0` 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 9b4b6894e0..6f4de54c05 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_AREA(`bfcol_0`) 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 ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 9557e2f1d6..ee182f46ea 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_ASTEXT(`bfcol_0`) 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 ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 31c0b45034..b2af317e9c 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_BOUNDARY(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_boundary(`t0`.`geography_col`) AS `geography_col` +FROM ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 9669c39a9f..a97e62145f 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_BUFFER(`bfcol_0`, 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(`t0`.`geography_col`, 1.0, 8.0, FALSE) AS `geography_col` +FROM ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 97867318ad..820489b99a 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_CENTROID(`bfcol_0`) 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 ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 8bb5801173..6f0b1796d2 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_CONVEXHULL(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_convexhull(`t0`.`geography_col`) AS `geography_col` +FROM ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 ba4d9dd182..c453975f18 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SAFE.ST_GEOGFROMTEXT(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + st_geogfromtext(`t0`.`string_col`) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 d905e8470b..1c9104c028 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_ISCLOSED(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_isclosed(`t0`.`geography_col`) AS `geography_col` +FROM ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 a023691d63..f84d730e4b 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_LENGTH(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_length(`t0`.`geography_col`, TRUE) AS `geography_col` +FROM ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 d4c0370ca8..b2697680ce 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SAFE.ST_X(`bfcol_0`) 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 ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 196c2fcad6..c4bf0065e5 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SAFE.ST_Y(`bfcol_0`) 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 ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 3d23bd1e3e..2bef4d8d61 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_EXTRACT(`bfcol_0`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_EXTRACT(`t0`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:50.715543') +) AS `t0` \ 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 1ddb3999b3..0249663216 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_EXTRACT_ARRAY(`bfcol_0`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_EXTRACT_ARRAY(`t0`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:50.715543') +) AS `t0` \ 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 cbc3df74c0..4ee5244c59 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_EXTRACT_STRING_ARRAY(`bfcol_0`, '$') 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(`t0`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:50.715543') +) AS `t0` \ 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 b5d98b80d2..3693ce4acd 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_QUERY(`bfcol_0`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + json_query(`t0`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:50.715543') +) AS `t0` \ 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 1b7a5908eb..c9930ab503 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_QUERY_ARRAY(`bfcol_0`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + json_query_array(`t0`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:50.715543') +) AS `t0` \ 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 b226066b16..70b5970675 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_SET(`bfcol_0`, '$.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(`t0`.`json_col`, '$.a', 100) AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:50.715543') +) AS `t0` \ 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 3a84a1a92a..82a0d6485c 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_VALUE(`bfcol_0`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + json_value(`t0`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:50.715543') +) AS `t0` \ 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 cdb091ae39..3a5661de98 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - PARSE_JSON(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + PARSE_JSON(`t0`.`string_col`) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 2786973933..25dbdafde9 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - TO_JSON_STRING(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + to_json_string(`t0`.`json_col`) AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:50.715543') +) AS `t0` \ 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 6f315f8113..7d80789a92 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ABS(`bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 44335805e4..fd570e83a3 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_1` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - `bfcol_1` + `bfcol_1` 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 ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 df695b7fbc..770c54e135 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,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN ABS(`bfcol_0`) > 1 THEN CAST('NaN' AS FLOAT64) ELSE ACOS(`bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 5272e4a6a8..9342d43d5d 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,13 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `bfcol_0` < 1 THEN CAST('NaN' AS FLOAT64) ELSE ACOSH(`bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 3afc7c64b8..9fd43d61c8 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,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN ABS(`bfcol_0`) > 1 THEN CAST('NaN' AS FLOAT64) ELSE ASIN(`bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 6313e80e5f..45d9a28db5 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,11 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ASINH(`bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 ec6a22e653..6baeede14f 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ATAN(`bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 39b5f565fe..278c13f664 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,13 +1,17 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN ABS(`bfcol_0`) > 1 THEN CAST('NaN' AS FLOAT64) ELSE ATANH(`bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 0959f3a0ad..359435eeef 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CEIL(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CEIL(`t0`.`float64_col`) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 126d2a63f2..3f3c938e2e 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COS(`bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 f44dfaac41..57741195d0 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`bfcol_0`) > 709.78 - THEN CAST('Infinity' AS FLOAT64) - ELSE COSH(`bfcol_0`) - 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 03d48276a0..3aa224e2c6 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,21 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `float64_col` AS `bfcol_2`, - `rowindex` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_3` AS `bfcol_8`, - `bfcol_1` AS `bfcol_9`, - `bfcol_0` AS `bfcol_10`, - `bfcol_2` AS `bfcol_11`, - IEEE_DIVIDE(`bfcol_1`, `bfcol_1`) 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 ( + SELECT + `bool_col`, + `int64_col`, + `float64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 6e05302fc9..56ffa87917 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,12 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1`, - `timestamp_col` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_6`, - `bfcol_2` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - CAST(FLOOR(IEEE_DIVIDE(86400000000, `bfcol_0`)) 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 ( + SELECT + `int64_col`, + `rowindex`, + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 6afa3f85a5..f59d3ba734 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,13 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `bfcol_0` > 709.78 - THEN CAST('Infinity' AS FLOAT64) - ELSE EXP(`bfcol_0`) - 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 f3768deb4a..a5343913c3 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,13 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `bfcol_0` > 709.78 - THEN CAST('Infinity' AS FLOAT64) - ELSE EXP(`bfcol_0`) - 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 56be1019e5..29bdee4e7c 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FLOOR(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + FLOOR(`t0`.`float64_col`) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 bc4f94d306..7fd8005b54 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,12 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1`, - `timestamp_col` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - 43200000000 AS `bfcol_6` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `rowindex`, - `bfcol_2` AS `timestamp_col`, - `bfcol_0` AS `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 ( + SELECT + `date_col`, + `rowindex`, + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_invert/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_invert/out.sql index 28f2aa6e06..1d8e3f4b00 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_invert/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_invert/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ~`bfcol_0` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + ~`t0`.`int64_col` AS `int64_col` +FROM ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 1372c088d9..0abf2874c7 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,13 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `bfcol_0` < 0 THEN CAST('NaN' AS FLOAT64) ELSE LN(`bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 b4cced439b..739b2f807d 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,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `bfcol_0` < 0 THEN CAST('NaN' AS FLOAT64) ELSE LOG(10, `bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 c3902ec174..9edcf5a8f0 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,13 +1,21 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `bfcol_0` < -1 THEN CAST('NaN' AS FLOAT64) ELSE LN(1 + `bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 a9c81f4744..2668ed213e 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_1` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - `bfcol_1` * `bfcol_1` 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 ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 46c58f766d..2d4957e310 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,13 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - -`bfcol_0` 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 2d6322a182..d5dc3f7b64 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_0` 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 62a5cff0b5..9ea618244f 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SIN(`bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 711dba94a9..8a39dead1b 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`bfcol_0`) > 709.78 - THEN SIGN(`bfcol_0`) * CAST('Infinity' AS FLOAT64) - ELSE SINH(`bfcol_0`) - 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 e6a93e5e6c..072742b759 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,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `bfcol_0` < 0 THEN CAST('NaN' AS FLOAT64) ELSE SQRT(`bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 a43fa2df67..77507bce0e 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_1` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - `bfcol_1` - `bfcol_1` 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 ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 5fac274b6b..9d919667af 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TAN(`bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 5d1a5a5320..1af867a321 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,20 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TANH(`bfcol_0`) 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 ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 de5129a6a3..23a30f57c5 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CONCAT(`bfcol_0`, '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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 7af1708347..2c85064e36 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,22 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - INITCAP(`bfcol_0`) 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 e3ac5ec033..b95e442437 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,9 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ENDS_WITH(`bfcol_0`, 'ab') AS `bfcol_1`, - ENDS_WITH(`bfcol_0`, 'ab') OR ENDS_WITH(`bfcol_0`, '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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 02e0094742..1d454cc83e 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, '^(\\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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 2615d0452f..db4da4baff 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, '^\\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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 bc1fce3dbc..2ebe653776 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, '^\\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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 1cb3a883ab..be159e4a60 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,10 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, '^\\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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 a621b71a3b..eeb0835739 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,10 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LOWER(`bfcol_0`) = `bfcol_0` AND UPPER(`bfcol_0`) <> `bfcol_0` 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 6566c1dd4c..8ee9432e05 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, '^\\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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 aff12102be..6f153b9232 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, '^\\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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 03fe005910..ae2004f0e4 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,10 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UPPER(`bfcol_0`) = `bfcol_0` AND LOWER(`bfcol_0`) <> `bfcol_0` 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 35fd087bc7..a302f0b42e 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LENGTH(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CAST(LENGTH(`t0`.`string_col`) AS INT64) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 e730cdee15..efe6a019d9 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LOWER(`bfcol_0`) 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 49ed89b40b..1163e82934 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TRIM(`bfcol_0`, ' ') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + LTRIM(`t0`.`string_col`, ' ') AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 149df6706c..2955e43bb1 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_REPLACE(`bfcol_0`, '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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 3bd7e0e47e..f1ca908ecb 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REPLACE(`bfcol_0`, '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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 1ef1074149..9c53d0f9d3 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REVERSE(`bfcol_0`) 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 49ed89b40b..06ae6bd167 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TRIM(`bfcol_0`, ' ') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + RTRIM(`t0`.`string_col`, ' ') AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 9679c95f75..bc83584d8b 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,9 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - STARTS_WITH(`bfcol_0`, 'ab') AS `bfcol_1`, - STARTS_WITH(`bfcol_0`, 'ab') OR STARTS_WITH(`bfcol_0`, '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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 a1aa0539ee..ce21361c8c 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_0` 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 d0383172cb..d7721e624b 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, '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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 a7fac093e2..b15ffcdc04 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_EXTRACT(`bfcol_0`, '([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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 1278c3435d..520f633714 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,12 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SUBSTRING(`bfcol_0`, 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 4226843122..32c26e8a90 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,21 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LPAD(`bfcol_0`, GREATEST(LENGTH(`bfcol_0`), 10), '-') AS `bfcol_1`, - RPAD(`bfcol_0`, GREATEST(LENGTH(`bfcol_0`), 10), '-') AS `bfcol_2`, - RPAD( - LPAD( - `bfcol_0`, - CAST(SAFE_DIVIDE(GREATEST(LENGTH(`bfcol_0`), 10) - LENGTH(`bfcol_0`), 2) AS INT64) + LENGTH(`bfcol_0`), - '-' - ), - GREATEST(LENGTH(`bfcol_0`), 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 1c94cfafe2..7a9eb03820 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REPEAT(`bfcol_0`, 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 4f97ab3ac6..41fe77f908 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,20 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SUBSTRING(`bfcol_0`, 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 fea0d6eaf1..06da810a0e 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SPLIT(`bfcol_0`, ',') 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 311f2c1727..849652e95d 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` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TRIM(' ', `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + TRIM(`t0`.`string_col`, ' ') AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0` \ 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 d22c8cff5a..797f3abbd6 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UPPER(`bfcol_0`) 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 e5d70ab44b..e5dde4ae4a 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,29 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN SUBSTRING(`bfcol_0`, 1, 1) = '-' - THEN CONCAT('-', LPAD(SUBSTRING(`bfcol_0`, 1), 9, '0')) - ELSE LPAD(`bfcol_0`, 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 ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 60ae78b755..7081eb0faa 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,8 @@ -WITH `bfcte_0` AS ( - SELECT - `people` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_0`.`name` AS `bfcol_1`, - `bfcol_0`.`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 ( + SELECT + `people` + FROM `bigframes-dev.sqlglot_test.nested_structs_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:52.992529') +) 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 1a8b9f4e39..0ed7bfbd93 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FLOOR(`bfcol_0`) 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 ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 057e6c778e..11e3b2d90c 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,12 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_4`, - `bfcol_0` AS `bfcol_5`, - `bfcol_0` 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 ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 02bba41a22..406298f480 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,30 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_too` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_2`, - `bfcol_0` 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_844` AS `bool_col`, + `t2`.`bfuid_col_845` 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_844`, + COALESCE(SUM(`t1`.`bfuid_col_843`), 0) AS `bfuid_col_845` + FROM ( + SELECT + `t0`.`int64_too` AS `bfuid_col_843`, + `t0`.`bool_col` AS `bfuid_col_844` + FROM ( + SELECT + `bool_col`, + `int64_too` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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_844` + ) 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 b8e127eb77..96df604919 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,26 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_too` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_2`, - `bfcol_0` 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_848` AS `bool_col`, + `t2`.`bfuid_col_849` AS `int64_too` +FROM ( SELECT - `bfcol_3`, - COALESCE(SUM(`bfcol_2`), 0) AS `bfcol_6` - FROM `bfcte_1` + `t1`.`bfuid_col_848`, + COALESCE(SUM(`t1`.`bfuid_col_847`), 0) AS `bfuid_col_849` + FROM ( + SELECT + `t0`.`int64_too` AS `bfuid_col_847`, + `t0`.`bool_col` AS `bfuid_col_848` + FROM ( + SELECT + `bool_col`, + `int64_too` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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 62e22a6a19..f902a48ce2 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,78 +1,44 @@ -WITH `bfcte_1` AS ( - SELECT - * - FROM UNNEST(ARRAY>[STRUCT(0, 123456789, 0, 'Hello, World!', 0), STRUCT(1, -987654321, 1, 'こんにちは', 1), STRUCT(2, 314159, 2, ' ¡Hola Mundo! ', 2), STRUCT(3, CAST(NULL AS INT64), 3, CAST(NULL AS STRING), 3), STRUCT(4, -234892, 4, 'Hello, World!', 4), STRUCT(5, 55555, 5, 'Güten Tag!', 5), STRUCT(6, 101202303, 6, 'capitalize, This ', 6), STRUCT(7, -214748367, 7, ' سلام', 7), STRUCT(8, 2, 8, 'T', 8)]) -), `bfcte_3` AS ( - SELECT - *, - `bfcol_4` AS `bfcol_10` - FROM `bfcte_1` -), `bfcte_5` AS ( - SELECT - *, - 0 AS `bfcol_16` - FROM `bfcte_3` -), `bfcte_6` AS ( - SELECT - `bfcol_0` AS `bfcol_17`, - `bfcol_2` AS `bfcol_18`, - `bfcol_1` AS `bfcol_19`, - `bfcol_3` AS `bfcol_20`, - `bfcol_16` AS `bfcol_21`, - `bfcol_10` AS `bfcol_22` - FROM `bfcte_5` -), `bfcte_0` AS ( +SELECT +`rowindex` AS `rowindex`, +`rowindex_1` AS `rowindex_1`, +`int64_col` AS `int64_col`, +`string_col` AS `string_col` +FROM +(SELECT + * +FROM ( SELECT * - FROM UNNEST(ARRAY>[STRUCT(0, 123456789, 0, 'Hello, World!', 0), STRUCT(1, -987654321, 1, 'こんにちは', 1), STRUCT(2, 314159, 2, ' ¡Hola Mundo! ', 2), STRUCT(3, CAST(NULL AS INT64), 3, CAST(NULL AS STRING), 3), STRUCT(4, -234892, 4, 'Hello, World!', 4), STRUCT(5, 55555, 5, 'Güten Tag!', 5), STRUCT(6, 101202303, 6, 'capitalize, This ', 6), STRUCT(7, -214748367, 7, ' سلام', 7), STRUCT(8, 2, 8, 'T', 8)]) -), `bfcte_2` AS ( - SELECT - *, - `bfcol_27` AS `bfcol_33` - FROM `bfcte_0` -), `bfcte_4` AS ( - SELECT - *, - 1 AS `bfcol_39` - FROM `bfcte_2` -), `bfcte_7` AS ( - SELECT - `bfcol_23` AS `bfcol_40`, - `bfcol_25` AS `bfcol_41`, - `bfcol_24` AS `bfcol_42`, - `bfcol_26` AS `bfcol_43`, - `bfcol_39` AS `bfcol_44`, - `bfcol_33` AS `bfcol_45` - FROM `bfcte_4` -), `bfcte_8` AS ( + FROM ( + SELECT + `t0`.`level_0` AS `rowindex`, + `t0`.`column_9` AS `rowindex_1`, + `t0`.`column_5` AS `int64_col`, + `t0`.`column_11` AS `string_col`, + 0 AS `bfuid_col_861`, + `t0`.`bfuid_col_854` AS `bfuid_col_860` + FROM ( + SELECT + * + FROM UNNEST(ARRAY>[STRUCT(0, 123456789, 0, 'Hello, World!', 0), STRUCT(1, -987654321, 1, 'こんにちは', 1), STRUCT(2, 314159, 2, ' ¡Hola Mundo! ', 2), STRUCT(3, CAST(NULL AS INT64), 3, CAST(NULL AS STRING), 3), STRUCT(4, -234892, 4, 'Hello, World!', 4), STRUCT(5, 55555, 5, 'Güten Tag!', 5), STRUCT(6, 101202303, 6, 'capitalize, This ', 6), STRUCT(7, -214748367, 7, ' سلام', 7), STRUCT(8, 2, 8, 'T', 8)]) AS `level_0` + ) AS `t0` + ) AS `t1` + UNION ALL SELECT * FROM ( SELECT - `bfcol_17` AS `bfcol_46`, - `bfcol_18` AS `bfcol_47`, - `bfcol_19` AS `bfcol_48`, - `bfcol_20` AS `bfcol_49`, - `bfcol_21` AS `bfcol_50`, - `bfcol_22` AS `bfcol_51` - FROM `bfcte_6` - UNION ALL - SELECT - `bfcol_40` AS `bfcol_46`, - `bfcol_41` AS `bfcol_47`, - `bfcol_42` AS `bfcol_48`, - `bfcol_43` AS `bfcol_49`, - `bfcol_44` AS `bfcol_50`, - `bfcol_45` AS `bfcol_51` - FROM `bfcte_7` - ) -) -SELECT - `bfcol_46` AS `rowindex`, - `bfcol_47` AS `rowindex_1`, - `bfcol_48` AS `int64_col`, - `bfcol_49` AS `string_col` -FROM `bfcte_8` -ORDER BY - `bfcol_50` ASC NULLS LAST, - `bfcol_51` ASC NULLS LAST \ No newline at end of file + `t0`.`level_0` AS `rowindex`, + `t0`.`column_9` AS `rowindex_1`, + `t0`.`column_5` AS `int64_col`, + `t0`.`column_11` AS `string_col`, + 1 AS `bfuid_col_861`, + `t0`.`bfuid_col_854` AS `bfuid_col_860` + FROM ( + SELECT + * + FROM UNNEST(ARRAY>[STRUCT(0, 123456789, 0, 'Hello, World!', 0), STRUCT(1, -987654321, 1, 'こんにちは', 1), STRUCT(2, 314159, 2, ' ¡Hola Mundo! ', 2), STRUCT(3, CAST(NULL AS INT64), 3, CAST(NULL AS STRING), 3), STRUCT(4, -234892, 4, 'Hello, World!', 4), STRUCT(5, 55555, 5, 'Güten Tag!', 5), STRUCT(6, 101202303, 6, 'capitalize, This ', 6), STRUCT(7, -214748367, 7, ' سلام', 7), STRUCT(8, 2, 8, 'T', 8)]) AS `level_0` + ) AS `t0` + ) AS `t2` +) AS `t3`) +ORDER BY `bfuid_col_861` ASC NULLS LAST ,`bfuid_col_860` 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 679da58f44..38ca935303 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,65 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `int_list_col` AS `bfcol_1`, - `string_list_col` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - * - REPLACE (`bfcol_1`[SAFE_OFFSET(`bfcol_13`)] AS `bfcol_1`, `bfcol_2`[SAFE_OFFSET(`bfcol_13`)] AS `bfcol_2`) - FROM `bfcte_0` - CROSS JOIN UNNEST(GENERATE_ARRAY(0, LEAST(ARRAY_LENGTH(`bfcol_1`) - 1, ARRAY_LENGTH(`bfcol_2`) - 1))) AS `bfcol_13` WITH OFFSET AS `bfcol_7` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_0` AS `rowindex_1`, - `bfcol_1` AS `int_list_col`, - `bfcol_2` AS `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_14` AS `rowindex`, + `t2`.`rowindex` AS `rowindex_1`, + `t2`.`int_list_col`[safe_offset(`t2`.`bfuid_col_865`)] AS `int_list_col`, + `t2`.`string_list_col`[safe_offset(`t2`.`bfuid_col_865`)] AS `string_list_col`, + `t2`.`bfuid_col_865` AS `bfuid_col_866` +FROM ( + SELECT + IF(pos = pos_2, `bfuid_col_865`, NULL) AS `bfuid_col_865`, + `t1`.`bfuid_col_14`, + `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_p4f3jchzhrapvau7lx6m67czgi + 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_p4f3jchzhrapvau7lx6m67czgi + WHERE + ibis_bq_arr_range_p4f3jchzhrapvau7lx6m67czgi <> GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`), ARRAY_LENGTH(`t0`.`string_list_col`))) + ), + [] + ) AS `bfuid_offset_array_867`, + `t0`.`rowindex` AS `bfuid_col_14`, + `t0`.`rowindex`, + `t0`.`int_list_col`, + `t0`.`string_list_col` + FROM ( + SELECT + `rowindex`, + `int_list_col`, + `string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:49.414285') + ) AS `t0` + ) AS `t1` + CROSS JOIN UNNEST(GENERATE_ARRAY(0, GREATEST(ARRAY_LENGTH(`t1`.`bfuid_offset_array_867`)) - 1)) AS pos + CROSS JOIN UNNEST(`t1`.`bfuid_offset_array_867`) AS `bfuid_col_865` WITH OFFSET AS pos_2 + WHERE + pos = pos_2 + OR ( + pos > ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_867`) - 1 + ) + AND pos_2 = ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_867`) - 1 + ) + ) +) AS `t2`) +ORDER BY `bfuid_col_866` 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 8bfd1eb005..79b044d02c 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,50 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `int_list_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - * - REPLACE (`bfcol_8` AS `bfcol_1`) - FROM `bfcte_0` - CROSS JOIN UNNEST(`bfcol_1`) AS `bfcol_8` WITH OFFSET AS `bfcol_4` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_1` AS `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_14` AS `rowindex`, + `t2`.`int_list_col`[safe_offset(`t2`.`bfuid_col_862`)] AS `int_list_col`, + `t2`.`bfuid_col_862` AS `bfuid_col_863` +FROM ( + SELECT + IF(pos = pos_2, `bfuid_col_862`, NULL) AS `bfuid_col_862`, + `t1`.`bfuid_col_14`, + `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_j4jb5nswzzew5gjdx57miqodry + FROM UNNEST(generate_array(0, GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`))), 1)) AS ibis_bq_arr_range_j4jb5nswzzew5gjdx57miqodry + WHERE + ibis_bq_arr_range_j4jb5nswzzew5gjdx57miqodry <> GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`))) + ), + [] + ) AS `bfuid_offset_array_864`, + `t0`.`rowindex` AS `bfuid_col_14`, + `t0`.`int_list_col` + FROM ( + SELECT + `rowindex`, + `int_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:49.414285') + ) AS `t0` + ) AS `t1` + CROSS JOIN UNNEST(GENERATE_ARRAY(0, GREATEST(ARRAY_LENGTH(`t1`.`bfuid_offset_array_864`)) - 1)) AS pos + CROSS JOIN UNNEST(`t1`.`bfuid_offset_array_864`) AS `bfuid_col_862` WITH OFFSET AS pos_2 + WHERE + pos = pos_2 + OR ( + pos > ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_864`) - 1 + ) + AND pos_2 = ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_864`) - 1 + ) + ) +) AS `t2`) +ORDER BY `bfuid_col_863` 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 9ca7fb6a74..e431995713 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,12 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_5`, - `bfcol_1` AS `bfcol_6`, - `bfcol_0` AS `bfcol_7`, - `bfcol_1` >= 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 ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 e3bb0f9eba..0d1e51488d 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,37 +1,39 @@ -WITH `bfcte_1` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `bfcol_1` AS `bfcol_2`, - `bfcol_0` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `int64_too` AS `bfcol_4` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( - SELECT - `bfcte_2`.*, - EXISTS( +SELECT + `t2`.`bfuid_col_1` AS `rowindex`, + EXISTS( + SELECT + 1 + FROM ( SELECT - 1 + `t3`.`int64_too` FROM ( SELECT - `bfcol_4` - FROM `bfcte_0` - GROUP BY - `bfcol_4` - ) AS `bft_0` - WHERE - COALESCE(`bfcte_2`.`bfcol_3`, 0) = COALESCE(`bft_0`.`bfcol_4`, 0) - AND COALESCE(`bfcte_2`.`bfcol_3`, 1) = COALESCE(`bft_0`.`bfcol_4`, 1) - ) AS `bfcol_5` - FROM `bfcte_2` -) -SELECT - `bfcol_2` AS `rowindex`, - `bfcol_5` AS `int64_col` -FROM `bfcte_3` \ No newline at end of file + `t1`.`int64_too` + FROM ( + SELECT + `int64_too` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t1` + ) AS `t3` + GROUP BY + 1 + ) AS `t4` + WHERE + ( + COALESCE(`t2`.`int64_col`, 0) = COALESCE(`t4`.`int64_too`, 0) + ) + AND ( + COALESCE(`t2`.`int64_col`, 1) = COALESCE(`t4`.`int64_too`, 1) + ) + ) AS `int64_col` +FROM ( + SELECT + `t0`.`rowindex` AS `bfuid_col_1`, + `t0`.`int64_col` + FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t0` +) AS `t2` \ 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 f96a9816dc..06d6c5c4f4 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,30 +1,32 @@ -WITH `bfcte_1` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `rowindex_2` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `bfcol_0` AS `bfcol_2`, - `bfcol_1` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `rowindex_2` AS `bfcol_4` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( - SELECT - `bfcte_2`.*, - `bfcte_2`.`bfcol_3` IN (( - SELECT - `bfcol_4` - FROM `bfcte_0` - GROUP BY - `bfcol_4` - )) AS `bfcol_5` - FROM `bfcte_2` -) SELECT - `bfcol_2` AS `rowindex`, - `bfcol_5` AS `rowindex_2` -FROM `bfcte_3` \ No newline at end of file + `t2`.`bfuid_col_1` AS `rowindex`, + `t2`.`rowindex_2` IN ( + SELECT + * + FROM ( + SELECT + `t3`.`rowindex_2` + FROM ( + SELECT + `t1`.`rowindex_2` + FROM ( + SELECT + `rowindex_2` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t1` + ) AS `t3` + GROUP BY + 1 + ) AS `t4` + ) AS `rowindex_2` +FROM ( + SELECT + `t0`.`rowindex` AS `bfuid_col_1`, + `t0`.`rowindex_2` + FROM ( + SELECT + `rowindex`, + `rowindex_2` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t0` +) AS `t2` \ 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 04ee767f8a..6b34700af8 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,27 @@ -WITH `bfcte_1` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `bfcol_1` AS `bfcol_2`, - `bfcol_0` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_4`, - `int64_too` AS `bfcol_5` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t4`.`int64_col`, + `t5`.`int64_too` +FROM ( SELECT - `bfcol_4` AS `bfcol_6`, - `bfcol_5` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex` AS `bfuid_col_1`, + `t0`.`int64_col` + FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t0` +) AS `t4` +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 + `t1`.`int64_col` AS `bfuid_col_875`, + `t1`.`int64_too` + FROM ( + SELECT + `int64_col`, + `int64_too` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t1` +) AS `t5` + ON COALESCE(`t4`.`bfuid_col_1`, 0) = COALESCE(`t5`.`bfuid_col_875`, 0) + AND COALESCE(`t4`.`bfuid_col_1`, 1) = COALESCE(`t5`.`bfuid_col_875`, 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 05d5fd0695..042af9a88f 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,28 @@ -WITH `bfcte_1` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `bfcol_1` AS `bfcol_2`, - `bfcol_0` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_4`, - `rowindex` AS `bfcol_5` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`bool_col`, + `t4`.`bfuid_col_878` AS `rowindex_y` +FROM ( SELECT - `bfcol_5` AS `bfcol_6`, - `bfcol_4` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`bool_col` + FROM ( + SELECT + `bool_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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_878`, + `t0`.`bool_col` AS `bfuid_col_879` + FROM ( + SELECT + `bool_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t0` +) AS `t4` + ON COALESCE(CAST(`t3`.`bool_col` AS STRING), '0') = COALESCE(CAST(`t4`.`bfuid_col_879` AS STRING), '0') + AND COALESCE(CAST(`t3`.`bool_col` AS STRING), '1') = COALESCE(CAST(`t4`.`bfuid_col_879` 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 9e6a4094b2..21072d4477 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,28 @@ -WITH `bfcte_1` AS ( - SELECT - `float64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `bfcol_1` AS `bfcol_2`, - `bfcol_0` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_4`, - `rowindex` AS `bfcol_5` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`float64_col`, + `t4`.`bfuid_col_884` AS `rowindex_y` +FROM ( SELECT - `bfcol_5` AS `bfcol_6`, - `bfcol_4` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`float64_col` + FROM ( + SELECT + `float64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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_884`, + `t0`.`float64_col` AS `bfuid_col_885` + FROM ( + SELECT + `float64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t0` +) AS `t4` + ON IF(IS_NAN(`t3`.`float64_col`), 2, COALESCE(`t3`.`float64_col`, 0)) = IF(IS_NAN(`t4`.`bfuid_col_885`), 2, COALESCE(`t4`.`bfuid_col_885`, 0)) + AND IF(IS_NAN(`t3`.`float64_col`), 3, COALESCE(`t3`.`float64_col`, 1)) = IF(IS_NAN(`t4`.`bfuid_col_885`), 3, COALESCE(`t4`.`bfuid_col_885`, 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 bd03e05cba..7db339e2d0 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,28 @@ -WITH `bfcte_1` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `bfcol_1` AS `bfcol_2`, - `bfcol_0` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_4`, - `rowindex` AS `bfcol_5` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`int64_col`, + `t4`.`bfuid_col_881` AS `rowindex_y` +FROM ( SELECT - `bfcol_5` AS `bfcol_6`, - `bfcol_4` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`int64_col` + FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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_881`, + `t0`.`int64_col` AS `bfuid_col_882` + FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t0` +) AS `t4` + ON COALESCE(`t3`.`int64_col`, 0) = COALESCE(`t4`.`bfuid_col_882`, 0) + AND COALESCE(`t3`.`int64_col`, 1) = COALESCE(`t4`.`bfuid_col_882`, 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 6b77ead97c..560fdcda83 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,28 @@ -WITH `bfcte_1` AS ( - SELECT - `numeric_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `bfcol_1` AS `bfcol_2`, - `bfcol_0` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `numeric_col` AS `bfcol_4`, - `rowindex` AS `bfcol_5` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`numeric_col`, + `t4`.`bfuid_col_893` AS `rowindex_y` +FROM ( SELECT - `bfcol_5` AS `bfcol_6`, - `bfcol_4` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`numeric_col` + FROM ( + SELECT + `numeric_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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_893`, + `t0`.`numeric_col` AS `bfuid_col_894` + FROM ( + SELECT + `numeric_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t0` +) AS `t4` + ON COALESCE(`t3`.`numeric_col`, 0) = COALESCE(`t4`.`bfuid_col_894`, 0) + AND COALESCE(`t3`.`numeric_col`, 1) = COALESCE(`t4`.`bfuid_col_894`, 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 1903d5fc22..8daf9981ed 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,28 +1,28 @@ -WITH `bfcte_1` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `string_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_2`, - `string_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`string_col`, + `t4`.`bfuid_col_887` AS `rowindex_y` +FROM ( SELECT - `bfcol_2` AS `bfcol_4`, - `bfcol_3` AS `bfcol_5` - FROM `bfcte_0` -), `bfcte_3` AS ( + `t0`.`rowindex`, + `t0`.`string_col` + FROM ( + SELECT + `rowindex`, + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_1` - INNER JOIN `bfcte_2` - 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_3` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_887`, + `t0`.`string_col` AS `bfuid_col_888` + FROM ( + SELECT + `rowindex`, + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t0` +) AS `t4` + ON COALESCE(`t3`.`string_col`, '0') = COALESCE(`t4`.`bfuid_col_888`, '0') + AND COALESCE(`t3`.`string_col`, '1') = COALESCE(`t4`.`bfuid_col_888`, '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 9e3477d4a9..c18769170a 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,28 +1,28 @@ -WITH `bfcte_1` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `time_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_2`, - `time_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`time_col`, + `t4`.`bfuid_col_890` AS `rowindex_y` +FROM ( SELECT - `bfcol_2` AS `bfcol_4`, - `bfcol_3` AS `bfcol_5` - FROM `bfcte_0` -), `bfcte_3` AS ( + `t0`.`rowindex`, + `t0`.`time_col` + FROM ( + SELECT + `rowindex`, + `time_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_1` - INNER JOIN `bfcte_2` - 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_3` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_890`, + `t0`.`time_col` AS `bfuid_col_891` + FROM ( + SELECT + `rowindex`, + `time_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) AS `t0` +) AS `t4` + ON COALESCE(CAST(`t3`.`time_col` AS STRING), '0') = COALESCE(CAST(`t4`.`bfuid_col_891` AS STRING), '0') + AND COALESCE(CAST(`t3`.`time_col` AS STRING), '1') = COALESCE(CAST(`t4`.`bfuid_col_891` 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..e697bfde57 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_896` AS `bfuid_col_897` +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_897` 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..99fbce9403 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_902` AS `bfuid_col_903` +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, 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)]) AS `level_0` +) AS `t0`) +ORDER BY `bfuid_col_903` 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..ebb104f778 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_900` AS `bfuid_col_901` +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_900` 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_901` 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..73cbc5bacd 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_898` AS `bfuid_col_899` +FROM ( SELECT * - FROM UNNEST(ARRAY>, `bfcol_2` INT64>>[STRUCT( + FROM UNNEST(ARRAY>, `bfuid_col_898` 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_899` 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 10c2a2088a..d15308e774 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,36 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `bytes_col` AS `bfcol_1`, - `date_col` AS `bfcol_2`, - `datetime_col` AS `bfcol_3`, - `geography_col` AS `bfcol_4`, - `int64_col` AS `bfcol_5`, - `int64_too` AS `bfcol_6`, - `numeric_col` AS `bfcol_7`, - `float64_col` AS `bfcol_8`, - `rowindex` AS `bfcol_9`, - `rowindex_2` AS `bfcol_10`, - `string_col` AS `bfcol_11`, - `time_col` AS `bfcol_12`, - `timestamp_col` AS `bfcol_13`, - `duration_col` AS `bfcol_14` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -) SELECT - `bfcol_9` AS `rowindex`, - `bfcol_0` AS `bool_col`, - `bfcol_1` AS `bytes_col`, - `bfcol_2` AS `date_col`, - `bfcol_3` AS `datetime_col`, - `bfcol_4` AS `geography_col`, - `bfcol_5` AS `int64_col`, - `bfcol_6` AS `int64_too`, - `bfcol_7` AS `numeric_col`, - `bfcol_8` AS `float64_col`, - `bfcol_9` AS `rowindex_1`, - `bfcol_10` AS `rowindex_2`, - `bfcol_11` AS `string_col`, - `bfcol_12` AS `time_col`, - `bfcol_13` AS `timestamp_col`, - `bfcol_14` AS `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 ( + 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 `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 4e8f61d75d..f68bdd4bae 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,8 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `json_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_1` AS `json_col` -FROM `bfcte_0` \ No newline at end of file + * +FROM ( + SELECT + `rowindex`, + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:50.715543') +) 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 f97eb7bf06..76a5e094fb 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,15 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -) SELECT - `bfcol_1` AS `rowindex`, - `bfcol_0` AS `int64_col` -FROM `bfcte_0` -ORDER BY - `bfcol_1` ASC NULLS LAST +`rowindex` AS `rowindex`, +`int64_col` AS `int64_col` +FROM +(SELECT + `t0`.`rowindex`, + `t0`.`int64_col` +FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 75c4a86e18..359918bf20 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,10 @@ -WITH `bfcte_0` AS ( - SELECT - `id` AS `bfcol_0`, - `people` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` -) SELECT - `bfcol_0` AS `id`, - `bfcol_0` AS `id_1`, - `bfcol_1` AS `people` -FROM `bfcte_0` \ No newline at end of file + `t0`.`id`, + `t0`.`id` AS `id_1`, + `t0`.`people` +FROM ( + SELECT + `id`, + `people` + FROM `bigframes-dev.sqlglot_test.nested_structs_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:52.992529') +) 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 6a16b98baa..dc1297a60f 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,14 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -) SELECT - `bfcol_1` AS `rowindex`, - `bfcol_0` AS `int64_col` -FROM `bfcte_0` -ORDER BY - `bfcol_0` 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 ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) 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 2436c01a44..3bf1bb84fe 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,22 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `int_list_col` AS `bfcol_1`, - `bool_list_col` AS `bfcol_2`, - `float_list_col` AS `bfcol_3`, - `date_list_col` AS `bfcol_4`, - `date_time_list_col` AS `bfcol_5`, - `numeric_list_col` AS `bfcol_6`, - `string_list_col` AS `bfcol_7` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_0` AS `rowindex_1`, - `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` \ 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 ( + SELECT + `rowindex`, + `int_list_col`, + `bool_list_col`, + `float_list_col`, + `date_list_col`, + `date_time_list_col`, + `numeric_list_col`, + `string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:49.414285') +) 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 beb3caa073..e63222b277 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,92 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_0` AS `bfcol_7`, - `bfcol_1` AS `bfcol_8`, - `bfcol_0` 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` IS NULL ASC NULLS LAST, `bfcol_9` ASC NULLS LAST, `bfcol_2` IS NULL ASC NULLS LAST, `bfcol_2` 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` IS NULL ASC NULLS LAST, `bfcol_9` ASC NULLS LAST, `bfcol_2` IS NULL ASC NULLS LAST, `bfcol_2` 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_909` AS `bool_col`, + `t3`.`bfuid_col_906` AS `rowindex`, + `t3`.`bfuid_col_910` AS `bool_col_1`, + CASE + WHEN COALESCE( + SUM(CAST(( + `t3`.`bfuid_col_908` + ) IS NOT NULL AS INT64)) OVER ( + PARTITION BY `t3`.`bfuid_col_909` + ORDER BY `t3`.`bfuid_col_909` IS NULL ASC, `t3`.`bfuid_col_909` ASC, `t3`.`bfuid_col_915` IS NULL ASC, `t3`.`bfuid_col_915` ASC + ROWS BETWEEN 3 preceding AND CURRENT ROW + ), + 0 + ) < 3 + THEN NULL + WHEN TRUE + THEN COALESCE( + SUM(`t3`.`bfuid_col_908`) OVER ( + PARTITION BY `t3`.`bfuid_col_909` + ORDER BY `t3`.`bfuid_col_909` IS NULL ASC, `t3`.`bfuid_col_909` ASC, `t3`.`bfuid_col_915` IS NULL ASC, `t3`.`bfuid_col_915` ASC + ROWS BETWEEN 3 preceding AND CURRENT ROW + ), + 0 + ) + ELSE CAST(NULL AS INT64) + END AS `int64_col`, + `t3`.`bfuid_col_915` AS `bfuid_col_916` +FROM ( SELECT * - FROM `bfcte_3` + FROM ( + SELECT + `t1`.`bfuid_col_906`, + `t1`.`bfuid_col_908`, + `t1`.`bfuid_col_909`, + CASE + WHEN COALESCE( + SUM(CAST(( + `t1`.`bfuid_col_907` + ) IS NOT NULL AS INT64)) OVER ( + PARTITION BY `t1`.`bfuid_col_909` + ORDER BY `t1`.`bfuid_col_909` IS NULL ASC, `t1`.`bfuid_col_909` ASC, `t1`.`bfuid_col_914` IS NULL ASC, `t1`.`bfuid_col_914` ASC + ROWS BETWEEN 3 preceding AND CURRENT ROW + ), + 0 + ) < 3 + THEN NULL + WHEN TRUE + THEN COALESCE( + SUM(CAST(`t1`.`bfuid_col_907` AS INT64)) OVER ( + PARTITION BY `t1`.`bfuid_col_909` + ORDER BY `t1`.`bfuid_col_909` IS NULL ASC, `t1`.`bfuid_col_909` ASC, `t1`.`bfuid_col_914` IS NULL ASC, `t1`.`bfuid_col_914` ASC + ROWS BETWEEN 3 preceding AND CURRENT ROW + ), + 0 + ) + ELSE CAST(NULL AS INT64) + END AS `bfuid_col_910`, + `t1`.`bfuid_col_914` AS `bfuid_col_915` + FROM ( + SELECT + `t0`.`rowindex` AS `bfuid_col_906`, + `t0`.`bool_col` AS `bfuid_col_907`, + `t0`.`int64_col` AS `bfuid_col_908`, + `t0`.`bool_col` AS `bfuid_col_909`, + `t0`.`rowindex` AS `bfuid_col_914` + FROM ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') + ) 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` IS NULL ASC NULLS LAST, `bfcol_9` ASC NULLS LAST, `bfcol_2` IS NULL ASC NULLS LAST, `bfcol_2` 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` IS NULL ASC NULLS LAST, `bfcol_9` ASC NULLS LAST, `bfcol_2` IS NULL ASC NULLS LAST, `bfcol_2` 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, - `bfcol_2` ASC NULLS LAST \ No newline at end of file + ( + `t2`.`bfuid_col_909` + ) IS NOT NULL +) AS `t3`) +ORDER BY `bool_col` ASC NULLS LAST ,`bfuid_col_916` 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..9fab214345 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_919` AS `bfuid_col_921` +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_921` 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 6d779a40ac..0d98a39da2 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,30 +1,34 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN SUM(CAST(NOT `bfcol_0` IS NULL AS INT64)) OVER ( - ORDER BY `bfcol_1` IS NULL ASC NULLS LAST, `bfcol_1` ASC NULLS LAST - ROWS BETWEEN 2 PRECEDING AND CURRENT ROW - ) < 3 - THEN NULL - ELSE COALESCE( - SUM(`bfcol_0`) OVER ( - ORDER BY `bfcol_1` IS NULL ASC NULLS LAST, `bfcol_1` ASC NULLS LAST - ROWS BETWEEN 2 PRECEDING AND CURRENT ROW - ), - 0 - ) - END AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `rowindex`, - `bfcol_4` AS `int64_col` -FROM `bfcte_1` -ORDER BY - `bfcol_1` ASC NULLS LAST \ No newline at end of file +`rowindex` AS `rowindex`, +`int64_col` AS `int64_col` +FROM +(SELECT + `t0`.`rowindex`, + CASE + WHEN COALESCE( + SUM(CAST(( + `t0`.`int64_col` + ) IS NOT NULL AS INT64)) OVER ( + ORDER BY `t0`.`rowindex` IS NULL ASC, `t0`.`rowindex` ASC + ROWS BETWEEN 2 preceding AND CURRENT ROW + ), + 0 + ) < 3 + THEN NULL + WHEN TRUE + THEN COALESCE( + SUM(`t0`.`int64_col`) OVER ( + ORDER BY `t0`.`rowindex` IS NULL ASC, `t0`.`rowindex` ASC + ROWS BETWEEN 2 preceding AND CURRENT ROW + ), + 0 + ) + ELSE CAST(NULL AS INT64) + END AS `int64_col` +FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0`) +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 1d5d9a9e45..5d386a7d97 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,27 +1,28 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN COUNT(CAST(NOT `bfcol_0` IS NULL AS INT64)) OVER ( - ORDER BY `bfcol_1` IS NULL ASC NULLS LAST, `bfcol_1` ASC NULLS LAST - ROWS BETWEEN 4 PRECEDING AND CURRENT ROW - ) < 5 - THEN NULL - ELSE COUNT(`bfcol_0`) OVER ( - ORDER BY `bfcol_1` IS NULL ASC NULLS LAST, `bfcol_1` ASC NULLS LAST - ROWS BETWEEN 4 PRECEDING AND CURRENT ROW - ) - END AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `rowindex`, - `bfcol_4` AS `int64_col` -FROM `bfcte_1` -ORDER BY - `bfcol_1` ASC NULLS LAST \ No newline at end of file +`rowindex` AS `rowindex`, +`int64_col` AS `int64_col` +FROM +(SELECT + `t0`.`rowindex`, + CASE + WHEN COUNT(( + `t0`.`int64_col` + ) IS NOT NULL) OVER ( + ORDER BY `t0`.`rowindex` IS NULL ASC, `t0`.`rowindex` ASC + ROWS BETWEEN 4 preceding AND CURRENT ROW + ) < 5 + THEN NULL + WHEN TRUE + THEN COUNT(`t0`.`int64_col`) OVER ( + ORDER BY `t0`.`rowindex` IS NULL ASC, `t0`.`rowindex` ASC + ROWS BETWEEN 4 preceding AND CURRENT ROW + ) + ELSE CAST(NULL AS INT64) + END AS `int64_col` +FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-09-30T20:19:48.854671') +) AS `t0`) +ORDER BY `rowindex` ASC NULLS LAST \ No newline at end of file