From 84c6f883aef8048e7013a8b3c03a1bde47e94eea Mon Sep 17 00:00:00 2001 From: Shuowei Li Date: Mon, 9 Feb 2026 13:53:56 -0800 Subject: [PATCH 01/17] docs: Add EXIF metadata extraction example to multimodal notebook (#2429) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR updates the notebooks/multimodal/multimodal_dataframe.ipynb notebook to include a comprehensive example of extracting EXIF metadata from images. Key Changes: * Added a new section "7. Extract EXIF metadata from images". * Implemented a custom remote function (UDF) using pillow and requests to retrieve and parse EXIF tags from image URLs. * Demonstrated how to apply this function efficiently within a BigFrames workflow to analyze image metadata. This addition provides users with a practical pattern for handling image metadata and using custom libraries within BigQuery DataFrames. Fixes #<478952827> 🦕 --------- Co-authored-by: Garrett Wu <6505921+GarrettWu@users.noreply.github.com> Co-authored-by: Chelsea Lin Co-authored-by: Shenyang Cai --- .../multimodal/multimodal_dataframe.ipynb | 94 ++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/notebooks/multimodal/multimodal_dataframe.ipynb b/notebooks/multimodal/multimodal_dataframe.ipynb index 0822ee4c2db..bb5733bde26 100644 --- a/notebooks/multimodal/multimodal_dataframe.ipynb +++ b/notebooks/multimodal/multimodal_dataframe.ipynb @@ -61,7 +61,8 @@ "3. Conduct image transformations\n", "4. Use LLM models to ask questions and generate embeddings on images\n", "5. PDF chunking function\n", - "6. Transcribe audio" + "6. Transcribe audio\n", + "7. Extract EXIF metadata from images" ] }, { @@ -104,6 +105,11 @@ "PROJECT = \"bigframes-dev\" # replace with your project. \n", "# Refer to https://cloud.google.com/bigquery/docs/multimodal-data-dataframes-tutorial#required_roles for your required permissions\n", "\n", + "LOCATION = \"us\" # replace with your location.\n", + "\n", + "# Dataset where the UDF will be created.\n", + "DATASET_ID = \"bigframes_samples\" # replace with your dataset ID.\n", + "\n", "OUTPUT_BUCKET = \"bigframes_blob_test\" # replace with your GCS bucket. \n", "# The connection (or bigframes-default-connection of the project) must have read/write permission to the bucket. \n", "# Refer to https://cloud.google.com/bigquery/docs/multimodal-data-dataframes-tutorial#grant-permissions for setting up connection service account permissions.\n", @@ -112,12 +118,14 @@ "import bigframes\n", "# Setup project\n", "bigframes.options.bigquery.project = PROJECT\n", + "bigframes.options.bigquery.location = LOCATION\n", "\n", "# Display options\n", "bigframes.options.display.blob_display_width = 300\n", "bigframes.options.display.progress_bar = None\n", "\n", - "import bigframes.pandas as bpd" + "import bigframes.pandas as bpd\n", + "import bigframes.bigquery as bbq" ] }, { @@ -1546,6 +1554,88 @@ "transcribed_series_verbose = df['audio'].blob.audio_transcribe(model_name=\"gemini-2.0-flash-001\", verbose=True)\n", "transcribed_series_verbose" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 7. Extract EXIF metadata from images" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This section demonstrates how to extract EXIF metadata from images using a custom BigQuery Python UDF and the `Pillow` library." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Construct the canonical connection ID\n", + "FULL_CONNECTION_ID = f\"{PROJECT}.{LOCATION}.bigframes-default-connection\"\n", + "\n", + "@bpd.udf(\n", + " input_types=[str],\n", + " output_type=str,\n", + " dataset=DATASET_ID,\n", + " name=\"extract_exif\",\n", + " bigquery_connection=FULL_CONNECTION_ID,\n", + " packages=[\"pillow\", \"requests\"],\n", + " max_batching_rows=8192,\n", + " container_cpu=0.33,\n", + " container_memory=\"512Mi\"\n", + ")\n", + "def extract_exif(src_obj_ref_rt: str) -> str:\n", + " import io\n", + " import json\n", + " from PIL import ExifTags, Image\n", + " import requests\n", + " from requests import adapters\n", + " session = requests.Session()\n", + " session.mount(\"https://\", adapters.HTTPAdapter(max_retries=3))\n", + " src_obj_ref_rt_json = json.loads(src_obj_ref_rt)\n", + " src_url = src_obj_ref_rt_json[\"access_urls\"][\"read_url\"]\n", + " response = session.get(src_url, timeout=30)\n", + " bts = response.content\n", + " image = Image.open(io.BytesIO(bts))\n", + " exif_data = image.getexif()\n", + " exif_dict = {}\n", + " if exif_data:\n", + " for tag, value in exif_data.items():\n", + " tag_name = ExifTags.TAGS.get(tag, tag)\n", + " exif_dict[tag_name] = value\n", + " return json.dumps(exif_dict)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Create a Multimodal DataFrame from the sample image URIs\n", + "exif_image_df = bpd.from_glob_path(\n", + " \"gs://bigframes_blob_test/images_exif/*\",\n", + " name=\"blob_col\",\n", + ")\n", + "\n", + "# Generate a JSON string containing the runtime information (including signed read URLs)\n", + "# This allows the UDF to download the images from Google Cloud Storage\n", + "access_urls = exif_image_df[\"blob_col\"].blob.get_runtime_json_str(mode=\"R\")\n", + "\n", + "# Apply the BigQuery Python UDF to the runtime JSON strings\n", + "# We cast to string to ensure the input matches the UDF's signature\n", + "exif_json = access_urls.astype(str).apply(extract_exif)\n", + "\n", + "# Parse the resulting JSON strings back into a structured JSON type for easier access\n", + "exif_data = bbq.parse_json(exif_json)\n", + "\n", + "exif_data" + ] } ], "metadata": { From 59cbc5db66fd178ecce03bf4b8b4a504d7ef3e9f Mon Sep 17 00:00:00 2001 From: Shuowei Li Date: Mon, 9 Feb 2026 15:47:48 -0800 Subject: [PATCH 02/17] docs: use direct API for audio transcription (#2447) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery-dataframes/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #<478952827> 🦕 --- .../multimodal/multimodal_dataframe.ipynb | 95 +++++++++++-------- 1 file changed, 54 insertions(+), 41 deletions(-) diff --git a/notebooks/multimodal/multimodal_dataframe.ipynb b/notebooks/multimodal/multimodal_dataframe.ipynb index bb5733bde26..29c2bd468a1 100644 --- a/notebooks/multimodal/multimodal_dataframe.ipynb +++ b/notebooks/multimodal/multimodal_dataframe.ipynb @@ -92,7 +92,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 9, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -1459,25 +1459,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 6. Audio transcribe function" + "### 6. Audio transcribe" ] }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 10, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n" - ] - } - ], + "outputs": [], "source": [ "audio_gcs_path = \"gs://bigframes_blob_test/audio/*\"\n", "df = bpd.from_glob_path(audio_gcs_path, name=\"audio\")" @@ -1485,18 +1474,14 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", + "/usr/local/google/home/shuowei/src/python-bigquery-dataframes/bigframes/dtypes.py:987: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", "instead of using `db_dtypes` in the future when available in pandas\n", "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n" @@ -1504,54 +1489,82 @@ }, { "data": { + "text/html": [ + "
0    Now, as all books, not primarily intended as p...
" + ], "text/plain": [ "0 Now, as all books, not primarily intended as p...\n", "Name: transcribed_content, dtype: string" ] }, - "execution_count": 22, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "transcribed_series = df['audio'].blob.audio_transcribe(model_name=\"gemini-2.0-flash-001\", verbose=False)\n", + "import bigframes.bigquery as bbq\n", + "import bigframes.operations as ops\n", + "\n", + "# The audio_transcribe function is a convenience wrapper around bigframes.bigquery.ai.generate.\n", + "# Here's how to perform the same operation directly:\n", + "\n", + "audio_series = df['audio']\n", + "prompt_text = (\n", + " \"**Task:** Transcribe the provided audio. **Instructions:** - Your response \"\n", + " \"must contain only the verbatim transcription of the audio. - Do not include \"\n", + " \"any introductory text, summaries, or conversational filler in your response. \"\n", + " \"The output should begin directly with the first word of the audio.\"\n", + ")\n", + "\n", + "# Convert the audio series to the runtime representation required by the model.\n", + "# This involves fetching metadata and getting a signed access URL.\n", + "audio_metadata = audio_series._apply_unary_op(ops.obj_fetch_metadata_op)\n", + "audio_runtime = audio_metadata._apply_unary_op(ops.ObjGetAccessUrl(mode=\"R\"))\n", + "\n", + "transcribed_results = bbq.ai.generate(\n", + " prompt=(prompt_text, audio_runtime),\n", + " endpoint=\"gemini-2.0-flash-001\",\n", + " model_params={\"generationConfig\": {\"temperature\": 0.0}},\n", + ")\n", + "\n", + "transcribed_series = transcribed_results.struct.field(\"result\").rename(\"transcribed_content\")\n", "transcribed_series" ] }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 12, "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n" - ] - }, { "data": { + "text/html": [ + "
0    {'status': '', 'content': 'Now, as all books, ...
" + ], "text/plain": [ "0 {'status': '', 'content': 'Now, as all books, ...\n", "Name: transcription_results, dtype: struct[pyarrow]" ] }, - "execution_count": 23, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "transcribed_series_verbose = df['audio'].blob.audio_transcribe(model_name=\"gemini-2.0-flash-001\", verbose=True)\n", + "# To get verbose results (including status), we can extract both fields from the result struct.\n", + "transcribed_content_series = transcribed_results.struct.field(\"result\")\n", + "transcribed_status_series = transcribed_results.struct.field(\"status\")\n", + "\n", + "transcribed_series_verbose = bpd.DataFrame(\n", + " {\n", + " \"status\": transcribed_status_series,\n", + " \"content\": transcribed_content_series,\n", + " }\n", + ")\n", + "# Package as a struct for consistent display\n", + "transcribed_series_verbose = bbq.struct(transcribed_series_verbose).rename(\"transcription_results\")\n", "transcribed_series_verbose" ] }, @@ -1657,7 +1670,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.18" + "version": "3.13.0" } }, "nbformat": 4, From 61c17e380a719561a163161e68bb6bae0452ae89 Mon Sep 17 00:00:00 2001 From: TrevorBergeron Date: Tue, 10 Feb 2026 09:20:12 -0800 Subject: [PATCH 03/17] refactor: Define sql nodes and transform (#2438) --- bigframes/core/compile/compiled.py | 61 +- .../compile/sqlglot/aggregate_compiler.py | 10 +- .../sqlglot/aggregations/binary_compiler.py | 2 + .../sqlglot/aggregations/nullary_compiler.py | 2 + .../sqlglot/aggregations/unary_compiler.py | 2 + .../compile/sqlglot/aggregations/windows.py | 14 +- bigframes/core/compile/sqlglot/compiler.py | 170 ++---- ...lar_compiler.py => expression_compiler.py} | 14 +- .../compile/sqlglot/expressions/ai_ops.py | 4 +- .../compile/sqlglot/expressions/array_ops.py | 6 +- .../compile/sqlglot/expressions/blob_ops.py | 6 +- .../compile/sqlglot/expressions/bool_ops.py | 4 +- .../sqlglot/expressions/comparison_ops.py | 6 +- .../compile/sqlglot/expressions/date_ops.py | 4 +- .../sqlglot/expressions/datetime_ops.py | 6 +- .../sqlglot/expressions/generic_ops.py | 14 +- .../compile/sqlglot/expressions/geo_ops.py | 6 +- .../compile/sqlglot/expressions/json_ops.py | 6 +- .../sqlglot/expressions/numeric_ops.py | 6 +- .../compile/sqlglot/expressions/string_ops.py | 6 +- .../compile/sqlglot/expressions/struct_ops.py | 6 +- .../sqlglot/expressions/timedelta_ops.py | 4 +- bigframes/core/compile/sqlglot/sqlglot_ir.py | 250 +++----- bigframes/core/rewrite/__init__.py | 9 +- bigframes/core/rewrite/as_sql.py | 227 ++++++++ bigframes/core/rewrite/windows.py | 65 ++- bigframes/core/sql_nodes.py | 157 +++++ .../test_row_number/out.sql | 28 +- .../test_row_number_with_window/out.sql | 14 +- .../test_all_w_window/out.sql | 14 +- .../test_any_value/window_out.sql | 14 +- .../test_any_value/window_partition_out.sql | 15 +- .../test_any_w_window/out.sql | 14 +- .../test_count/window_out.sql | 14 +- .../test_count/window_partition_out.sql | 15 +- .../test_unary_compiler/test_cut/int_bins.sql | 88 ++- .../test_cut/int_bins_labels.sql | 36 +- .../test_cut/interval_bins.sql | 24 +- .../test_cut/interval_bins_labels.sql | 24 +- .../test_dense_rank/out.sql | 14 +- .../test_diff_w_bool/out.sql | 14 +- .../test_diff_w_date/out.sql | 18 +- .../test_diff_w_datetime/out.sql | 22 +- .../test_diff_w_int/out.sql | 14 +- .../test_diff_w_timestamp/out.sql | 22 +- .../test_unary_compiler/test_first/out.sql | 20 +- .../test_first_non_null/out.sql | 20 +- .../test_unary_compiler/test_last/out.sql | 20 +- .../test_last_non_null/out.sql | 20 +- .../test_max/window_out.sql | 14 +- .../test_max/window_partition_out.sql | 15 +- .../test_unary_compiler/test_mean/out.sql | 14 +- .../test_mean/window_out.sql | 14 +- .../test_mean/window_partition_out.sql | 15 +- .../test_min/window_out.sql | 14 +- .../test_min/window_partition_out.sql | 15 +- .../test_pop_var/window_out.sql | 14 +- .../test_product/window_partition_out.sql | 41 +- .../test_unary_compiler/test_qcut/out.sql | 86 ++- .../test_unary_compiler/test_rank/out.sql | 14 +- .../test_unary_compiler/test_shift/lag.sql | 14 +- .../test_unary_compiler/test_shift/lead.sql | 14 +- .../test_unary_compiler/test_shift/noop.sql | 14 +- .../test_unary_compiler/test_std/out.sql | 14 +- .../test_std/window_out.sql | 14 +- .../test_sum/window_out.sql | 14 +- .../test_sum/window_partition_out.sql | 15 +- .../test_var/window_out.sql | 14 +- .../test_ai_ops/test_ai_classify/out.sql | 22 +- .../test_ai_ops/test_ai_generate/out.sql | 22 +- .../test_ai_ops/test_ai_generate_bool/out.sql | 22 +- .../out.sql | 24 +- .../out.sql | 22 +- .../test_ai_generate_double/out.sql | 22 +- .../out.sql | 24 +- .../out.sql | 22 +- .../test_ai_ops/test_ai_generate_int/out.sql | 22 +- .../out.sql | 24 +- .../out.sql | 22 +- .../out.sql | 24 +- .../test_ai_generate_with_model_param/out.sql | 22 +- .../out.sql | 24 +- .../snapshots/test_ai_ops/test_ai_if/out.sql | 20 +- .../test_ai_ops/test_ai_score/out.sql | 20 +- .../test_array_ops/test_array_index/out.sql | 14 +- .../test_array_reduce_op/out.sql | 57 +- .../test_array_slice_with_only_start/out.sql | 26 +- .../out.sql | 26 +- .../test_array_to_string/out.sql | 14 +- .../test_array_ops/test_to_array_op/out.sql | 34 +- .../test_obj_fetch_metadata/out.sql | 27 +- .../test_obj_get_access_url/out.sql | 31 +- .../test_blob_ops/test_obj_make_ref/out.sql | 15 +- .../test_bool_ops/test_and_op/out.sql | 48 +- .../test_bool_ops/test_or_op/out.sql | 48 +- .../test_bool_ops/test_xor_op/out.sql | 66 +-- .../test_eq_null_match/out.sql | 15 +- .../test_eq_numeric/out.sql | 75 +-- .../test_ge_numeric/out.sql | 61 +- .../test_gt_numeric/out.sql | 61 +- .../test_comparison_ops/test_is_in/out.sql | 47 +- .../test_le_numeric/out.sql | 61 +- .../test_lt_numeric/out.sql | 61 +- .../test_maximum_op/out.sql | 15 +- .../test_minimum_op/out.sql | 15 +- .../test_ne_numeric/out.sql | 79 +-- .../test_add_timedelta/out.sql | 68 +-- .../test_datetime_ops/test_date/out.sql | 14 +- .../test_datetime_to_integer_label/out.sql | 60 +- .../test_datetime_ops/test_day/out.sql | 14 +- .../test_datetime_ops/test_dayofweek/out.sql | 22 +- .../test_datetime_ops/test_dayofyear/out.sql | 14 +- .../test_datetime_ops/test_floor_dt/out.sql | 48 +- .../test_datetime_ops/test_hour/out.sql | 14 +- .../out.sql | 19 +- .../out.sql | 81 ++- .../out.sql | 95 ++- .../out.sql | 23 +- .../out.sql | 15 +- .../test_datetime_ops/test_iso_day/out.sql | 14 +- .../test_datetime_ops/test_iso_week/out.sql | 14 +- .../test_datetime_ops/test_iso_year/out.sql | 14 +- .../test_datetime_ops/test_minute/out.sql | 14 +- .../test_datetime_ops/test_month/out.sql | 14 +- .../test_datetime_ops/test_normalize/out.sql | 14 +- .../test_datetime_ops/test_quarter/out.sql | 14 +- .../test_datetime_ops/test_second/out.sql | 14 +- .../test_datetime_ops/test_strftime/out.sql | 26 +- .../test_sub_timedelta/out.sql | 91 +-- .../test_datetime_ops/test_time/out.sql | 14 +- .../test_to_datetime/out.sql | 22 +- .../test_to_timestamp/out.sql | 30 +- .../test_unix_micros/out.sql | 14 +- .../test_unix_millis/out.sql | 14 +- .../test_unix_seconds/out.sql | 14 +- .../test_datetime_ops/test_year/out.sql | 14 +- .../test_generic_ops/test_astype_bool/out.sql | 21 +- .../test_astype_float/out.sql | 20 +- .../test_astype_from_json/out.sql | 26 +- .../test_generic_ops/test_astype_int/out.sql | 42 +- .../test_generic_ops/test_astype_json/out.sql | 32 +- .../test_astype_string/out.sql | 21 +- .../test_astype_time_like/out.sql | 23 +- .../test_binary_remote_function_op/out.sql | 15 +- .../test_case_when_op/out.sql | 40 +- .../test_generic_ops/test_clip/out.sql | 16 +- .../test_generic_ops/test_coalesce/out.sql | 18 +- .../test_generic_ops/test_fillna/out.sql | 15 +- .../test_generic_ops/test_hash/out.sql | 14 +- .../test_generic_ops/test_invert/out.sql | 34 +- .../test_generic_ops/test_isnull/out.sql | 16 +- .../test_generic_ops/test_map/out.sql | 26 +- .../test_nary_remote_function_op/out.sql | 16 +- .../test_generic_ops/test_notnull/out.sql | 16 +- .../test_remote_function_op/out.sql | 25 +- .../test_generic_ops/test_row_key/out.sql | 114 ++-- .../test_sql_scalar_op/out.sql | 15 +- .../test_generic_ops/test_where/out.sql | 16 +- .../test_geo_ops/test_geo_area/out.sql | 14 +- .../test_geo_ops/test_geo_st_astext/out.sql | 14 +- .../test_geo_ops/test_geo_st_boundary/out.sql | 14 +- .../test_geo_ops/test_geo_st_buffer/out.sql | 14 +- .../test_geo_ops/test_geo_st_centroid/out.sql | 14 +- .../test_geo_st_convexhull/out.sql | 14 +- .../test_geo_st_difference/out.sql | 14 +- .../test_geo_ops/test_geo_st_distance/out.sql | 17 +- .../test_geo_st_geogfromtext/out.sql | 14 +- .../test_geo_st_geogpoint/out.sql | 15 +- .../test_geo_st_intersection/out.sql | 14 +- .../test_geo_ops/test_geo_st_isclosed/out.sql | 14 +- .../test_geo_ops/test_geo_st_length/out.sql | 14 +- .../snapshots/test_geo_ops/test_geo_x/out.sql | 14 +- .../snapshots/test_geo_ops/test_geo_y/out.sql | 14 +- .../test_json_ops/test_json_extract/out.sql | 14 +- .../test_json_extract_array/out.sql | 14 +- .../test_json_extract_string_array/out.sql | 14 +- .../test_json_ops/test_json_keys/out.sql | 17 +- .../test_json_ops/test_json_query/out.sql | 14 +- .../test_json_query_array/out.sql | 14 +- .../test_json_ops/test_json_set/out.sql | 14 +- .../test_json_ops/test_json_value/out.sql | 14 +- .../test_json_ops/test_parse_json/out.sql | 14 +- .../test_json_ops/test_to_json/out.sql | 14 +- .../test_json_ops/test_to_json_string/out.sql | 14 +- .../test_numeric_ops/test_abs/out.sql | 14 +- .../test_numeric_ops/test_add_numeric/out.sql | 61 +- .../test_numeric_ops/test_add_string/out.sql | 14 +- .../test_add_timedelta/out.sql | 68 +-- .../test_numeric_ops/test_arccos/out.sql | 22 +- .../test_numeric_ops/test_arccosh/out.sql | 22 +- .../test_numeric_ops/test_arcsin/out.sql | 22 +- .../test_numeric_ops/test_arcsinh/out.sql | 14 +- .../test_numeric_ops/test_arctan/out.sql | 14 +- .../test_numeric_ops/test_arctan2/out.sql | 19 +- .../test_numeric_ops/test_arctanh/out.sql | 26 +- .../test_numeric_ops/test_ceil/out.sql | 14 +- .../test_numeric_ops/test_cos/out.sql | 14 +- .../test_numeric_ops/test_cosh/out.sql | 22 +- .../test_cosine_distance/out.sql | 18 +- .../test_numeric_ops/test_div_numeric/out.sql | 134 +---- .../test_div_timedelta/out.sql | 25 +- .../test_euclidean_distance/out.sql | 18 +- .../test_numeric_ops/test_exp/out.sql | 22 +- .../test_numeric_ops/test_expm1/out.sql | 14 +- .../test_numeric_ops/test_floor/out.sql | 14 +- .../test_floordiv_timedelta/out.sql | 16 +- .../test_numeric_ops/test_ln/out.sql | 30 +- .../test_numeric_ops/test_log10/out.sql | 30 +- .../test_numeric_ops/test_log1p/out.sql | 30 +- .../test_manhattan_distance/out.sql | 18 +- .../test_numeric_ops/test_mod_numeric/out.sql | 481 ++++++--------- .../test_numeric_ops/test_mul_numeric/out.sql | 61 +- .../test_mul_timedelta/out.sql | 49 +- .../test_numeric_ops/test_neg/out.sql | 18 +- .../test_numeric_ops/test_pos/out.sql | 14 +- .../test_numeric_ops/test_pow/out.sql | 547 ++++++++---------- .../test_numeric_ops/test_round/out.sql | 90 +-- .../test_numeric_ops/test_sin/out.sql | 14 +- .../test_numeric_ops/test_sinh/out.sql | 22 +- .../test_numeric_ops/test_sqrt/out.sql | 14 +- .../test_numeric_ops/test_sub_numeric/out.sql | 61 +- .../test_sub_timedelta/out.sql | 91 +-- .../test_numeric_ops/test_tan/out.sql | 14 +- .../test_numeric_ops/test_tanh/out.sql | 14 +- .../test_unsafe_pow_op/out.sql | 55 +- .../test_string_ops/test_add_string/out.sql | 14 +- .../test_string_ops/test_capitalize/out.sql | 14 +- .../test_string_ops/test_endswith/out.sql | 20 +- .../test_string_ops/test_isalnum/out.sql | 14 +- .../test_string_ops/test_isalpha/out.sql | 14 +- .../test_string_ops/test_isdecimal/out.sql | 14 +- .../test_string_ops/test_isdigit/out.sql | 20 +- .../test_string_ops/test_islower/out.sql | 14 +- .../test_string_ops/test_isnumeric/out.sql | 14 +- .../test_string_ops/test_isspace/out.sql | 14 +- .../test_string_ops/test_isupper/out.sql | 14 +- .../test_string_ops/test_len/out.sql | 14 +- .../test_string_ops/test_len_w_array/out.sql | 14 +- .../test_string_ops/test_lower/out.sql | 14 +- .../test_string_ops/test_lstrip/out.sql | 14 +- .../test_regex_replace_str/out.sql | 14 +- .../test_string_ops/test_replace_str/out.sql | 14 +- .../test_string_ops/test_reverse/out.sql | 14 +- .../test_string_ops/test_rstrip/out.sql | 14 +- .../test_string_ops/test_startswith/out.sql | 20 +- .../test_string_ops/test_str_contains/out.sql | 14 +- .../test_str_contains_regex/out.sql | 14 +- .../test_string_ops/test_str_extract/out.sql | 33 +- .../test_string_ops/test_str_find/out.sql | 23 +- .../test_string_ops/test_str_get/out.sql | 14 +- .../test_string_ops/test_str_pad/out.sql | 36 +- .../test_string_ops/test_str_repeat/out.sql | 14 +- .../test_string_ops/test_str_slice/out.sql | 14 +- .../test_string_ops/test_strconcat/out.sql | 14 +- .../test_string_ops/test_string_split/out.sql | 14 +- .../test_string_ops/test_strip/out.sql | 14 +- .../test_string_ops/test_upper/out.sql | 14 +- .../test_string_ops/test_zfill/out.sql | 22 +- .../test_struct_ops/test_struct_field/out.sql | 17 +- .../test_struct_ops/test_struct_op/out.sql | 27 +- .../test_timedelta_floor/out.sql | 14 +- .../test_to_timedelta/out.sql | 61 +- .../test_compile_aggregate/out.sql | 14 +- .../test_compile_aggregate_wo_dropna/out.sql | 14 +- .../test_compile_concat/out.sql | 48 +- .../test_compile_concat_filter_sorted/out.sql | 100 +--- .../test_compile_filter/out.sql | 30 +- .../test_st_regionstats/out.sql | 71 ++- .../out.sql | 29 +- .../test_compile_geo/test_st_simplify/out.sql | 9 +- .../test_compile_isin/out.sql | 25 +- .../test_compile_isin_not_nullable/out.sql | 23 +- .../test_compile_join/out.sql | 24 +- .../test_compile_join_w_on/bool_col/out.sql | 24 +- .../float64_col/out.sql | 24 +- .../test_compile_join_w_on/int64_col/out.sql | 24 +- .../numeric_col/out.sql | 24 +- .../test_compile_join_w_on/string_col/out.sql | 24 +- .../test_compile_join_w_on/time_col/out.sql | 24 +- .../test_compile_random_sample/out.sql | 5 +- .../test_compile_readtable/out.sql | 21 +- .../out.sql | 4 +- .../out.sql | 8 +- .../test_compile_readtable_w_limit/out.sql | 8 +- .../out.sql | 8 +- .../test_compile_readtable_w_ordering/out.sql | 8 +- .../out.sql | 14 +- .../out.sql | 21 +- .../out.sql | 125 ++-- .../out.sql | 44 +- .../out.sql | 38 +- .../out.sql | 26 +- .../compile/sqlglot/test_scalar_compiler.py | 20 +- 293 files changed, 2562 insertions(+), 6200 deletions(-) rename bigframes/core/compile/sqlglot/{scalar_compiler.py => expression_compiler.py} (94%) create mode 100644 bigframes/core/rewrite/as_sql.py create mode 100644 bigframes/core/sql_nodes.py diff --git a/bigframes/core/compile/compiled.py b/bigframes/core/compile/compiled.py index f8be331d59b..5bd141a4062 100644 --- a/bigframes/core/compile/compiled.py +++ b/bigframes/core/compile/compiled.py @@ -13,7 +13,6 @@ # limitations under the License. from __future__ import annotations -import functools import itertools import typing from typing import Literal, Optional, Sequence @@ -27,7 +26,7 @@ from google.cloud import bigquery import pyarrow as pa -from bigframes.core import agg_expressions +from bigframes.core import agg_expressions, rewrite import bigframes.core.agg_expressions as ex_types import bigframes.core.compile.googlesql import bigframes.core.compile.ibis_compiler.aggregate_compiler as agg_compiler @@ -38,8 +37,6 @@ import bigframes.core.sql from bigframes.core.window_spec import WindowSpec import bigframes.dtypes -import bigframes.operations as ops -import bigframes.operations.aggregations as agg_ops op_compiler = op_compilers.scalar_op_compiler @@ -424,59 +421,11 @@ def project_window_op( output_name, ) - if expression.op.order_independent and window_spec.is_unbounded: - # notably percentile_cont does not support ordering clause - window_spec = window_spec.without_order() - - # TODO: Turn this logic into a true rewriter - result_expr: ex.Expression = agg_expressions.WindowExpression( - expression, window_spec + rewritten_expr = rewrite.simplify_complex_windows( + agg_expressions.WindowExpression(expression, window_spec) ) - clauses: list[tuple[ex.Expression, ex.Expression]] = [] - if window_spec.min_periods and len(expression.inputs) > 0: - if not expression.op.nulls_count_for_min_values: - is_observation = ops.notnull_op.as_expr() - - # Most operations do not count NULL values towards min_periods - per_col_does_count = ( - ops.notnull_op.as_expr(input) for input in expression.inputs - ) - # All inputs must be non-null for observation to count - is_observation = functools.reduce( - lambda x, y: ops.and_op.as_expr(x, y), per_col_does_count - ) - observation_sentinel = ops.AsTypeOp(bigframes.dtypes.INT_DTYPE).as_expr( - is_observation - ) - observation_count_expr = agg_expressions.WindowExpression( - ex_types.UnaryAggregation(agg_ops.sum_op, observation_sentinel), - window_spec, - ) - else: - # Operations like count treat even NULLs as valid observations for the sake of min_periods - # notnull is just used to convert null values to non-null (FALSE) values to be counted - is_observation = ops.notnull_op.as_expr(expression.inputs[0]) - observation_count_expr = agg_expressions.WindowExpression( - agg_ops.count_op.as_expr(is_observation), - window_spec, - ) - clauses.append( - ( - ops.lt_op.as_expr( - observation_count_expr, ex.const(window_spec.min_periods) - ), - ex.const(None), - ) - ) - if clauses: - case_inputs = [ - *itertools.chain.from_iterable(clauses), - ex.const(True), - result_expr, - ] - result_expr = ops.CaseWhenOp().as_expr(*case_inputs) - - ibis_expr = op_compiler.compile_expression(result_expr, self._ibis_bindings) + + ibis_expr = op_compiler.compile_expression(rewritten_expr, self._ibis_bindings) return UnorderedIR(self._table, (*self.columns, ibis_expr.name(output_name))) diff --git a/bigframes/core/compile/sqlglot/aggregate_compiler.py b/bigframes/core/compile/sqlglot/aggregate_compiler.py index d2ecfaade01..f86e2af0dee 100644 --- a/bigframes/core/compile/sqlglot/aggregate_compiler.py +++ b/bigframes/core/compile/sqlglot/aggregate_compiler.py @@ -22,8 +22,8 @@ ordered_unary_compiler, unary_compiler, ) +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions import typed_expr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler def compile_aggregate( @@ -35,7 +35,7 @@ def compile_aggregate( return nullary_compiler.compile(aggregate.op) if isinstance(aggregate, agg_expressions.UnaryAggregation): column = typed_expr.TypedExpr( - scalar_compiler.scalar_op_compiler.compile_expression(aggregate.arg), + expression_compiler.expression_compiler.compile_expression(aggregate.arg), aggregate.arg.output_type, ) if not aggregate.op.order_independent: @@ -46,11 +46,11 @@ def compile_aggregate( return unary_compiler.compile(aggregate.op, column) elif isinstance(aggregate, agg_expressions.BinaryAggregation): left = typed_expr.TypedExpr( - scalar_compiler.scalar_op_compiler.compile_expression(aggregate.left), + expression_compiler.expression_compiler.compile_expression(aggregate.left), aggregate.left.output_type, ) right = typed_expr.TypedExpr( - scalar_compiler.scalar_op_compiler.compile_expression(aggregate.right), + expression_compiler.expression_compiler.compile_expression(aggregate.right), aggregate.right.output_type, ) return binary_compiler.compile(aggregate.op, left, right) @@ -66,7 +66,7 @@ def compile_analytic( return nullary_compiler.compile(aggregate.op, window) if isinstance(aggregate, agg_expressions.UnaryAggregation): column = typed_expr.TypedExpr( - scalar_compiler.scalar_op_compiler.compile_expression(aggregate.arg), + expression_compiler.expression_compiler.compile_expression(aggregate.arg), aggregate.arg.output_type, ) return unary_compiler.compile(aggregate.op, column, window) diff --git a/bigframes/core/compile/sqlglot/aggregations/binary_compiler.py b/bigframes/core/compile/sqlglot/aggregations/binary_compiler.py index 51ff1ceeccb..d068578c651 100644 --- a/bigframes/core/compile/sqlglot/aggregations/binary_compiler.py +++ b/bigframes/core/compile/sqlglot/aggregations/binary_compiler.py @@ -33,6 +33,8 @@ def compile( right: typed_expr.TypedExpr, window: typing.Optional[window_spec.WindowSpec] = None, ) -> sge.Expression: + if op.order_independent and (window is not None) and window.is_unbounded: + window = window.without_order() return BINARY_OP_REGISTRATION[op](op, left, right, window=window) diff --git a/bigframes/core/compile/sqlglot/aggregations/nullary_compiler.py b/bigframes/core/compile/sqlglot/aggregations/nullary_compiler.py index 58ab7ec5135..061c58983c8 100644 --- a/bigframes/core/compile/sqlglot/aggregations/nullary_compiler.py +++ b/bigframes/core/compile/sqlglot/aggregations/nullary_compiler.py @@ -30,6 +30,8 @@ def compile( op: agg_ops.WindowOp, window: typing.Optional[window_spec.WindowSpec] = None, ) -> sge.Expression: + if op.order_independent and (window is not None) and window.is_unbounded: + window = window.without_order() return NULLARY_OP_REGISTRATION[op](op, window=window) diff --git a/bigframes/core/compile/sqlglot/aggregations/unary_compiler.py b/bigframes/core/compile/sqlglot/aggregations/unary_compiler.py index 3b851390049..381b472bceb 100644 --- a/bigframes/core/compile/sqlglot/aggregations/unary_compiler.py +++ b/bigframes/core/compile/sqlglot/aggregations/unary_compiler.py @@ -36,6 +36,8 @@ def compile( column: typed_expr.TypedExpr, window: typing.Optional[window_spec.WindowSpec] = None, ) -> sge.Expression: + if op.order_independent and (window is not None) and window.is_unbounded: + window = window.without_order() return UNARY_OP_REGISTRATION[op](op, column, window=window) diff --git a/bigframes/core/compile/sqlglot/aggregations/windows.py b/bigframes/core/compile/sqlglot/aggregations/windows.py index 9c327885850..d10da8f1c05 100644 --- a/bigframes/core/compile/sqlglot/aggregations/windows.py +++ b/bigframes/core/compile/sqlglot/aggregations/windows.py @@ -18,7 +18,7 @@ import bigframes_vendored.sqlglot.expressions as sge from bigframes.core import utils, window_spec -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler import bigframes.core.expression as ex import bigframes.core.ordering as ordering_spec import bigframes.dtypes as dtypes @@ -116,7 +116,7 @@ def get_window_order_by( order_by = [] for ordering_spec_item in ordering: - expr = scalar_compiler.scalar_op_compiler.compile_expression( + expr = expression_compiler.expression_compiler.compile_expression( ordering_spec_item.scalar_expression ) desc = not ordering_spec_item.direction.is_ascending @@ -191,15 +191,15 @@ def _get_window_bounds( def _compile_group_by_key(key: ex.Expression) -> sge.Expression: - expr = scalar_compiler.scalar_op_compiler.compile_expression(key) + expr = expression_compiler.expression_compiler.compile_expression(key) # The group_by keys has been rewritten by bind_schema_to_node - assert isinstance(key, ex.ResolvedDerefOp) + assert key.is_scalar_expr and key.is_resolved # Some types need to be converted to another type to enable groupby - if key.dtype == dtypes.FLOAT_DTYPE: + if key.output_type == dtypes.FLOAT_DTYPE: expr = sge.Cast(this=expr, to="STRING") - elif key.dtype == dtypes.GEO_DTYPE: + elif key.output_type == dtypes.GEO_DTYPE: expr = sge.func("ST_ASBINARY", expr) - elif key.dtype == dtypes.JSON_DTYPE: + elif key.output_type == dtypes.JSON_DTYPE: expr = sge.func("TO_JSON_STRING", expr) return expr diff --git a/bigframes/core/compile/sqlglot/compiler.py b/bigframes/core/compile/sqlglot/compiler.py index f2c94f98c7a..786c5a1ed1f 100644 --- a/bigframes/core/compile/sqlglot/compiler.py +++ b/bigframes/core/compile/sqlglot/compiler.py @@ -20,19 +20,19 @@ import bigframes_vendored.sqlglot.expressions as sge from bigframes.core import ( - agg_expressions, expression, guid, identifiers, nodes, pyarrow_utils, rewrite, + sql_nodes, ) from bigframes.core.compile import configs import bigframes.core.compile.sqlglot.aggregate_compiler as aggregate_compiler from bigframes.core.compile.sqlglot.aggregations import windows +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions import typed_expr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler import bigframes.core.compile.sqlglot.sqlglot_ir as ir from bigframes.core.logging import data_types as data_type_logger import bigframes.core.ordering as bf_ordering @@ -104,30 +104,10 @@ def _compile_result_node(root: nodes.ResultNode) -> str: root = typing.cast(nodes.ResultNode, rewrite.defer_selection(root)) # Have to bind schema as the final step before compilation. + # Probably, should defer even further root = typing.cast(nodes.ResultNode, schema_binding.bind_schema_to_tree(root)) - selected_cols: tuple[tuple[str, sge.Expression], ...] = tuple( - (name, scalar_compiler.scalar_op_compiler.compile_expression(ref)) - for ref, name in root.output_cols - ) - sqlglot_ir = compile_node(root.child, uid_gen).select(selected_cols) - - if root.order_by is not None: - ordering_cols = tuple( - sge.Ordered( - this=scalar_compiler.scalar_op_compiler.compile_expression( - ordering.scalar_expression - ), - desc=ordering.direction.is_ascending is False, - nulls_first=ordering.na_last is False, - ) - for ordering in root.order_by.all_ordering_columns - ) - sqlglot_ir = sqlglot_ir.order_by(ordering_cols) - - if root.limit is not None: - sqlglot_ir = sqlglot_ir.limit(root.limit) - + sqlglot_ir = compile_node(rewrite.as_sql_nodes(root), uid_gen) return sqlglot_ir.sql @@ -160,6 +140,35 @@ def _compile_node( raise ValueError(f"Can't compile unrecognized node: {node}") +@_compile_node.register +def compile_sql_select(node: sql_nodes.SqlSelectNode, child: ir.SQLGlotIR): + ordering_cols = tuple( + sge.Ordered( + this=expression_compiler.expression_compiler.compile_expression( + ordering.scalar_expression + ), + desc=ordering.direction.is_ascending is False, + nulls_first=ordering.na_last is False, + ) + for ordering in node.sorting + ) + + projected_cols: tuple[tuple[str, sge.Expression], ...] = tuple( + ( + cdef.id.sql, + expression_compiler.expression_compiler.compile_expression(cdef.expression), + ) + for cdef in node.selections + ) + + sge_predicates = tuple( + expression_compiler.expression_compiler.compile_expression(expression) + for expression in node.predicates + ) + + return child.select(projected_cols, sge_predicates, ordering_cols, node.limit) + + @_compile_node.register def compile_readlocal(node: nodes.ReadLocalNode, child: ir.SQLGlotIR) -> ir.SQLGlotIR: pa_table = node.local_data_source.data @@ -174,44 +183,18 @@ def compile_readlocal(node: nodes.ReadLocalNode, child: ir.SQLGlotIR) -> ir.SQLG @_compile_node.register -def compile_readtable(node: nodes.ReadTableNode, child: ir.SQLGlotIR): +def compile_readtable(node: sql_nodes.SqlDataSource, child: ir.SQLGlotIR): table = node.source.table return ir.SQLGlotIR.from_table( table.project_id, table.dataset_id, table.table_id, - col_names=[col.source_id for col in node.scan_list.items], - alias_names=[col.id.sql for col in node.scan_list.items], uid_gen=child.uid_gen, sql_predicate=node.source.sql_predicate, system_time=node.source.at_time, ) -@_compile_node.register -def compile_selection(node: nodes.SelectionNode, child: ir.SQLGlotIR) -> ir.SQLGlotIR: - selected_cols: tuple[tuple[str, sge.Expression], ...] = tuple( - (id.sql, scalar_compiler.scalar_op_compiler.compile_expression(expr)) - for expr, id in node.input_output_pairs - ) - return child.select(selected_cols) - - -@_compile_node.register -def compile_projection(node: nodes.ProjectionNode, child: ir.SQLGlotIR) -> ir.SQLGlotIR: - projected_cols: tuple[tuple[str, sge.Expression], ...] = tuple( - (id.sql, scalar_compiler.scalar_op_compiler.compile_expression(expr)) - for expr, id in node.assignments - ) - return child.project(projected_cols) - - -@_compile_node.register -def compile_filter(node: nodes.FilterNode, child: ir.SQLGlotIR) -> ir.SQLGlotIR: - condition = scalar_compiler.scalar_op_compiler.compile_expression(node.predicate) - return child.filter(tuple([condition])) - - @_compile_node.register def compile_join( node: nodes.JoinNode, left: ir.SQLGlotIR, right: ir.SQLGlotIR @@ -219,11 +202,11 @@ def compile_join( conditions = tuple( ( typed_expr.TypedExpr( - scalar_compiler.scalar_op_compiler.compile_expression(left), + expression_compiler.expression_compiler.compile_expression(left), left.output_type, ), typed_expr.TypedExpr( - scalar_compiler.scalar_op_compiler.compile_expression(right), + expression_compiler.expression_compiler.compile_expression(right), right.output_type, ), ) @@ -245,11 +228,11 @@ def compile_isin_join( right_field = node.right_child.fields[0] conditions = ( typed_expr.TypedExpr( - scalar_compiler.scalar_op_compiler.compile_expression(node.left_col), + expression_compiler.expression_compiler.compile_expression(node.left_col), node.left_col.output_type, ), typed_expr.TypedExpr( - scalar_compiler.scalar_op_compiler.compile_expression( + expression_compiler.expression_compiler.compile_expression( expression.DerefOp(right_field.id) ), right_field.dtype, @@ -277,7 +260,7 @@ def compile_concat(node: nodes.ConcatNode, *children: ir.SQLGlotIR) -> ir.SQLGlo ] return ir.SQLGlotIR.from_union( - [child.expr for child in children], + [child._as_select() for child in children], output_aliases=output_aliases, uid_gen=uid_gen, ) @@ -312,7 +295,7 @@ def compile_aggregate(node: nodes.AggregateNode, child: ir.SQLGlotIR) -> ir.SQLG for agg, id in node.aggregations ) by_cols: tuple[sge.Expression, ...] = tuple( - scalar_compiler.scalar_op_compiler.compile_expression(by_col) + expression_compiler.expression_compiler.compile_expression(by_col) for by_col in node.by_column_ids ) @@ -325,79 +308,6 @@ def compile_aggregate(node: nodes.AggregateNode, child: ir.SQLGlotIR) -> ir.SQLG return child.aggregate(aggregations, by_cols, tuple(dropna_cols)) -@_compile_node.register -def compile_window(node: nodes.WindowOpNode, child: ir.SQLGlotIR) -> ir.SQLGlotIR: - window_spec = node.window_spec - result = child - for cdef in node.agg_exprs: - assert isinstance(cdef.expression, agg_expressions.Aggregation) - if cdef.expression.op.order_independent and window_spec.is_unbounded: - # notably percentile_cont does not support ordering clause - window_spec = window_spec.without_order() - - window_op = aggregate_compiler.compile_analytic(cdef.expression, window_spec) - - inputs: tuple[sge.Expression, ...] = tuple( - scalar_compiler.scalar_op_compiler.compile_expression( - expression.DerefOp(column) - ) - for column in cdef.expression.column_references - ) - - clauses: list[tuple[sge.Expression, sge.Expression]] = [] - if window_spec.min_periods and len(inputs) > 0: - if not cdef.expression.op.nulls_count_for_min_values: - # Most operations do not count NULL values towards min_periods - not_null_columns = [ - sge.Not(this=sge.Is(this=column, expression=sge.Null())) - for column in inputs - ] - # All inputs must be non-null for observation to count - if not not_null_columns: - is_observation_expr: sge.Expression = sge.convert(True) - else: - is_observation_expr = not_null_columns[0] - for expr in not_null_columns[1:]: - is_observation_expr = sge.And( - this=is_observation_expr, expression=expr - ) - is_observation = ir._cast(is_observation_expr, "INT64") - observation_count = windows.apply_window_if_present( - sge.func("SUM", is_observation), window_spec - ) - observation_count = sge.func( - "COALESCE", observation_count, sge.convert(0) - ) - else: - # Operations like count treat even NULLs as valid observations - # for the sake of min_periods notnull is just used to convert - # null values to non-null (FALSE) values to be counted. - is_observation = ir._cast( - sge.Not(this=sge.Is(this=inputs[0], expression=sge.Null())), - "INT64", - ) - observation_count = windows.apply_window_if_present( - sge.func("COUNT", is_observation), window_spec - ) - - clauses.append( - ( - observation_count < sge.convert(window_spec.min_periods), - sge.Null(), - ) - ) - if clauses: - when_expressions = [sge.When(this=cond, true=res) for cond, res in clauses] - window_op = sge.Case(ifs=when_expressions, default=window_op) - - # TODO: check if we can directly window the expression. - result = result.window( - window_op=window_op, - output_column_id=cdef.id.sql, - ) - return result - - def _replace_unsupported_ops(node: nodes.BigFrameNode): node = nodes.bottom_up(node, rewrite.rewrite_slice) node = nodes.bottom_up(node, rewrite.rewrite_range_rolling) diff --git a/bigframes/core/compile/sqlglot/scalar_compiler.py b/bigframes/core/compile/sqlglot/expression_compiler.py similarity index 94% rename from bigframes/core/compile/sqlglot/scalar_compiler.py rename to bigframes/core/compile/sqlglot/expression_compiler.py index 317141b6cc4..b2ff34bf747 100644 --- a/bigframes/core/compile/sqlglot/scalar_compiler.py +++ b/bigframes/core/compile/sqlglot/expression_compiler.py @@ -18,13 +18,14 @@ import bigframes_vendored.sqlglot.expressions as sge +import bigframes.core.agg_expressions as agg_exprs from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr import bigframes.core.compile.sqlglot.sqlglot_ir as ir import bigframes.core.expression as ex import bigframes.operations as ops -class ScalarOpCompiler: +class ExpressionCompiler: # Mapping of operation name to implemenations _registry: dict[ str, @@ -78,6 +79,15 @@ def _(self, expr: ex.DerefOp) -> sge.Expression: def _(self, expr: ex.ScalarConstantExpression) -> sge.Expression: return ir._literal(expr.value, expr.dtype) + @compile_expression.register + def _(self, expr: agg_exprs.WindowExpression) -> sge.Expression: + import bigframes.core.compile.sqlglot.aggregate_compiler as agg_compile + + return agg_compile.compile_analytic( + expr.analytic_expr, + expr.window, + ) + @compile_expression.register def _(self, expr: ex.OpExpression) -> sge.Expression: # Non-recursively compiles the children scalar expressions. @@ -218,4 +228,4 @@ def _add_parentheses(cls, expr: TypedExpr) -> TypedExpr: # Singleton compiler -scalar_op_compiler = ScalarOpCompiler() +expression_compiler = ExpressionCompiler() diff --git a/bigframes/core/compile/sqlglot/expressions/ai_ops.py b/bigframes/core/compile/sqlglot/expressions/ai_ops.py index 748f15b8677..cc0cbaad8fe 100644 --- a/bigframes/core/compile/sqlglot/expressions/ai_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/ai_ops.py @@ -19,10 +19,10 @@ import bigframes_vendored.sqlglot.expressions as sge from bigframes import operations as ops -from bigframes.core.compile.sqlglot import scalar_compiler +from bigframes.core.compile.sqlglot import expression_compiler from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -register_nary_op = scalar_compiler.scalar_op_compiler.register_nary_op +register_nary_op = expression_compiler.expression_compiler.register_nary_op @register_nary_op(ops.AIGenerate, pass_op=True) diff --git a/bigframes/core/compile/sqlglot/expressions/array_ops.py b/bigframes/core/compile/sqlglot/expressions/array_ops.py index e83a6ea99a9..eb7582cb168 100644 --- a/bigframes/core/compile/sqlglot/expressions/array_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/array_ops.py @@ -20,16 +20,16 @@ import bigframes_vendored.sqlglot.expressions as sge from bigframes import operations as ops +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions.string_ops import ( string_index, string_slice, ) from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler import bigframes.dtypes as dtypes -register_unary_op = scalar_compiler.scalar_op_compiler.register_unary_op -register_nary_op = scalar_compiler.scalar_op_compiler.register_nary_op +register_unary_op = expression_compiler.expression_compiler.register_unary_op +register_nary_op = expression_compiler.expression_compiler.register_nary_op @register_unary_op(ops.ArrayIndexOp, pass_op=True) diff --git a/bigframes/core/compile/sqlglot/expressions/blob_ops.py b/bigframes/core/compile/sqlglot/expressions/blob_ops.py index 3105cd8e303..cf939c68cef 100644 --- a/bigframes/core/compile/sqlglot/expressions/blob_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/blob_ops.py @@ -17,11 +17,11 @@ import bigframes_vendored.sqlglot.expressions as sge from bigframes import operations as ops +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler -register_unary_op = scalar_compiler.scalar_op_compiler.register_unary_op -register_binary_op = scalar_compiler.scalar_op_compiler.register_binary_op +register_unary_op = expression_compiler.expression_compiler.register_unary_op +register_binary_op = expression_compiler.expression_compiler.register_binary_op @register_unary_op(ops.obj_fetch_metadata_op) diff --git a/bigframes/core/compile/sqlglot/expressions/bool_ops.py b/bigframes/core/compile/sqlglot/expressions/bool_ops.py index 6fee3f4278e..cd7f9da4084 100644 --- a/bigframes/core/compile/sqlglot/expressions/bool_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/bool_ops.py @@ -18,10 +18,10 @@ from bigframes import dtypes from bigframes import operations as ops +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler -register_binary_op = scalar_compiler.scalar_op_compiler.register_binary_op +register_binary_op = expression_compiler.expression_compiler.register_binary_op @register_binary_op(ops.and_op) diff --git a/bigframes/core/compile/sqlglot/expressions/comparison_ops.py b/bigframes/core/compile/sqlglot/expressions/comparison_ops.py index 8c201f6a068..550a6c25be2 100644 --- a/bigframes/core/compile/sqlglot/expressions/comparison_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/comparison_ops.py @@ -23,11 +23,11 @@ from bigframes import dtypes from bigframes import operations as ops from bigframes.core.compile.sqlglot import sqlglot_ir +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler -register_unary_op = scalar_compiler.scalar_op_compiler.register_unary_op -register_binary_op = scalar_compiler.scalar_op_compiler.register_binary_op +register_unary_op = expression_compiler.expression_compiler.register_unary_op +register_binary_op = expression_compiler.expression_compiler.register_binary_op @register_unary_op(ops.IsInOp, pass_op=True) diff --git a/bigframes/core/compile/sqlglot/expressions/date_ops.py b/bigframes/core/compile/sqlglot/expressions/date_ops.py index 3de7c4b23b1..e9b43febaed 100644 --- a/bigframes/core/compile/sqlglot/expressions/date_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/date_ops.py @@ -17,10 +17,10 @@ import bigframes_vendored.sqlglot.expressions as sge from bigframes import operations as ops +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler -register_unary_op = scalar_compiler.scalar_op_compiler.register_unary_op +register_unary_op = expression_compiler.expression_compiler.register_unary_op @register_unary_op(ops.date_op) diff --git a/bigframes/core/compile/sqlglot/expressions/datetime_ops.py b/bigframes/core/compile/sqlglot/expressions/datetime_ops.py index 7f3e8135af1..82f2f34edf3 100644 --- a/bigframes/core/compile/sqlglot/expressions/datetime_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/datetime_ops.py @@ -20,11 +20,11 @@ from bigframes import operations as ops from bigframes.core.compile.constants import UNIT_TO_US_CONVERSION_FACTORS from bigframes.core.compile.sqlglot import sqlglot_types +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler -register_unary_op = scalar_compiler.scalar_op_compiler.register_unary_op -register_binary_op = scalar_compiler.scalar_op_compiler.register_binary_op +register_unary_op = expression_compiler.expression_compiler.register_unary_op +register_binary_op = expression_compiler.expression_compiler.register_binary_op @register_binary_op(ops.DatetimeToIntegerLabelOp, pass_op=True) diff --git a/bigframes/core/compile/sqlglot/expressions/generic_ops.py b/bigframes/core/compile/sqlglot/expressions/generic_ops.py index 003a7296fcb..94ff12a7ef8 100644 --- a/bigframes/core/compile/sqlglot/expressions/generic_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/generic_ops.py @@ -20,13 +20,13 @@ from bigframes import dtypes from bigframes import operations as ops from bigframes.core.compile.sqlglot import sqlglot_ir, sqlglot_types +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler -register_unary_op = scalar_compiler.scalar_op_compiler.register_unary_op -register_binary_op = scalar_compiler.scalar_op_compiler.register_binary_op -register_nary_op = scalar_compiler.scalar_op_compiler.register_nary_op -register_ternary_op = scalar_compiler.scalar_op_compiler.register_ternary_op +register_unary_op = expression_compiler.expression_compiler.register_unary_op +register_binary_op = expression_compiler.expression_compiler.register_binary_op +register_nary_op = expression_compiler.expression_compiler.register_nary_op +register_ternary_op = expression_compiler.expression_compiler.register_ternary_op @register_unary_op(ops.AsTypeOp, pass_op=True) @@ -94,7 +94,7 @@ def _(*operands: TypedExpr, op: ops.SqlScalarOp) -> sge.Expression: @register_unary_op(ops.isnull_op) def _(expr: TypedExpr) -> sge.Expression: - return sge.Is(this=expr.expr, expression=sge.Null()) + return sge.Is(this=sge.paren(expr.expr), expression=sge.Null()) @register_unary_op(ops.MapOp, pass_op=True) @@ -125,7 +125,7 @@ def _(expr: TypedExpr, op: ops.MapOp) -> sge.Expression: @register_unary_op(ops.notnull_op) def _(expr: TypedExpr) -> sge.Expression: - return sge.Not(this=sge.Is(this=expr.expr, expression=sge.Null())) + return sge.Not(this=sge.Is(this=sge.paren(expr.expr), expression=sge.Null())) @register_ternary_op(ops.where_op) diff --git a/bigframes/core/compile/sqlglot/expressions/geo_ops.py b/bigframes/core/compile/sqlglot/expressions/geo_ops.py index 9c6ba33ea54..ea7f09b41a8 100644 --- a/bigframes/core/compile/sqlglot/expressions/geo_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/geo_ops.py @@ -17,11 +17,11 @@ import bigframes_vendored.sqlglot.expressions as sge from bigframes import operations as ops +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler -register_unary_op = scalar_compiler.scalar_op_compiler.register_unary_op -register_binary_op = scalar_compiler.scalar_op_compiler.register_binary_op +register_unary_op = expression_compiler.expression_compiler.register_unary_op +register_binary_op = expression_compiler.expression_compiler.register_binary_op @register_unary_op(ops.geo_area_op) diff --git a/bigframes/core/compile/sqlglot/expressions/json_ops.py b/bigframes/core/compile/sqlglot/expressions/json_ops.py index d2008b45bf9..d7ecf49fc6c 100644 --- a/bigframes/core/compile/sqlglot/expressions/json_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/json_ops.py @@ -17,11 +17,11 @@ import bigframes_vendored.sqlglot.expressions as sge from bigframes import operations as ops +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler -register_unary_op = scalar_compiler.scalar_op_compiler.register_unary_op -register_binary_op = scalar_compiler.scalar_op_compiler.register_binary_op +register_unary_op = expression_compiler.expression_compiler.register_unary_op +register_binary_op = expression_compiler.expression_compiler.register_binary_op @register_unary_op(ops.JSONExtract, pass_op=True) diff --git a/bigframes/core/compile/sqlglot/expressions/numeric_ops.py b/bigframes/core/compile/sqlglot/expressions/numeric_ops.py index 28d3532b8b8..f2ae6cd82eb 100644 --- a/bigframes/core/compile/sqlglot/expressions/numeric_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/numeric_ops.py @@ -19,13 +19,13 @@ from bigframes import dtypes from bigframes import operations as ops +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler import bigframes.core.compile.sqlglot.expressions.constants as constants from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler from bigframes.operations import numeric_ops -register_unary_op = scalar_compiler.scalar_op_compiler.register_unary_op -register_binary_op = scalar_compiler.scalar_op_compiler.register_binary_op +register_unary_op = expression_compiler.expression_compiler.register_unary_op +register_binary_op = expression_compiler.expression_compiler.register_binary_op @register_unary_op(ops.abs_op) diff --git a/bigframes/core/compile/sqlglot/expressions/string_ops.py b/bigframes/core/compile/sqlglot/expressions/string_ops.py index 242dd7ae20d..3bfec04b3e0 100644 --- a/bigframes/core/compile/sqlglot/expressions/string_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/string_ops.py @@ -21,11 +21,11 @@ from bigframes import dtypes from bigframes import operations as ops +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler -register_unary_op = scalar_compiler.scalar_op_compiler.register_unary_op -register_binary_op = scalar_compiler.scalar_op_compiler.register_binary_op +register_unary_op = expression_compiler.expression_compiler.register_unary_op +register_binary_op = expression_compiler.expression_compiler.register_binary_op @register_unary_op(ops.capitalize_op) diff --git a/bigframes/core/compile/sqlglot/expressions/struct_ops.py b/bigframes/core/compile/sqlglot/expressions/struct_ops.py index 5048941f149..0fe09cb294e 100644 --- a/bigframes/core/compile/sqlglot/expressions/struct_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/struct_ops.py @@ -21,11 +21,11 @@ import pyarrow as pa from bigframes import operations as ops +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler -register_nary_op = scalar_compiler.scalar_op_compiler.register_nary_op -register_unary_op = scalar_compiler.scalar_op_compiler.register_unary_op +register_nary_op = expression_compiler.expression_compiler.register_nary_op +register_unary_op = expression_compiler.expression_compiler.register_unary_op @register_unary_op(ops.StructFieldOp, pass_op=True) diff --git a/bigframes/core/compile/sqlglot/expressions/timedelta_ops.py b/bigframes/core/compile/sqlglot/expressions/timedelta_ops.py index b442fa8175d..ab75669a3dc 100644 --- a/bigframes/core/compile/sqlglot/expressions/timedelta_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/timedelta_ops.py @@ -19,10 +19,10 @@ from bigframes import dtypes from bigframes import operations as ops from bigframes.core.compile.constants import UNIT_TO_US_CONVERSION_FACTORS +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler -register_unary_op = scalar_compiler.scalar_op_compiler.register_unary_op +register_unary_op = expression_compiler.expression_compiler.register_unary_op @register_unary_op(ops.timedelta_floor_op) diff --git a/bigframes/core/compile/sqlglot/sqlglot_ir.py b/bigframes/core/compile/sqlglot/sqlglot_ir.py index ad5da31206a..d0bd32697c4 100644 --- a/bigframes/core/compile/sqlglot/sqlglot_ir.py +++ b/bigframes/core/compile/sqlglot/sqlglot_ir.py @@ -44,7 +44,7 @@ class SQLGlotIR: """Helper class to build SQLGlot Query and generate SQL string.""" - expr: sge.Select = sg.select() + expr: typing.Union[sge.Select, sge.Table] = sg.select() """The SQLGlot expression representing the query.""" dialect = sg.dialects.bigquery.BigQuery @@ -116,8 +116,6 @@ def from_table( project_id: str, dataset_id: str, table_id: str, - col_names: typing.Sequence[str], - alias_names: typing.Sequence[str], uid_gen: guid.SequentialUIDGenerator, sql_predicate: typing.Optional[str] = None, system_time: typing.Optional[datetime.datetime] = None, @@ -134,15 +132,6 @@ def from_table( sql_predicate (typing.Optional[str]): An optional SQL predicate for filtering. system_time (typing.Optional[str]): An optional system time for time-travel queries. """ - selections = [ - sge.Alias( - this=sge.to_identifier(col_name, quoted=cls.quoted), - alias=sge.to_identifier(alias_name, quoted=cls.quoted), - ) - if col_name != alias_name - else sge.to_identifier(col_name, quoted=cls.quoted) - for col_name, alias_name in zip(col_names, alias_names) - ] version = ( sge.Version( this="TIMESTAMP", @@ -158,12 +147,49 @@ def from_table( catalog=sg.to_identifier(project_id, quoted=cls.quoted), version=version, ) - select_expr = sge.Select().select(*selections).from_(table_expr) if sql_predicate: + select_expr = sge.Select().select(sge.Star()).from_(table_expr) select_expr = select_expr.where( sg.parse_one(sql_predicate, dialect="bigquery"), append=False ) - return cls(expr=select_expr, uid_gen=uid_gen) + return cls(expr=select_expr, uid_gen=uid_gen) + + return cls(expr=table_expr, uid_gen=uid_gen) + + def select( + self, + selections: tuple[tuple[str, sge.Expression], ...] = (), + predicates: tuple[sge.Expression, ...] = (), + sorting: tuple[sge.Ordered, ...] = (), + limit: typing.Optional[int] = None, + ) -> SQLGlotIR: + # TODO: Explicitly insert CTEs into plan + if isinstance(self.expr, sge.Select): + new_expr, _ = self._select_to_cte() + else: + new_expr = sge.Select().from_(self.expr) + + if len(sorting) > 0: + new_expr = new_expr.order_by(*sorting) + + to_select = [ + sge.Alias( + this=expr, + alias=sge.to_identifier(id, quoted=self.quoted), + ) + if expr.alias_or_name != id + else expr + for id, expr in selections + ] + new_expr = new_expr.select(*to_select, append=False) + + if len(predicates) > 0: + condition = _and(predicates) + new_expr = new_expr.where(condition, append=False) + if limit is not None: + new_expr = new_expr.limit(limit) + + return SQLGlotIR(expr=new_expr, uid_gen=self.uid_gen) @classmethod def from_query_string( @@ -231,91 +257,6 @@ def from_union( final_select_expr = _set_query_ctes(final_select_expr, existing_ctes) return cls(expr=final_select_expr, uid_gen=uid_gen) - def select( - self, - selected_cols: tuple[tuple[str, sge.Expression], ...], - ) -> SQLGlotIR: - """Replaces new selected columns of the current SELECT clause.""" - selections = [ - sge.Alias( - this=expr, - alias=sge.to_identifier(id, quoted=self.quoted), - ) - if expr.alias_or_name != id - else expr - for id, expr in selected_cols - ] - - new_expr = _select_to_cte( - self.expr, - sge.to_identifier( - next(self.uid_gen.get_uid_stream("bfcte_")), quoted=self.quoted - ), - ) - new_expr = new_expr.select(*selections, append=False) - return SQLGlotIR(expr=new_expr, uid_gen=self.uid_gen) - - def project( - self, - projected_cols: tuple[tuple[str, sge.Expression], ...], - ) -> SQLGlotIR: - """Adds new columns to the SELECT clause.""" - projected_cols_expr = [ - sge.Alias( - this=expr, - alias=sge.to_identifier(id, quoted=self.quoted), - ) - for id, expr in projected_cols - ] - new_expr = _select_to_cte( - self.expr, - sge.to_identifier( - next(self.uid_gen.get_uid_stream("bfcte_")), quoted=self.quoted - ), - ) - new_expr = new_expr.select(*projected_cols_expr, append=True) - return SQLGlotIR(expr=new_expr, uid_gen=self.uid_gen) - - def order_by( - self, - ordering: tuple[sge.Ordered, ...], - ) -> SQLGlotIR: - """Adds an ORDER BY clause to the query.""" - if len(ordering) == 0: - return SQLGlotIR(expr=self.expr.copy(), uid_gen=self.uid_gen) - new_expr = self.expr.order_by(*ordering) - return SQLGlotIR(expr=new_expr, uid_gen=self.uid_gen) - - def limit( - self, - limit: int | None, - ) -> SQLGlotIR: - """Adds a LIMIT clause to the query.""" - if limit is not None: - new_expr = self.expr.limit(limit) - else: - new_expr = self.expr.copy() - return SQLGlotIR(expr=new_expr, uid_gen=self.uid_gen) - - def filter( - self, - conditions: tuple[sge.Expression, ...], - ) -> SQLGlotIR: - """Filters the query by adding a WHERE clause.""" - condition = _and(conditions) - if condition is None: - return SQLGlotIR(expr=self.expr.copy(), uid_gen=self.uid_gen) - - new_expr = _select_to_cte( - self.expr, - sge.to_identifier( - next(self.uid_gen.get_uid_stream("bfcte_")), quoted=self.quoted - ), - ) - return SQLGlotIR( - expr=new_expr.where(condition, append=False), uid_gen=self.uid_gen - ) - def join( self, right: SQLGlotIR, @@ -325,15 +266,8 @@ def join( joins_nulls: bool = True, ) -> SQLGlotIR: """Joins the current query with another SQLGlotIR instance.""" - left_cte_name = sge.to_identifier( - next(self.uid_gen.get_uid_stream("bfcte_")), quoted=self.quoted - ) - right_cte_name = sge.to_identifier( - next(self.uid_gen.get_uid_stream("bfcte_")), quoted=self.quoted - ) - - left_select = _select_to_cte(self.expr, left_cte_name) - right_select = _select_to_cte(right.expr, right_cte_name) + left_select, left_cte_name = self._select_to_cte() + right_select, right_cte_name = right._select_to_cte() left_select, left_ctes = _pop_query_ctes(left_select) right_select, right_ctes = _pop_query_ctes(right_select) @@ -364,13 +298,9 @@ def isin_join( joins_nulls: bool = True, ) -> SQLGlotIR: """Joins the current query with another SQLGlotIR instance.""" - left_cte_name = sge.to_identifier( - next(self.uid_gen.get_uid_stream("bfcte_")), quoted=self.quoted - ) - - left_select = _select_to_cte(self.expr, left_cte_name) + left_select, left_cte_name = self._select_to_cte() # Prefer subquery over CTE for the IN clause's right side to improve SQL readability. - right_select = right.expr + right_select = right._as_select() left_select, left_ctes = _pop_query_ctes(left_select) right_select, right_ctes = _pop_query_ctes(right_select) @@ -433,21 +363,12 @@ def explode( def sample(self, fraction: float) -> SQLGlotIR: """Uniform samples a fraction of the rows.""" - uuid_col = sge.to_identifier( - next(self.uid_gen.get_uid_stream("bfcol_")), quoted=self.quoted - ) - uuid_expr = sge.Alias(this=sge.func("RAND"), alias=uuid_col) condition = sge.LT( - this=uuid_col, + this=sge.func("RAND"), expression=_literal(fraction, dtypes.FLOAT_DTYPE), ) - new_cte_name = sge.to_identifier( - next(self.uid_gen.get_uid_stream("bfcte_")), quoted=self.quoted - ) - new_expr = _select_to_cte( - self.expr.select(uuid_expr, append=True), new_cte_name - ).where(condition, append=False) + new_expr = self._select_to_cte()[0].where(condition, append=False) return SQLGlotIR(expr=new_expr, uid_gen=self.uid_gen) def aggregate( @@ -471,12 +392,7 @@ def aggregate( for id, expr in aggregations ] - new_expr = _select_to_cte( - self.expr, - sge.to_identifier( - next(self.uid_gen.get_uid_stream("bfcte_")), quoted=self.quoted - ), - ) + new_expr, _ = self._select_to_cte() new_expr = new_expr.group_by(*by_cols).select( *[*by_cols, *aggregations_expr], append=False ) @@ -491,19 +407,12 @@ def aggregate( new_expr = new_expr.where(condition, append=False) return SQLGlotIR(expr=new_expr, uid_gen=self.uid_gen) - def window( - self, - window_op: sge.Expression, - output_column_id: str, - ) -> SQLGlotIR: - return self.project(((output_column_id, window_op),)) - def insert( self, destination: bigquery.TableReference, ) -> str: """Generates an INSERT INTO SQL statement from the current SELECT clause.""" - return sge.insert(self.expr.subquery(), _table(destination)).sql( + return sge.insert(self._as_from_item(), _table(destination)).sql( dialect=self.dialect, pretty=self.pretty ) @@ -527,7 +436,7 @@ def replace( merge_str = sge.Merge( this=_table(destination), - using=self.expr.subquery(), + using=self._as_from_item(), on=_literal(False, dtypes.BOOL_DTYPE), ).sql(dialect=self.dialect, pretty=self.pretty) return f"{merge_str}\n{whens_str}" @@ -550,12 +459,7 @@ def _explode_single_column( ) selection = sge.Star(replace=[unnested_column_alias.as_(column)]) - new_expr = _select_to_cte( - self.expr, - sge.to_identifier( - next(self.uid_gen.get_uid_stream("bfcte_")), quoted=self.quoted - ), - ) + new_expr, _ = self._select_to_cte() # Use LEFT JOIN to preserve rows when unnesting empty arrays. new_expr = new_expr.select(selection, append=False).join( unnest_expr, join_type="LEFT" @@ -606,32 +510,46 @@ def _explode_multiple_columns( for column in columns ] ) - new_expr = _select_to_cte( - self.expr, - sge.to_identifier( - next(self.uid_gen.get_uid_stream("bfcte_")), quoted=self.quoted - ), - ) + new_expr, _ = self._select_to_cte() # Use LEFT JOIN to preserve rows when unnesting empty arrays. new_expr = new_expr.select(selection, append=False).join( unnest_expr, join_type="LEFT" ) return SQLGlotIR(expr=new_expr, uid_gen=self.uid_gen) - -def _select_to_cte(expr: sge.Select, cte_name: sge.Identifier) -> sge.Select: - """Transforms a given sge.Select query by pushing its main SELECT statement - into a new CTE and then generates a 'SELECT * FROM new_cte_name' - for the new query.""" - select_expr = expr.copy() - select_expr, existing_ctes = _pop_query_ctes(select_expr) - new_cte = sge.CTE( - this=select_expr, - alias=cte_name, - ) - new_select_expr = sge.Select().select(sge.Star()).from_(sge.Table(this=cte_name)) - new_select_expr = _set_query_ctes(new_select_expr, [*existing_ctes, new_cte]) - return new_select_expr + def _as_from_item(self) -> typing.Union[sge.Table, sge.Subquery]: + if isinstance(self.expr, sge.Select): + return self.expr.subquery() + else: # table + return self.expr + + def _as_select(self) -> sge.Select: + if isinstance(self.expr, sge.Select): + return self.expr + else: # table + return sge.Select().from_(self.expr) + + def _as_subquery(self) -> sge.Subquery: + return self._as_select().subquery() + + def _select_to_cte(self) -> tuple[sge.Select, sge.Identifier]: + """Transforms a given sge.Select query by pushing its main SELECT statement + into a new CTE and then generates a 'SELECT * FROM new_cte_name' + for the new query.""" + cte_name = sge.to_identifier( + next(self.uid_gen.get_uid_stream("bfcte_")), quoted=self.quoted + ) + select_expr = self._as_select().copy() + select_expr, existing_ctes = _pop_query_ctes(select_expr) + new_cte = sge.CTE( + this=select_expr, + alias=cte_name, + ) + new_select_expr = ( + sge.Select().select(sge.Star()).from_(sge.Table(this=cte_name)) + ) + new_select_expr = _set_query_ctes(new_select_expr, [*existing_ctes, new_cte]) + return new_select_expr, cte_name def _is_null_literal(expr: sge.Expression) -> bool: diff --git a/bigframes/core/rewrite/__init__.py b/bigframes/core/rewrite/__init__.py index 4e5295ae9d3..a120612aae5 100644 --- a/bigframes/core/rewrite/__init__.py +++ b/bigframes/core/rewrite/__init__.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from bigframes.core.rewrite.as_sql import as_sql_nodes from bigframes.core.rewrite.fold_row_count import fold_row_counts from bigframes.core.rewrite.identifiers import remap_variables from bigframes.core.rewrite.implicit_align import try_row_join @@ -25,9 +26,14 @@ from bigframes.core.rewrite.select_pullup import defer_selection from bigframes.core.rewrite.slices import pull_out_limit, pull_up_limits, rewrite_slice from bigframes.core.rewrite.timedeltas import rewrite_timedelta_expressions -from bigframes.core.rewrite.windows import pull_out_window_order, rewrite_range_rolling +from bigframes.core.rewrite.windows import ( + pull_out_window_order, + rewrite_range_rolling, + simplify_complex_windows, +) __all__ = [ + "as_sql_nodes", "legacy_join_as_projection", "try_row_join", "rewrite_slice", @@ -44,4 +50,5 @@ "fold_row_counts", "pull_out_window_order", "defer_selection", + "simplify_complex_windows", ] diff --git a/bigframes/core/rewrite/as_sql.py b/bigframes/core/rewrite/as_sql.py new file mode 100644 index 00000000000..32d677f75d7 --- /dev/null +++ b/bigframes/core/rewrite/as_sql.py @@ -0,0 +1,227 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from __future__ import annotations + +import dataclasses +from typing import Optional, Sequence, Union + +from bigframes.core import ( + agg_expressions, + expression, + identifiers, + nodes, + ordering, + sql_nodes, +) +import bigframes.core.rewrite + + +def _limit(select: sql_nodes.SqlSelectNode, limit: int) -> sql_nodes.SqlSelectNode: + new_limit = limit if select.limit is None else min([select.limit, limit]) + return dataclasses.replace(select, limit=new_limit) + + +def _try_sort( + select: sql_nodes.SqlSelectNode, sort_by: Sequence[ordering.OrderingExpression] +) -> Optional[sql_nodes.SqlSelectNode]: + new_order_exprs = [] + for sort_expr in sort_by: + new_expr = _try_bind( + sort_expr.scalar_expression, select.get_id_mapping(), analytic_allowed=False + ) + if new_expr is None: + return None + new_order_exprs.append( + dataclasses.replace(sort_expr, scalar_expression=new_expr) + ) + return dataclasses.replace(select, sorting=tuple(new_order_exprs)) + + +def _sort( + node: nodes.BigFrameNode, sort_by: Sequence[ordering.OrderingExpression] +) -> sql_nodes.SqlSelectNode: + if isinstance(node, sql_nodes.SqlSelectNode): + merged = _try_sort(node, sort_by) + if merged: + return merged + result = _try_sort(_create_noop_select(node), sort_by) + assert result is not None + return result + + +def _try_bind( + expr: expression.Expression, + bindings: dict[identifiers.ColumnId, expression.Expression], + analytic_allowed: bool = False, # means block binding to an analytic even if original is scalar +) -> Optional[expression.Expression]: + if not expr.is_scalar_expr or not analytic_allowed: + for ref in expr.column_references: + if ref in bindings and not bindings[ref].is_scalar_expr: + return None + return expr.bind_refs(bindings) + + +def _try_add_cdefs( + select: sql_nodes.SqlSelectNode, cdefs: Sequence[nodes.ColumnDef] +) -> Optional[sql_nodes.SqlSelectNode]: + # TODO: add up complexity measure while inlining refs + new_defs = [] + for cdef in cdefs: + cdef_expr = cdef.expression + merged_expr = _try_bind( + cdef_expr, select.get_id_mapping(), analytic_allowed=True + ) + if merged_expr is None: + return None + new_defs.append(nodes.ColumnDef(merged_expr, cdef.id)) + + return dataclasses.replace(select, selections=(*select.selections, *new_defs)) + + +def _add_cdefs( + node: nodes.BigFrameNode, cdefs: Sequence[nodes.ColumnDef] +) -> sql_nodes.SqlSelectNode: + if isinstance(node, sql_nodes.SqlSelectNode): + merged = _try_add_cdefs(node, cdefs) + if merged: + return merged + # Otherwise, wrap the child in a SELECT and add the columns + result = _try_add_cdefs(_create_noop_select(node), cdefs) + assert result is not None + return result + + +def _try_add_filter( + select: sql_nodes.SqlSelectNode, predicates: Sequence[expression.Expression] +) -> Optional[sql_nodes.SqlSelectNode]: + # Filter implicitly happens first, so merging it into ths select will modify non-scalar col expressions + if not all(cdef.expression.is_scalar_expr for cdef in select.selections): + return None + if not all( + sort_expr.scalar_expression.is_scalar_expr for sort_expr in select.sorting + ): + return None + # Constraint: filters can only be merged if they are scalar expression after binding + new_predicates = [] + # bind variables, merge predicates + for predicate in predicates: + merged_pred = _try_bind(predicate, select.get_id_mapping()) + if not merged_pred: + return None + new_predicates.append(merged_pred) + return dataclasses.replace(select, predicates=(*select.predicates, *new_predicates)) + + +def _add_filter( + node: nodes.BigFrameNode, predicates: Sequence[expression.Expression] +) -> sql_nodes.SqlSelectNode: + if isinstance(node, sql_nodes.SqlSelectNode): + result = _try_add_filter(node, predicates) + if result: + return result + new_node = _try_add_filter(_create_noop_select(node), predicates) + assert new_node is not None + return new_node + + +def _create_noop_select(node: nodes.BigFrameNode) -> sql_nodes.SqlSelectNode: + return sql_nodes.SqlSelectNode( + node, + selections=tuple( + nodes.ColumnDef(expression.ResolvedDerefOp.from_field(field), field.id) + for field in node.fields + ), + ) + + +def _try_remap_select_cols( + select: sql_nodes.SqlSelectNode, cols: Sequence[nodes.AliasedRef] +): + new_defs = [] + for aliased_ref in cols: + new_defs.append( + nodes.ColumnDef(select.get_id_mapping()[aliased_ref.ref.id], aliased_ref.id) + ) + + return dataclasses.replace(select, selections=tuple(new_defs)) + + +def _remap_select_cols(node: nodes.BigFrameNode, cols: Sequence[nodes.AliasedRef]): + if isinstance(node, sql_nodes.SqlSelectNode): + result = _try_remap_select_cols(node, cols) + if result: + return result + new_node = _try_remap_select_cols(_create_noop_select(node), cols) + assert new_node is not None + return new_node + + +def _get_added_cdefs(node: Union[nodes.ProjectionNode, nodes.WindowOpNode]): + # TODO: InNode + if isinstance(node, nodes.ProjectionNode): + return tuple(nodes.ColumnDef(expr, id) for expr, id in node.assignments) + if isinstance(node, nodes.WindowOpNode): + new_cdefs = [] + for cdef in node.agg_exprs: + assert isinstance(cdef.expression, agg_expressions.Aggregation) + window_expr = agg_expressions.WindowExpression( + cdef.expression, node.window_spec + ) + # TODO: we probably should do this as another step + rewritten_window_expr = bigframes.core.rewrite.simplify_complex_windows( + window_expr + ) + new_cdefs.append(nodes.ColumnDef(rewritten_window_expr, cdef.id)) + return tuple(new_cdefs) + else: + raise ValueError(f"Unexpected node type: {type(node)}") + + +def _as_sql_node(node: nodes.BigFrameNode) -> nodes.BigFrameNode: + # case one, can be converted to select + if isinstance(node, nodes.ReadTableNode): + leaf = sql_nodes.SqlDataSource(source=node.source) + mappings = [ + nodes.AliasedRef(expression.deref(scan_item.source_id), scan_item.id) + for scan_item in node.scan_list.items + ] + return _remap_select_cols(leaf, mappings) + elif isinstance(node, (nodes.ProjectionNode, nodes.WindowOpNode)): + cdefs = _get_added_cdefs(node) + return _add_cdefs(node.child, cdefs) + elif isinstance(node, (nodes.SelectionNode)): + return _remap_select_cols(node.child, node.input_output_pairs) + elif isinstance(node, nodes.FilterNode): + return _add_filter(node.child, [node.predicate]) + elif isinstance(node, nodes.ResultNode): + result = node.child + if node.order_by is not None: + result = _sort(result, node.order_by.all_ordering_columns) + result = _remap_select_cols( + result, + [ + nodes.AliasedRef(ref, identifiers.ColumnId(name)) + for ref, name in node.output_cols + ], + ) + if node.limit is not None: + result = _limit(result, node.limit) # type: ignore + return result + else: + return node + + +def as_sql_nodes(root: nodes.BigFrameNode) -> nodes.BigFrameNode: + # TODO: Aggregations, Unions, Joins, raw data sources + return nodes.bottom_up(root, _as_sql_node) diff --git a/bigframes/core/rewrite/windows.py b/bigframes/core/rewrite/windows.py index 6e9ba0dd3d0..b95a47d72a5 100644 --- a/bigframes/core/rewrite/windows.py +++ b/bigframes/core/rewrite/windows.py @@ -15,9 +15,72 @@ from __future__ import annotations import dataclasses +import functools +import itertools from bigframes import operations as ops -from bigframes.core import guid, identifiers, nodes, ordering +from bigframes.core import ( + agg_expressions, + expression, + guid, + identifiers, + nodes, + ordering, +) +import bigframes.dtypes +from bigframes.operations import aggregations as agg_ops + + +def simplify_complex_windows( + window_expr: agg_expressions.WindowExpression, +) -> expression.Expression: + result_expr: expression.Expression = window_expr + agg_expr = window_expr.analytic_expr + window_spec = window_expr.window + clauses: list[tuple[expression.Expression, expression.Expression]] = [] + if window_spec.min_periods and len(agg_expr.inputs) > 0: + if not agg_expr.op.nulls_count_for_min_values: + is_observation = ops.notnull_op.as_expr() + + # Most operations do not count NULL values towards min_periods + per_col_does_count = ( + ops.notnull_op.as_expr(input) for input in agg_expr.inputs + ) + # All inputs must be non-null for observation to count + is_observation = functools.reduce( + lambda x, y: ops.and_op.as_expr(x, y), per_col_does_count + ) + observation_sentinel = ops.AsTypeOp(bigframes.dtypes.INT_DTYPE).as_expr( + is_observation + ) + observation_count_expr = agg_expressions.WindowExpression( + agg_expressions.UnaryAggregation(agg_ops.sum_op, observation_sentinel), + window_spec, + ) + else: + # Operations like count treat even NULLs as valid observations for the sake of min_periods + # notnull is just used to convert null values to non-null (FALSE) values to be counted + is_observation = ops.notnull_op.as_expr(agg_expr.inputs[0]) + observation_count_expr = agg_expressions.WindowExpression( + agg_ops.count_op.as_expr(is_observation), + window_spec, + ) + clauses.append( + ( + ops.lt_op.as_expr( + observation_count_expr, expression.const(window_spec.min_periods) + ), + expression.const(None), + ) + ) + if clauses: + case_inputs = [ + *itertools.chain.from_iterable(clauses), + expression.const(True), + result_expr, + ] + result_expr = ops.CaseWhenOp().as_expr(*case_inputs) + return result_expr def rewrite_range_rolling(node: nodes.BigFrameNode) -> nodes.BigFrameNode: diff --git a/bigframes/core/sql_nodes.py b/bigframes/core/sql_nodes.py new file mode 100644 index 00000000000..a1624a10217 --- /dev/null +++ b/bigframes/core/sql_nodes.py @@ -0,0 +1,157 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import annotations + +import dataclasses +import functools +from typing import Mapping, Optional, Sequence, Tuple + +from bigframes.core import bq_data, identifiers, nodes +import bigframes.core.expression as ex +from bigframes.core.ordering import OrderingExpression +import bigframes.dtypes + + +# TODO: Join node, union node +@dataclasses.dataclass(frozen=True) +class SqlDataSource(nodes.LeafNode): + source: bq_data.BigqueryDataSource + + @functools.cached_property + def fields(self) -> Sequence[nodes.Field]: + return tuple( + nodes.Field( + identifiers.ColumnId(source_id), + self.source.schema.get_type(source_id), + self.source.table.schema_by_id[source_id].is_nullable, + ) + for source_id in self.source.schema.names + ) + + @property + def variables_introduced(self) -> int: + # This operation only renames variables, doesn't actually create new ones + return 0 + + @property + def defines_namespace(self) -> bool: + return True + + @property + def explicitly_ordered(self) -> bool: + return False + + @property + def order_ambiguous(self) -> bool: + return True + + @property + def row_count(self) -> Optional[int]: + return self.source.n_rows + + @property + def node_defined_ids(self) -> Tuple[identifiers.ColumnId, ...]: + return tuple(self.ids) + + @property + def consumed_ids(self): + return () + + @property + def _node_expressions(self): + return () + + def remap_vars( + self, mappings: Mapping[identifiers.ColumnId, identifiers.ColumnId] + ) -> SqlSelectNode: + raise NotImplementedError() + + def remap_refs( + self, mappings: Mapping[identifiers.ColumnId, identifiers.ColumnId] + ) -> SqlSelectNode: + raise NotImplementedError() # type: ignore + + +@dataclasses.dataclass(frozen=True) +class SqlSelectNode(nodes.UnaryNode): + selections: tuple[nodes.ColumnDef, ...] = () + predicates: tuple[ex.Expression, ...] = () + sorting: tuple[OrderingExpression, ...] = () + limit: Optional[int] = None + + @functools.cached_property + def fields(self) -> Sequence[nodes.Field]: + fields = [] + for cdef in self.selections: + bound_expr = ex.bind_schema_fields(cdef.expression, self.child.field_by_id) + field = nodes.Field( + cdef.id, + bigframes.dtypes.dtype_for_etype(bound_expr.output_type), + nullable=bound_expr.nullable, + ) + + # Special case until we get better nullability inference in expression objects themselves + if bound_expr.is_identity and not any( + self.child.field_by_id[id].nullable + for id in cdef.expression.column_references + ): + field = field.with_nonnull() + fields.append(field) + + return tuple(fields) + + @property + def variables_introduced(self) -> int: + # This operation only renames variables, doesn't actually create new ones + return 0 + + @property + def defines_namespace(self) -> bool: + return True + + @property + def row_count(self) -> Optional[int]: + if self.child.row_count is not None: + if self.limit is not None: + return min([self.limit, self.child.row_count]) + return self.child.row_count + + return None + + @property + def node_defined_ids(self) -> Tuple[identifiers.ColumnId, ...]: + return tuple(cdef.id for cdef in self.selections) + + @property + def consumed_ids(self): + raise NotImplementedError() + + @property + def _node_expressions(self): + raise NotImplementedError() + + @functools.cache + def get_id_mapping(self) -> dict[identifiers.ColumnId, ex.Expression]: + return {cdef.id: cdef.expression for cdef in self.selections} + + def remap_vars( + self, mappings: Mapping[identifiers.ColumnId, identifiers.ColumnId] + ) -> SqlSelectNode: + raise NotImplementedError() + + def remap_refs( + self, mappings: Mapping[identifiers.ColumnId, identifiers.ColumnId] + ) -> SqlSelectNode: + raise NotImplementedError() # type: ignore 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 f1197465f0d..e2b5c841046 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_row_number/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_row_number/out.sql @@ -1,27 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `bytes_col`, - `date_col`, - `datetime_col`, - `duration_col`, - `float64_col`, - `geography_col`, - `int64_col`, - `int64_too`, - `numeric_col`, - `rowindex`, - `rowindex_2`, - `string_col`, - `time_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ROW_NUMBER() OVER () - 1 AS `bfcol_32` - FROM `bfcte_0` -) SELECT - `bfcol_32` AS `row_number` -FROM `bfcte_1` \ No newline at end of file + ROW_NUMBER() OVER () - 1 AS `row_number` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 bfa67b8a747..5301ba76fd3 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ROW_NUMBER() OVER (ORDER BY `int64_col` ASC NULLS LAST) - 1 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 `int64_col` ASC NULLS LAST) - 1 AS `row_number` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all_w_window/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all_w_window/out.sql index 829e5a88361..b05158ef22f 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all_w_window/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all_w_window/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COALESCE(LOGICAL_AND(`bool_col`) OVER (), TRUE) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_bool` -FROM `bfcte_1` \ No newline at end of file + COALESCE(LOGICAL_AND(`bool_col`) OVER (), TRUE) AS `agg_bool` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_out.sql index ea15243d90a..15e30775712 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ANY_VALUE(`int64_col`) OVER () AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + ANY_VALUE(`int64_col`) OVER () AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_partition_out.sql index e722318fbce..d6b97b9b690 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_partition_out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ANY_VALUE(`int64_col`) OVER (PARTITION BY `string_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + ANY_VALUE(`int64_col`) OVER (PARTITION BY `string_col`) AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_w_window/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_w_window/out.sql index 337f0ff9638..ae7a1d92fa6 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_w_window/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_w_window/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COALESCE(LOGICAL_OR(`bool_col`) OVER (), FALSE) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_bool` -FROM `bfcte_1` \ No newline at end of file + COALESCE(LOGICAL_OR(`bool_col`) OVER (), FALSE) AS `agg_bool` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_out.sql index 0baac953118..7be9980fc23 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COUNT(`int64_col`) OVER () AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + COUNT(`int64_col`) OVER () AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_partition_out.sql index 6d3f8564599..7f2066d98ea 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_partition_out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COUNT(`int64_col`) OVER (PARTITION BY `string_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + COUNT(`int64_col`) OVER (PARTITION BY `string_col`) AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins.sql index 015ac327998..d7b0fde7103 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins.sql @@ -1,55 +1,45 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `int64_col` <= MIN(`int64_col`) OVER () + ( - 1 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) - ) - THEN STRUCT( +SELECT + CASE + WHEN `int64_col` <= MIN(`int64_col`) OVER () + ( + 1 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) + ) + THEN STRUCT( + ( + MIN(`int64_col`) OVER () + ( + 0 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) + ) + ) - ( ( - MIN(`int64_col`) OVER () + ( - 0 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) - ) - ) - ( - ( - MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER () - ) * 0.001 - ) AS `left_exclusive`, + MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER () + ) * 0.001 + ) AS `left_exclusive`, + MIN(`int64_col`) OVER () + ( + 1 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) + ) + 0 AS `right_inclusive` + ) + WHEN `int64_col` <= MIN(`int64_col`) OVER () + ( + 2 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) + ) + THEN STRUCT( + ( MIN(`int64_col`) OVER () + ( 1 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) - ) + 0 AS `right_inclusive` - ) - WHEN `int64_col` <= MIN(`int64_col`) OVER () + ( + ) + ) - 0 AS `left_exclusive`, + MIN(`int64_col`) OVER () + ( 2 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) - ) - THEN STRUCT( - ( - MIN(`int64_col`) OVER () + ( - 1 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) - ) - ) - 0 AS `left_exclusive`, + ) + 0 AS `right_inclusive` + ) + WHEN `int64_col` IS NOT NULL + THEN STRUCT( + ( MIN(`int64_col`) OVER () + ( 2 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) - ) + 0 AS `right_inclusive` - ) - WHEN `int64_col` IS NOT NULL - THEN STRUCT( - ( - MIN(`int64_col`) OVER () + ( - 2 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) - ) - ) - 0 AS `left_exclusive`, - MIN(`int64_col`) OVER () + ( - 3 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) - ) + 0 AS `right_inclusive` - ) - END AS `bfcol_1` - FROM `bfcte_0` -) -SELECT - `bfcol_1` AS `int_bins` -FROM `bfcte_1` \ No newline at end of file + ) + ) - 0 AS `left_exclusive`, + MIN(`int64_col`) OVER () + ( + 3 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) + ) + 0 AS `right_inclusive` + ) + END AS `int_bins` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins_labels.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins_labels.sql index c98682f2b83..1a3aede0502 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins_labels.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins_labels.sql @@ -1,24 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `int64_col` < MIN(`int64_col`) OVER () + ( - 1 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) - ) - THEN 'a' - WHEN `int64_col` < MIN(`int64_col`) OVER () + ( - 2 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) - ) - THEN 'b' - WHEN `int64_col` IS NOT NULL - THEN 'c' - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int_bins_labels` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `int64_col` < MIN(`int64_col`) OVER () + ( + 1 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) + ) + THEN 'a' + WHEN `int64_col` < MIN(`int64_col`) OVER () + ( + 2 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) + ) + THEN 'b' + WHEN `int64_col` IS NOT NULL + THEN 'c' + END AS `int_bins_labels` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins.sql index a3e689b11ec..3365500e0bd 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins.sql @@ -1,18 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `int64_col` > 0 AND `int64_col` <= 1 - THEN STRUCT(0 AS `left_exclusive`, 1 AS `right_inclusive`) - WHEN `int64_col` > 1 AND `int64_col` <= 2 - THEN STRUCT(1 AS `left_exclusive`, 2 AS `right_inclusive`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `interval_bins` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `int64_col` > 0 AND `int64_col` <= 1 + THEN STRUCT(0 AS `left_exclusive`, 1 AS `right_inclusive`) + WHEN `int64_col` > 1 AND `int64_col` <= 2 + THEN STRUCT(1 AS `left_exclusive`, 2 AS `right_inclusive`) + END AS `interval_bins` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins_labels.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins_labels.sql index 1a8a92e38ee..2cc91765c84 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins_labels.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins_labels.sql @@ -1,18 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `int64_col` > 0 AND `int64_col` <= 1 - THEN 0 - WHEN `int64_col` > 1 AND `int64_col` <= 2 - THEN 1 - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `interval_bins_labels` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `int64_col` > 0 AND `int64_col` <= 1 + THEN 0 + WHEN `int64_col` > 1 AND `int64_col` <= 2 + THEN 1 + END AS `interval_bins_labels` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 76b455a65c9..d8f8e26ddcb 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - DENSE_RANK() OVER (ORDER BY `int64_col` DESC) 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 `int64_col` DESC) AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_bool/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_bool/out.sql index 96d23c4747d..18da6d95fbf 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_bool/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_bool/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bool_col` <> LAG(`bool_col`, 1) OVER (ORDER BY `bool_col` DESC) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `diff_bool` -FROM `bfcte_1` \ No newline at end of file + `bool_col` <> LAG(`bool_col`, 1) OVER (ORDER BY `bool_col` DESC) AS `diff_bool` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_date/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_date/out.sql index 4f1729d2e28..d5a548f9207 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_date/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_date/out.sql @@ -1,15 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(FLOOR( - DATE_DIFF(`date_col`, LAG(`date_col`, 1) OVER (ORDER BY `date_col` ASC NULLS LAST), DAY) * 86400000000 - ) AS INT64) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `diff_date` -FROM `bfcte_1` \ No newline at end of file + CAST(FLOOR( + DATE_DIFF(`date_col`, LAG(`date_col`, 1) OVER (ORDER BY `date_col` ASC NULLS LAST), DAY) * 86400000000 + ) AS INT64) AS `diff_date` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_datetime/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_datetime/out.sql index 9c279a479d5..c997025ad2a 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_datetime/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_datetime/out.sql @@ -1,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `datetime_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - DATETIME_DIFF( - `datetime_col`, - LAG(`datetime_col`, 1) OVER (ORDER BY `datetime_col` ASC NULLS LAST), - MICROSECOND - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `diff_datetime` -FROM `bfcte_1` \ No newline at end of file + DATETIME_DIFF( + `datetime_col`, + LAG(`datetime_col`, 1) OVER (ORDER BY `datetime_col` ASC NULLS LAST), + MICROSECOND + ) AS `diff_datetime` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_int/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_int/out.sql index 95d786b951e..37acf8896ef 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_int/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_int/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `int64_col` - LAG(`int64_col`, 1) OVER (ORDER BY `int64_col` ASC NULLS LAST) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `diff_int` -FROM `bfcte_1` \ No newline at end of file + `int64_col` - LAG(`int64_col`, 1) OVER (ORDER BY `int64_col` ASC NULLS LAST) AS `diff_int` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_timestamp/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_timestamp/out.sql index 1f8b8227b4a..5ed7e83ae5c 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_timestamp/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_timestamp/out.sql @@ -1,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIMESTAMP_DIFF( - `timestamp_col`, - LAG(`timestamp_col`, 1) OVER (ORDER BY `timestamp_col` DESC), - MICROSECOND - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `diff_timestamp` -FROM `bfcte_1` \ No newline at end of file + TIMESTAMP_DIFF( + `timestamp_col`, + LAG(`timestamp_col`, 1) OVER (ORDER BY `timestamp_col` DESC), + MICROSECOND + ) AS `diff_timestamp` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first/out.sql index b053178f584..29de93c80c9 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first/out.sql @@ -1,16 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FIRST_VALUE(`int64_col`) OVER ( - ORDER BY `int64_col` DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + FIRST_VALUE(`int64_col`) OVER ( + ORDER BY `int64_col` DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first_non_null/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first_non_null/out.sql index 2ef7b7151e2..4d53d126104 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first_non_null/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first_non_null/out.sql @@ -1,16 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FIRST_VALUE(`int64_col` IGNORE NULLS) OVER ( - ORDER BY `int64_col` ASC NULLS LAST - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + FIRST_VALUE(`int64_col` IGNORE NULLS) OVER ( + ORDER BY `int64_col` ASC NULLS LAST + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last/out.sql index 61e90ee612e..8e41cbd8b69 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last/out.sql @@ -1,16 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LAST_VALUE(`int64_col`) OVER ( - ORDER BY `int64_col` DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + LAST_VALUE(`int64_col`) OVER ( + ORDER BY `int64_col` DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last_non_null/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last_non_null/out.sql index c626c263ace..a563eeb52ad 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last_non_null/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last_non_null/out.sql @@ -1,16 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LAST_VALUE(`int64_col` IGNORE NULLS) OVER ( - ORDER BY `int64_col` ASC NULLS LAST - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + LAST_VALUE(`int64_col` IGNORE NULLS) OVER ( + ORDER BY `int64_col` ASC NULLS LAST + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_out.sql index f55201418a9..75fdbcdc217 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - MAX(`int64_col`) OVER () AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + MAX(`int64_col`) OVER () AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_partition_out.sql index ac9b2df84e1..48630c48e38 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_partition_out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - MAX(`int64_col`) OVER (PARTITION BY `string_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + MAX(`int64_col`) OVER (PARTITION BY `string_col`) AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 0b33d0b1d0a..2f9d540776f 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 @@ -2,26 +2,22 @@ WITH `bfcte_0` AS ( SELECT `bool_col`, `duration_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, + `int64_col`, `int64_col` AS `bfcol_6`, `bool_col` AS `bfcol_7`, `duration_col` AS `bfcol_8` - FROM `bfcte_0` -), `bfcte_2` AS ( + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +), `bfcte_1` 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` + FROM `bfcte_0` ) 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 `bfcte_1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_out.sql index fdb59809c31..13a595b85e0 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AVG(`int64_col`) OVER () AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + AVG(`int64_col`) OVER () AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_partition_out.sql index d96121e54da..c1bfa7d10b3 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_partition_out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AVG(`int64_col`) OVER (PARTITION BY `string_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + AVG(`int64_col`) OVER (PARTITION BY `string_col`) AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_out.sql index cbda2b7d581..ab5c4c21f97 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - MIN(`int64_col`) OVER () AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + MIN(`int64_col`) OVER () AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_partition_out.sql index d601832950e..2233ebe38dd 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_partition_out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - MIN(`int64_col`) OVER (PARTITION BY `string_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + MIN(`int64_col`) OVER (PARTITION BY `string_col`) AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/window_out.sql index 430da33e3c3..c3971c61b54 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/window_out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - VAR_POP(`int64_col`) OVER () AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + VAR_POP(`int64_col`) OVER () AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_product/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_product/window_partition_out.sql index c5f12f70093..335bfcd17c2 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_product/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_product/window_partition_out.sql @@ -1,27 +1,16 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN LOGICAL_OR(`int64_col` = 0) OVER (PARTITION BY `string_col`) - THEN 0 - ELSE POWER( - 2, - SUM(IF(`int64_col` = 0, 0, LOG(ABS(`int64_col`), 2))) OVER (PARTITION BY `string_col`) - ) * POWER( - -1, - MOD( - SUM(CASE WHEN SIGN(`int64_col`) = -1 THEN 1 ELSE 0 END) OVER (PARTITION BY `string_col`), - 2 - ) - ) - END AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN LOGICAL_OR(`int64_col` = 0) OVER (PARTITION BY `string_col`) + THEN 0 + ELSE POWER( + 2, + SUM(IF(`int64_col` = 0, 0, LOG(ABS(`int64_col`), 2))) OVER (PARTITION BY `string_col`) + ) * POWER( + -1, + MOD( + SUM(CASE WHEN SIGN(`int64_col`) = -1 THEN 1 ELSE 0 END) OVER (PARTITION BY `string_col`), + 2 + ) + ) + END AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_qcut/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_qcut/out.sql index 1aa2e436caa..e24f5050303 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_qcut/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_qcut/out.sql @@ -1,61 +1,51 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - NOT `int64_col` IS NULL AS `bfcol_4` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, +SELECT + `rowindex`, + `int64_col`, + IF( + NOT ( + `int64_col` + ) IS NULL, IF( `int64_col` IS NULL, NULL, CAST(GREATEST( - CEIL(PERCENT_RANK() OVER (PARTITION BY `bfcol_4` ORDER BY `int64_col` ASC) * 4) - 1, + CEIL( + PERCENT_RANK() OVER (PARTITION BY NOT ( + `int64_col` + ) IS NULL ORDER BY `int64_col` ASC) * 4 + ) - 1, 0 ) AS INT64) - ) AS `bfcol_5` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - IF(`bfcol_4`, `bfcol_5`, NULL) AS `bfcol_6` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - NOT `int64_col` IS NULL AS `bfcol_10` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, + ), + NULL + ) AS `qcut_w_int`, + IF( + NOT ( + `int64_col` + ) IS NULL, CASE - WHEN PERCENT_RANK() OVER (PARTITION BY `bfcol_10` ORDER BY `int64_col` ASC) < 0 + WHEN PERCENT_RANK() OVER (PARTITION BY NOT ( + `int64_col` + ) IS NULL ORDER BY `int64_col` ASC) < 0 THEN NULL - WHEN PERCENT_RANK() OVER (PARTITION BY `bfcol_10` ORDER BY `int64_col` ASC) <= 0.25 + WHEN PERCENT_RANK() OVER (PARTITION BY NOT ( + `int64_col` + ) IS NULL ORDER BY `int64_col` ASC) <= 0.25 THEN 0 - WHEN PERCENT_RANK() OVER (PARTITION BY `bfcol_10` ORDER BY `int64_col` ASC) <= 0.5 + WHEN PERCENT_RANK() OVER (PARTITION BY NOT ( + `int64_col` + ) IS NULL ORDER BY `int64_col` ASC) <= 0.5 THEN 1 - WHEN PERCENT_RANK() OVER (PARTITION BY `bfcol_10` ORDER BY `int64_col` ASC) <= 0.75 + WHEN PERCENT_RANK() OVER (PARTITION BY NOT ( + `int64_col` + ) IS NULL ORDER BY `int64_col` ASC) <= 0.75 THEN 2 - WHEN PERCENT_RANK() OVER (PARTITION BY `bfcol_10` ORDER BY `int64_col` ASC) <= 1 + WHEN PERCENT_RANK() OVER (PARTITION BY NOT ( + `int64_col` + ) IS NULL ORDER BY `int64_col` ASC) <= 1 THEN 3 ELSE NULL - END AS `bfcol_11` - FROM `bfcte_4` -), `bfcte_6` AS ( - SELECT - *, - IF(`bfcol_10`, `bfcol_11`, NULL) AS `bfcol_12` - FROM `bfcte_5` -) -SELECT - `rowindex`, - `int64_col`, - `bfcol_6` AS `qcut_w_int`, - `bfcol_12` AS `qcut_w_list` -FROM `bfcte_6` \ No newline at end of file + END, + NULL + ) AS `qcut_w_list` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 96b121bde49..cdba69fe68d 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - RANK() OVER (ORDER BY `int64_col` DESC NULLS FIRST) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + RANK() OVER (ORDER BY `int64_col` DESC NULLS FIRST) AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lag.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lag.sql index 7d1d62f1ae4..674c59fb1e2 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lag.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lag.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LAG(`int64_col`, 1) OVER (ORDER BY `int64_col` ASC) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `lag` -FROM `bfcte_1` \ No newline at end of file + LAG(`int64_col`, 1) OVER (ORDER BY `int64_col` ASC) AS `lag` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lead.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lead.sql index 67b40c99db0..eff56dd81d8 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lead.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lead.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LEAD(`int64_col`, 1) OVER (ORDER BY `int64_col` ASC) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `lead` -FROM `bfcte_1` \ No newline at end of file + LEAD(`int64_col`, 1) OVER (ORDER BY `int64_col` ASC) AS `lead` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/noop.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/noop.sql index 0202cf5c214..ec2e9d11a06 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/noop.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/noop.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `int64_col` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `noop` -FROM `bfcte_1` \ No newline at end of file + `int64_col` AS `noop` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql index 36a50302a66..bc744258913 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql @@ -2,26 +2,22 @@ WITH `bfcte_0` AS ( SELECT `bool_col`, `duration_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, + `int64_col`, `int64_col` AS `bfcol_6`, `bool_col` AS `bfcol_7`, `duration_col` AS `bfcol_8` - FROM `bfcte_0` -), `bfcte_2` AS ( + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +), `bfcte_1` AS ( SELECT STDDEV(`bfcol_6`) AS `bfcol_12`, STDDEV(CAST(`bfcol_7` AS INT64)) AS `bfcol_13`, CAST(FLOOR(STDDEV(`bfcol_8`)) AS INT64) AS `bfcol_14`, CAST(FLOOR(STDDEV(`bfcol_6`)) AS INT64) AS `bfcol_15` - FROM `bfcte_1` + FROM `bfcte_0` ) 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 `bfcte_1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/window_out.sql index 80e0cf5bc62..7f8da195e96 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/window_out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - STDDEV(`int64_col`) OVER () AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + STDDEV(`int64_col`) OVER () AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_out.sql index 47426abcbd0..0a5ad499321 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COALESCE(SUM(`int64_col`) OVER (), 0) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + COALESCE(SUM(`int64_col`) OVER (), 0) AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_partition_out.sql index fd1bd4f630d..ccf39df0f77 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_partition_out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COALESCE(SUM(`int64_col`) OVER (PARTITION BY `string_col`), 0) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + COALESCE(SUM(`int64_col`) OVER (PARTITION BY `string_col`), 0) AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/window_out.sql index e9d6c1cb932..c82ca3324d7 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/window_out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - VARIANCE(`int64_col`) OVER () AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `agg_int64` -FROM `bfcte_1` \ No newline at end of file + VARIANCE(`int64_col`) OVER () AS `agg_int64` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_classify/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_classify/out.sql index a40784a3ca5..65098ca9e2a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_classify/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_classify/out.sql @@ -1,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.CLASSIFY( - input => (`string_col`), - categories => ['greeting', 'rejection'], - connection_id => 'bigframes-dev.us.bigframes-default-connection' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.CLASSIFY( + input => (`string_col`), + categories => ['greeting', 'rejection'], + connection_id => 'bigframes-dev.us.bigframes-default-connection' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate/out.sql index ec3515e7ed7..0d79dfd0f0f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate/out.sql @@ -1,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE( - prompt => (`string_col`, ' is the same as ', `string_col`), - endpoint => 'gemini-2.5-flash', - request_type => 'SHARED' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE( + prompt => (`string_col`, ' is the same as ', `string_col`), + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 3a09da7c3a2..7a4260ed8d5 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,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_BOOL( - prompt => (`string_col`, ' is the same as ', `string_col`), - 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 => (`string_col`, ' is the same as ', `string_col`), + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool_with_connection_id/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool_with_connection_id/out.sql index f844ed16918..ebbe4c0847d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool_with_connection_id/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool_with_connection_id/out.sql @@ -1,18 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_BOOL( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection', - endpoint => 'gemini-2.5-flash', - request_type => 'SHARED' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE_BOOL( + prompt => (`string_col`, ' is the same as ', `string_col`), + connection_id => 'bigframes-dev.us.bigframes-default-connection', + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 2a81ced7823..2556208610c 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,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_BOOL( - prompt => (`string_col`, ' is the same as ', `string_col`), - 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 => (`string_col`, ' is the same as ', `string_col`), + request_type => 'SHARED', + model_params => JSON '{}' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 3b894296210..2712af87752 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,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_DOUBLE( - prompt => (`string_col`, ' is the same as ', `string_col`), - 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 => (`string_col`, ' is the same as ', `string_col`), + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double_with_connection_id/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double_with_connection_id/out.sql index fae92515cbe..a1671c300df 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double_with_connection_id/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double_with_connection_id/out.sql @@ -1,18 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_DOUBLE( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection', - endpoint => 'gemini-2.5-flash', - request_type => 'SHARED' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE_DOUBLE( + prompt => (`string_col`, ' is the same as ', `string_col`), + connection_id => 'bigframes-dev.us.bigframes-default-connection', + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 480ee09ef65..4f6ada7eee3 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,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_DOUBLE( - prompt => (`string_col`, ' is the same as ', `string_col`), - 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 => (`string_col`, ' is the same as ', `string_col`), + request_type => 'SHARED', + model_params => JSON '{}' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 f33af547c7f..42fad82bcf5 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,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_INT( - prompt => (`string_col`, ' is the same as ', `string_col`), - 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 => (`string_col`, ' is the same as ', `string_col`), + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int_with_connection_id/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int_with_connection_id/out.sql index a0c92c959c2..0c565df519f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int_with_connection_id/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int_with_connection_id/out.sql @@ -1,18 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_INT( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection', - endpoint => 'gemini-2.5-flash', - request_type => 'SHARED' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE_INT( + prompt => (`string_col`, ' is the same as ', `string_col`), + connection_id => 'bigframes-dev.us.bigframes-default-connection', + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 2929e57ba0c..360ca346987 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,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE_INT( - prompt => (`string_col`, ' is the same as ', `string_col`), - 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 => (`string_col`, ' is the same as ', `string_col`), + request_type => 'SHARED', + model_params => JSON '{}' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_connection_id/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_connection_id/out.sql index 19f85b181b2..5e289430d98 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_connection_id/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_connection_id/out.sql @@ -1,18 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection', - endpoint => 'gemini-2.5-flash', - request_type => 'SHARED' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE( + prompt => (`string_col`, ' is the same as ', `string_col`), + connection_id => 'bigframes-dev.us.bigframes-default-connection', + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_model_param/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_model_param/out.sql index 745243db3a0..1706cf8f308 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_model_param/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_model_param/out.sql @@ -1,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE( - prompt => (`string_col`, ' is the same as ', `string_col`), - request_type => 'SHARED', - model_params => JSON '{}' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE( + prompt => (`string_col`, ' is the same as ', `string_col`), + request_type => 'SHARED', + model_params => JSON '{}' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_output_schema/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_output_schema/out.sql index 4f7867a0f20..c94637dc707 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_output_schema/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_output_schema/out.sql @@ -1,18 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.GENERATE( - prompt => (`string_col`, ' is the same as ', `string_col`), - endpoint => 'gemini-2.5-flash', - request_type => 'SHARED', - output_schema => 'x INT64, y FLOAT64' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.GENERATE( + prompt => (`string_col`, ' is the same as ', `string_col`), + endpoint => 'gemini-2.5-flash', + request_type => 'SHARED', + output_schema => 'x INT64, y FLOAT64' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_if/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_if/out.sql index 275ba8d4239..8ad4457475d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_if/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_if/out.sql @@ -1,16 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.IF( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.IF( + prompt => (`string_col`, ' is the same as ', `string_col`), + connection_id => 'bigframes-dev.us.bigframes-default-connection' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_score/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_score/out.sql index 01c71065b92..709dfd11c09 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_score/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_score/out.sql @@ -1,16 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - AI.SCORE( - prompt => (`string_col`, ' is the same as ', `string_col`), - connection_id => 'bigframes-dev.us.bigframes-default-connection' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `result` -FROM `bfcte_1` \ No newline at end of file + AI.SCORE( + prompt => (`string_col`, ' is the same as ', `string_col`), + connection_id => 'bigframes-dev.us.bigframes-default-connection' + ) AS `result` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 d8e223d5f85..0198d92697e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_index/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_index/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - `string_list_col`[SAFE_OFFSET(1)] AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + `string_list_col`[SAFE_OFFSET(1)] AS `string_list_col` +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_reduce_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_reduce_op/out.sql index b9f87bfd1ed..7c955a273aa 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_reduce_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_reduce_op/out.sql @@ -1,37 +1,22 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_list_col`, - `float_list_col`, - `string_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ( - SELECT - COALESCE(SUM(bf_arr_reduce_uid), 0) - FROM UNNEST(`float_list_col`) AS bf_arr_reduce_uid - ) AS `bfcol_3`, - ( - SELECT - STDDEV(bf_arr_reduce_uid) - FROM UNNEST(`float_list_col`) AS bf_arr_reduce_uid - ) AS `bfcol_4`, - ( - SELECT - COUNT(bf_arr_reduce_uid) - FROM UNNEST(`string_list_col`) AS bf_arr_reduce_uid - ) AS `bfcol_5`, - ( - SELECT - COALESCE(LOGICAL_OR(bf_arr_reduce_uid), FALSE) - FROM UNNEST(`bool_list_col`) AS bf_arr_reduce_uid - ) AS `bfcol_6` - FROM `bfcte_0` -) SELECT - `bfcol_3` AS `sum_float`, - `bfcol_4` AS `std_float`, - `bfcol_5` AS `count_str`, - `bfcol_6` AS `any_bool` -FROM `bfcte_1` \ No newline at end of file + ( + SELECT + COALESCE(SUM(bf_arr_reduce_uid), 0) + FROM UNNEST(`float_list_col`) AS bf_arr_reduce_uid + ) AS `sum_float`, + ( + SELECT + STDDEV(bf_arr_reduce_uid) + FROM UNNEST(`float_list_col`) AS bf_arr_reduce_uid + ) AS `std_float`, + ( + SELECT + COUNT(bf_arr_reduce_uid) + FROM UNNEST(`string_list_col`) AS bf_arr_reduce_uid + ) AS `count_str`, + ( + SELECT + COALESCE(LOGICAL_OR(bf_arr_reduce_uid), FALSE) + FROM UNNEST(`bool_list_col`) AS bf_arr_reduce_uid + ) AS `any_bool` +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ 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 0034ffd69cd..2fb104cdf40 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_slice_with_only_start/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_slice_with_only_start/out.sql @@ -1,19 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY( - SELECT - el - FROM UNNEST(`string_list_col`) AS el WITH OFFSET AS slice_idx - WHERE - slice_idx >= 1 - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + ARRAY( + SELECT + el + FROM UNNEST(`string_list_col`) AS el WITH OFFSET AS slice_idx + WHERE + slice_idx >= 1 + ) AS `string_list_col` +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ 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 f0638fa3afc..e6bcf4f1e27 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,9 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY( - SELECT - el - FROM UNNEST(`string_list_col`) AS el WITH OFFSET AS slice_idx - WHERE - slice_idx >= 1 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(`string_list_col`) AS el WITH OFFSET AS slice_idx + WHERE + slice_idx >= 1 AND slice_idx < 5 + ) AS `string_list_col` +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ 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 09446bb8f51..435249cbe9c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_to_string/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_to_string/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY_TO_STRING(`string_list_col`, '.') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + ARRAY_TO_STRING(`string_list_col`, '.') AS `string_list_col` +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_to_array_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_to_array_op/out.sql index 3e297016584..a243c37d4fe 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_to_array_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_to_array_op/out.sql @@ -1,26 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - [COALESCE(`bool_col`, FALSE)] AS `bfcol_8`, - [COALESCE(`int64_col`, 0)] AS `bfcol_9`, - [COALESCE(`string_col`, ''), COALESCE(`string_col`, '')] AS `bfcol_10`, - [ - COALESCE(`int64_col`, 0), - CAST(COALESCE(`bool_col`, FALSE) AS INT64), - COALESCE(`float64_col`, 0.0) - ] AS `bfcol_11` - FROM `bfcte_0` -) SELECT - `bfcol_8` AS `bool_col`, - `bfcol_9` AS `int64_col`, - `bfcol_10` AS `strs_col`, - `bfcol_11` AS `numeric_col` -FROM `bfcte_1` \ No newline at end of file + [COALESCE(`bool_col`, FALSE)] AS `bool_col`, + [COALESCE(`int64_col`, 0)] AS `int64_col`, + [COALESCE(`string_col`, ''), COALESCE(`string_col`, '')] AS `strs_col`, + [ + COALESCE(`int64_col`, 0), + CAST(COALESCE(`bool_col`, FALSE) AS INT64), + COALESCE(`float64_col`, 0.0) + ] AS `numeric_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 bd99b860648..5efae7637a0 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,6 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - OBJ.MAKE_REF(`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') AS `bfcol_4` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - OBJ.FETCH_METADATA(`bfcol_4`) AS `bfcol_7` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_7`.`version` AS `bfcol_10` - FROM `bfcte_2` -) SELECT `rowindex`, - `bfcol_10` AS `version` -FROM `bfcte_3` \ No newline at end of file + OBJ.FETCH_METADATA( + OBJ.MAKE_REF(`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') + ).`version` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 28c2f2ce181..675f19af69b 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,10 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - OBJ.MAKE_REF(`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') AS `bfcol_4` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - OBJ.GET_ACCESS_URL(`bfcol_4`, 'R') AS `bfcol_7` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - JSON_VALUE(`bfcol_7`, '$.access_urls.read_url') AS `bfcol_10` - FROM `bfcte_2` -) SELECT `rowindex`, - `bfcol_10` AS `string_col` -FROM `bfcte_3` \ No newline at end of file + JSON_VALUE( + OBJ.GET_ACCESS_URL( + OBJ.MAKE_REF(`string_col`, 'bigframes-dev.test-region.bigframes-default-connection'), + 'R' + ), + '$.access_urls.read_url' + ) AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 d74449c986e..89e891c0825 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,4 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - OBJ.MAKE_REF(`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') AS `bfcol_4` - FROM `bfcte_0` -) SELECT `rowindex`, - `bfcol_4` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + OBJ.MAKE_REF(`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 7e46e10708d..074a291883a 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,42 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `bool_col` AS `bfcol_7`, - `int64_col` AS `bfcol_8`, - `int64_col` & `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` AND `bfcol_7` AS `bfcol_18` - FROM `bfcte_1` -), `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`, - IF(`bfcol_15` = FALSE, `bfcol_15`, NULL) AS `bfcol_29` - FROM `bfcte_2` -) SELECT - `bfcol_24` AS `rowindex`, - `bfcol_25` AS `bool_col`, - `bfcol_26` AS `int64_col`, - `bfcol_27` AS `int_and_int`, - `bfcol_28` AS `bool_and_bool`, - `bfcol_29` AS `bool_and_null` -FROM `bfcte_3` \ No newline at end of file + `rowindex`, + `bool_col`, + `int64_col`, + `int64_col` & `int64_col` AS `int_and_int`, + `bool_col` AND `bool_col` AS `bool_and_bool`, + IF(`bool_col` = FALSE, `bool_col`, NULL) AS `bool_and_null` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 c8e9cf65a91..7ebb3f77fe4 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,42 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `bool_col` AS `bfcol_7`, - `int64_col` AS `bfcol_8`, - `int64_col` | `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` OR `bfcol_7` AS `bfcol_18` - FROM `bfcte_1` -), `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`, - IF(`bfcol_15` = TRUE, `bfcol_15`, NULL) AS `bfcol_29` - FROM `bfcte_2` -) SELECT - `bfcol_24` AS `rowindex`, - `bfcol_25` AS `bool_col`, - `bfcol_26` AS `int64_col`, - `bfcol_27` AS `int_and_int`, - `bfcol_28` AS `bool_and_bool`, - `bfcol_29` AS `bool_and_null` -FROM `bfcte_3` \ No newline at end of file + `rowindex`, + `bool_col`, + `int64_col`, + `int64_col` | `int64_col` AS `int_and_int`, + `bool_col` OR `bool_col` AS `bool_and_bool`, + IF(`bool_col` = TRUE, `bool_col`, NULL) AS `bool_and_null` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 d6a081cbbde..5f90436ead7 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,51 +1,17 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `bool_col` AS `bfcol_7`, - `int64_col` AS `bfcol_8`, - `int64_col` ^ `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - ( - `bfcol_7` AND NOT `bfcol_7` - ) OR ( - NOT `bfcol_7` AND `bfcol_7` - ) AS `bfcol_18` - FROM `bfcte_1` -), `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` AND NOT CAST(NULL AS BOOLEAN) - ) - OR ( - NOT `bfcol_15` AND CAST(NULL AS BOOLEAN) - ) AS `bfcol_29` - FROM `bfcte_2` -) SELECT - `bfcol_24` AS `rowindex`, - `bfcol_25` AS `bool_col`, - `bfcol_26` AS `int64_col`, - `bfcol_27` AS `int_and_int`, - `bfcol_28` AS `bool_and_bool`, - `bfcol_29` AS `bool_and_null` -FROM `bfcte_3` \ No newline at end of file + `rowindex`, + `bool_col`, + `int64_col`, + `int64_col` ^ `int64_col` AS `int_and_int`, + ( + `bool_col` AND NOT `bool_col` + ) OR ( + NOT `bool_col` AND `bool_col` + ) AS `bool_and_bool`, + ( + `bool_col` AND NOT CAST(NULL AS BOOLEAN) + ) + OR ( + NOT `bool_col` AND CAST(NULL AS BOOLEAN) + ) AS `bool_and_null` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 57af99a52bd..17ac7379815 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_eq_null_match/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_eq_null_match/out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COALESCE(CAST(`int64_col` AS STRING), '$NULL_SENTINEL$') = COALESCE(CAST(CAST(`bool_col` AS INT64) AS STRING), '$NULL_SENTINEL$') AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + COALESCE(CAST(`int64_col` AS STRING), '$NULL_SENTINEL$') = COALESCE(CAST(CAST(`bool_col` AS INT64) AS STRING), '$NULL_SENTINEL$') AS `int64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 a21e0089416..391311df073 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,67 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` = `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` = 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` IS NULL 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`, - `bfcol_25` = CAST(`bfcol_26` AS INT64) AS `bfcol_42` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - `bfcol_36` AS `bfcol_50`, - `bfcol_37` AS `bfcol_51`, - `bfcol_38` AS `bfcol_52`, - `bfcol_39` AS `bfcol_53`, - `bfcol_40` AS `bfcol_54`, - `bfcol_41` AS `bfcol_55`, - `bfcol_42` AS `bfcol_56`, - CAST(`bfcol_38` AS INT64) = `bfcol_37` AS `bfcol_57` - FROM `bfcte_4` -) SELECT - `bfcol_50` AS `rowindex`, - `bfcol_51` AS `int64_col`, - `bfcol_52` AS `bool_col`, - `bfcol_53` AS `int_eq_int`, - `bfcol_54` AS `int_eq_1`, - `bfcol_55` AS `int_eq_null`, - `bfcol_56` AS `int_eq_bool`, - `bfcol_57` AS `bool_eq_int` -FROM `bfcte_5` \ No newline at end of file + `rowindex`, + `int64_col`, + `bool_col`, + `int64_col` = `int64_col` AS `int_eq_int`, + `int64_col` = 1 AS `int_eq_1`, + `int64_col` IS NULL AS `int_eq_null`, + `int64_col` = CAST(`bool_col` AS INT64) AS `int_eq_bool`, + CAST(`bool_col` AS INT64) = `int64_col` AS `bool_eq_int` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 e99fe49c8e0..aaab4f4e391 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_ge_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_ge_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` >= `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` >= 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` >= CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) >= `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_ge_int`, - `bfcol_40` AS `int_ge_1`, - `bfcol_41` AS `int_ge_bool`, - `bfcol_42` AS `bool_ge_int` -FROM `bfcte_4` \ No newline at end of file + `rowindex`, + `int64_col`, + `bool_col`, + `int64_col` >= `int64_col` AS `int_ge_int`, + `int64_col` >= 1 AS `int_ge_1`, + `int64_col` >= CAST(`bool_col` AS INT64) AS `int_ge_bool`, + CAST(`bool_col` AS INT64) >= `int64_col` AS `bool_ge_int` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 4e5aba3d31e..f83c4e87e00 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_gt_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_gt_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` > `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` > 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` > CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) > `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_gt_int`, - `bfcol_40` AS `int_gt_1`, - `bfcol_41` AS `int_gt_bool`, - `bfcol_42` AS `bool_gt_int` -FROM `bfcte_4` \ No newline at end of file + `rowindex`, + `int64_col`, + `bool_col`, + `int64_col` > `int64_col` AS `int_gt_int`, + `int64_col` > 1 AS `int_gt_1`, + `int64_col` > CAST(`bool_col` AS INT64) AS `int_gt_bool`, + CAST(`bool_col` AS INT64) > `int64_col` AS `bool_gt_int` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 ec85f060dac..f5b60baee32 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,35 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COALESCE(`bool_col` IN (TRUE, FALSE), FALSE) AS `bfcol_3`, - COALESCE(`int64_col` IN (1, 2, 3), FALSE) AS `bfcol_4`, - `int64_col` IS NULL AS `bfcol_5`, - COALESCE(`int64_col` IN (1.0, 2.0, 3.0), FALSE) AS `bfcol_6`, - FALSE AS `bfcol_7`, - COALESCE(`int64_col` IN (2.5, 3), FALSE) AS `bfcol_8`, - FALSE AS `bfcol_9`, - FALSE AS `bfcol_10`, - COALESCE(`int64_col` IN (123456), FALSE) AS `bfcol_11`, - ( - `float64_col` IS NULL - ) OR `float64_col` IN (1, 2, 3) AS `bfcol_12` - FROM `bfcte_0` -) SELECT - `bfcol_3` AS `bools`, - `bfcol_4` AS `ints`, - `bfcol_5` AS `ints_w_null`, - `bfcol_6` AS `floats`, - `bfcol_7` AS `strings`, - `bfcol_8` AS `mixed`, - `bfcol_9` AS `empty`, - `bfcol_10` AS `empty_wo_match_nulls`, - `bfcol_11` AS `ints_wo_match_nulls`, - `bfcol_12` AS `float_in_ints` -FROM `bfcte_1` \ No newline at end of file + COALESCE(`bool_col` IN (TRUE, FALSE), FALSE) AS `bools`, + COALESCE(`int64_col` IN (1, 2, 3), FALSE) AS `ints`, + `int64_col` IS NULL AS `ints_w_null`, + COALESCE(`int64_col` IN (1.0, 2.0, 3.0), FALSE) AS `floats`, + FALSE AS `strings`, + COALESCE(`int64_col` IN (2.5, 3), FALSE) AS `mixed`, + FALSE AS `empty`, + FALSE AS `empty_wo_match_nulls`, + COALESCE(`int64_col` IN (123456), FALSE) AS `ints_wo_match_nulls`, + ( + `float64_col` IS NULL + ) OR `float64_col` IN (1, 2, 3) AS `float_in_ints` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 97a00d1c88b..09ce08d2f0b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_le_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_le_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` <= `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` <= 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` <= CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) <= `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_le_int`, - `bfcol_40` AS `int_le_1`, - `bfcol_41` AS `int_le_bool`, - `bfcol_42` AS `bool_le_int` -FROM `bfcte_4` \ No newline at end of file + `rowindex`, + `int64_col`, + `bool_col`, + `int64_col` <= `int64_col` AS `int_le_int`, + `int64_col` <= 1 AS `int_le_1`, + `int64_col` <= CAST(`bool_col` AS INT64) AS `int_le_bool`, + CAST(`bool_col` AS INT64) <= `int64_col` AS `bool_le_int` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 addebd3187c..bdeb6aee7e7 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_lt_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_lt_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` < `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` < 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` < CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) < `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_lt_int`, - `bfcol_40` AS `int_lt_1`, - `bfcol_41` AS `int_lt_bool`, - `bfcol_42` AS `bool_lt_int` -FROM `bfcte_4` \ No newline at end of file + `rowindex`, + `int64_col`, + `bool_col`, + `int64_col` < `int64_col` AS `int_lt_int`, + `int64_col` < 1 AS `int_lt_1`, + `int64_col` < CAST(`bool_col` AS INT64) AS `int_lt_bool`, + CAST(`bool_col` AS INT64) < `int64_col` AS `bool_lt_int` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_maximum_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_maximum_op/out.sql index bbef2127070..1d710112c02 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_maximum_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_maximum_op/out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - GREATEST(`int64_col`, `float64_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + GREATEST(`int64_col`, `float64_col`) AS `int64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_minimum_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_minimum_op/out.sql index 1f00f5892ef..9372f1b5200 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_minimum_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_minimum_op/out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LEAST(`int64_col`, `float64_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + LEAST(`int64_col`, `float64_col`) AS `int64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 1a1ff6e44d2..d362f9820c7 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,69 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` <> `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` <> 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - ( - `bfcol_15` - ) IS NOT NULL 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`, - `bfcol_25` <> CAST(`bfcol_26` AS INT64) AS `bfcol_42` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - `bfcol_36` AS `bfcol_50`, - `bfcol_37` AS `bfcol_51`, - `bfcol_38` AS `bfcol_52`, - `bfcol_39` AS `bfcol_53`, - `bfcol_40` AS `bfcol_54`, - `bfcol_41` AS `bfcol_55`, - `bfcol_42` AS `bfcol_56`, - CAST(`bfcol_38` AS INT64) <> `bfcol_37` AS `bfcol_57` - FROM `bfcte_4` -) SELECT - `bfcol_50` AS `rowindex`, - `bfcol_51` AS `int64_col`, - `bfcol_52` AS `bool_col`, - `bfcol_53` AS `int_ne_int`, - `bfcol_54` AS `int_ne_1`, - `bfcol_55` AS `int_ne_null`, - `bfcol_56` AS `int_ne_bool`, - `bfcol_57` AS `bool_ne_int` -FROM `bfcte_5` \ No newline at end of file + `rowindex`, + `int64_col`, + `bool_col`, + `int64_col` <> `int64_col` AS `int_ne_int`, + `int64_col` <> 1 AS `int_ne_1`, + ( + `int64_col` + ) IS NOT NULL AS `int_ne_null`, + `int64_col` <> CAST(`bool_col` AS INT64) AS `int_ne_bool`, + CAST(`bool_col` AS INT64) <> `int64_col` AS `bool_ne_int` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 2fef18eeb8a..f5a3b94c0bb 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_add_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_add_timedelta/out.sql @@ -1,60 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `timestamp_col` AS `bfcol_7`, - `date_col` AS `bfcol_8`, - TIMESTAMP_ADD(CAST(`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - TIMESTAMP_ADD(`bfcol_7`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - TIMESTAMP_ADD(CAST(`bfcol_16` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - TIMESTAMP_ADD(`bfcol_25`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_42` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - 172800000000 AS `bfcol_50` - FROM `bfcte_4` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `timestamp_col`, - `bfcol_38` AS `date_col`, - `bfcol_39` AS `date_add_timedelta`, - `bfcol_40` AS `timestamp_add_timedelta`, - `bfcol_41` AS `timedelta_add_date`, - `bfcol_42` AS `timedelta_add_timestamp`, - `bfcol_50` AS `timedelta_add_timedelta` -FROM `bfcte_5` \ No newline at end of file + `rowindex`, + `timestamp_col`, + `date_col`, + TIMESTAMP_ADD(CAST(`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `date_add_timedelta`, + TIMESTAMP_ADD(`timestamp_col`, INTERVAL 86400000000 MICROSECOND) AS `timestamp_add_timedelta`, + TIMESTAMP_ADD(CAST(`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_date`, + TIMESTAMP_ADD(`timestamp_col`, INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_timestamp`, + 172800000000 AS `timedelta_add_timedelta` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 b8f46ceafef..90c29c6c7df 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_date/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_date/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - DATE(`timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + DATE(`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_datetime_to_integer_label/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_datetime_to_integer_label/out.sql index 5260dd680a3..e29494a33df 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_datetime_to_integer_label/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_datetime_to_integer_label/out.sql @@ -1,38 +1,26 @@ -WITH `bfcte_0` AS ( - SELECT - `datetime_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(FLOOR( +SELECT + CAST(FLOOR( + IEEE_DIVIDE( + UNIX_MICROS(CAST(`datetime_col` AS TIMESTAMP)) - UNIX_MICROS(CAST(`timestamp_col` AS TIMESTAMP)), + 86400000000 + ) + ) AS INT64) AS `fixed_freq`, + CASE + WHEN UNIX_MICROS( + CAST(TIMESTAMP_TRUNC(`datetime_col`, WEEK(MONDAY)) + INTERVAL 6 DAY AS TIMESTAMP) + ) = UNIX_MICROS( + CAST(TIMESTAMP_TRUNC(`timestamp_col`, WEEK(MONDAY)) + INTERVAL 6 DAY AS TIMESTAMP) + ) + THEN 0 + ELSE CAST(FLOOR( IEEE_DIVIDE( - UNIX_MICROS(CAST(`datetime_col` AS TIMESTAMP)) - UNIX_MICROS(CAST(`timestamp_col` AS TIMESTAMP)), - 86400000000 - ) - ) AS INT64) AS `bfcol_2`, - CASE - WHEN UNIX_MICROS( - CAST(TIMESTAMP_TRUNC(`datetime_col`, WEEK(MONDAY)) + INTERVAL 6 DAY AS TIMESTAMP) - ) = UNIX_MICROS( - CAST(TIMESTAMP_TRUNC(`timestamp_col`, WEEK(MONDAY)) + INTERVAL 6 DAY AS TIMESTAMP) + UNIX_MICROS( + CAST(TIMESTAMP_TRUNC(`datetime_col`, WEEK(MONDAY)) + INTERVAL 6 DAY AS TIMESTAMP) + ) - UNIX_MICROS( + CAST(TIMESTAMP_TRUNC(`timestamp_col`, WEEK(MONDAY)) + INTERVAL 6 DAY AS TIMESTAMP) + ) - 1, + 604800000000 ) - THEN 0 - ELSE CAST(FLOOR( - IEEE_DIVIDE( - UNIX_MICROS( - CAST(TIMESTAMP_TRUNC(`datetime_col`, WEEK(MONDAY)) + INTERVAL 6 DAY AS TIMESTAMP) - ) - UNIX_MICROS( - CAST(TIMESTAMP_TRUNC(`timestamp_col`, WEEK(MONDAY)) + INTERVAL 6 DAY AS TIMESTAMP) - ) - 1, - 604800000000 - ) - ) AS INT64) + 1 - END AS `bfcol_3` - FROM `bfcte_0` -) -SELECT - `bfcol_2` AS `fixed_freq`, - `bfcol_3` AS `non_fixed_freq_weekly` -FROM `bfcte_1` \ No newline at end of file + ) AS INT64) + 1 + END AS `non_fixed_freq_weekly` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 52d80fd2a61..4f8f3637d57 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_day/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_day/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(DAY FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(DAY FROM `timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 0119bbb4e9f..4bd0cd4fd67 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_dayofweek/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_dayofweek/out.sql @@ -1,19 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `datetime_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(MOD(EXTRACT(DAYOFWEEK FROM `datetime_col`) + 5, 7) AS INT64) AS `bfcol_6`, - CAST(MOD(EXTRACT(DAYOFWEEK FROM `timestamp_col`) + 5, 7) AS INT64) AS `bfcol_7`, - CAST(MOD(EXTRACT(DAYOFWEEK FROM `date_col`) + 5, 7) AS INT64) AS `bfcol_8` - FROM `bfcte_0` -) SELECT - `bfcol_6` AS `datetime_col`, - `bfcol_7` AS `timestamp_col`, - `bfcol_8` AS `date_col` -FROM `bfcte_1` \ No newline at end of file + CAST(MOD(EXTRACT(DAYOFWEEK FROM `datetime_col`) + 5, 7) AS INT64) AS `datetime_col`, + CAST(MOD(EXTRACT(DAYOFWEEK FROM `timestamp_col`) + 5, 7) AS INT64) AS `timestamp_col`, + CAST(MOD(EXTRACT(DAYOFWEEK FROM `date_col`) + 5, 7) AS INT64) AS `date_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 521419757ab..d8b919586ed 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_dayofyear/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_dayofyear/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(DAYOFYEAR FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(DAYOFYEAR FROM `timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 fe76efb609b..a40a726b4ed 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_floor_dt/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_floor_dt/out.sql @@ -1,36 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `datetime_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIMESTAMP_TRUNC(`timestamp_col`, MICROSECOND) AS `bfcol_2`, - TIMESTAMP_TRUNC(`timestamp_col`, MILLISECOND) AS `bfcol_3`, - TIMESTAMP_TRUNC(`timestamp_col`, SECOND) AS `bfcol_4`, - TIMESTAMP_TRUNC(`timestamp_col`, MINUTE) AS `bfcol_5`, - TIMESTAMP_TRUNC(`timestamp_col`, HOUR) AS `bfcol_6`, - TIMESTAMP_TRUNC(`timestamp_col`, DAY) AS `bfcol_7`, - TIMESTAMP_TRUNC(`timestamp_col`, WEEK(MONDAY)) AS `bfcol_8`, - TIMESTAMP_TRUNC(`timestamp_col`, MONTH) AS `bfcol_9`, - TIMESTAMP_TRUNC(`timestamp_col`, QUARTER) AS `bfcol_10`, - TIMESTAMP_TRUNC(`timestamp_col`, YEAR) AS `bfcol_11`, - TIMESTAMP_TRUNC(`datetime_col`, MICROSECOND) AS `bfcol_12`, - TIMESTAMP_TRUNC(`datetime_col`, MICROSECOND) AS `bfcol_13` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `timestamp_col_us`, - `bfcol_3` AS `timestamp_col_ms`, - `bfcol_4` AS `timestamp_col_s`, - `bfcol_5` AS `timestamp_col_min`, - `bfcol_6` AS `timestamp_col_h`, - `bfcol_7` AS `timestamp_col_D`, - `bfcol_8` AS `timestamp_col_W`, - `bfcol_9` AS `timestamp_col_M`, - `bfcol_10` AS `timestamp_col_Q`, - `bfcol_11` AS `timestamp_col_Y`, - `bfcol_12` AS `datetime_col_q`, - `bfcol_13` AS `datetime_col_us` -FROM `bfcte_1` \ No newline at end of file + TIMESTAMP_TRUNC(`timestamp_col`, MICROSECOND) AS `timestamp_col_us`, + TIMESTAMP_TRUNC(`timestamp_col`, MILLISECOND) AS `timestamp_col_ms`, + TIMESTAMP_TRUNC(`timestamp_col`, SECOND) AS `timestamp_col_s`, + TIMESTAMP_TRUNC(`timestamp_col`, MINUTE) AS `timestamp_col_min`, + TIMESTAMP_TRUNC(`timestamp_col`, HOUR) AS `timestamp_col_h`, + TIMESTAMP_TRUNC(`timestamp_col`, DAY) AS `timestamp_col_D`, + TIMESTAMP_TRUNC(`timestamp_col`, WEEK(MONDAY)) AS `timestamp_col_W`, + TIMESTAMP_TRUNC(`timestamp_col`, MONTH) AS `timestamp_col_M`, + TIMESTAMP_TRUNC(`timestamp_col`, QUARTER) AS `timestamp_col_Q`, + TIMESTAMP_TRUNC(`timestamp_col`, YEAR) AS `timestamp_col_Y`, + TIMESTAMP_TRUNC(`datetime_col`, MICROSECOND) AS `datetime_col_q`, + TIMESTAMP_TRUNC(`datetime_col`, MICROSECOND) AS `datetime_col_us` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 5fc6621a7ca..7b3189f3a67 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_hour/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_hour/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(HOUR FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(HOUR FROM `timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_fixed/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_fixed/out.sql index 8a759e85f98..b4e23ed8772 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_fixed/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_fixed/out.sql @@ -1,16 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(TIMESTAMP_MICROS( - CAST(CAST(`rowindex` AS BIGNUMERIC) * 86400000000 + CAST(UNIX_MICROS(CAST(`timestamp_col` AS TIMESTAMP)) AS BIGNUMERIC) AS INT64) - ) AS TIMESTAMP) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `fixed_freq` -FROM `bfcte_1` \ No newline at end of file + CAST(TIMESTAMP_MICROS( + CAST(CAST(`rowindex` AS BIGNUMERIC) * 86400000000 + CAST(UNIX_MICROS(CAST(`timestamp_col` AS TIMESTAMP)) AS BIGNUMERIC) AS INT64) + ) AS TIMESTAMP) AS `fixed_freq` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_month/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_month/out.sql index a9e64fead63..5d20e2c1d16 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_month/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_month/out.sql @@ -1,50 +1,39 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(TIMESTAMP( - DATETIME( - CASE - WHEN MOD( - `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 12 + EXTRACT(MONTH FROM `timestamp_col`) - 1, - 12 - ) + 1 = 12 - THEN CAST(FLOOR( - IEEE_DIVIDE( - `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 12 + EXTRACT(MONTH FROM `timestamp_col`) - 1, - 12 - ) - ) AS INT64) + 1 - ELSE CAST(FLOOR( - IEEE_DIVIDE( - `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 12 + EXTRACT(MONTH FROM `timestamp_col`) - 1, - 12 - ) - ) AS INT64) - END, - CASE - WHEN MOD( +SELECT + CAST(TIMESTAMP( + DATETIME( + CASE + WHEN MOD( + `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 12 + EXTRACT(MONTH FROM `timestamp_col`) - 1, + 12 + ) + 1 = 12 + THEN CAST(FLOOR( + IEEE_DIVIDE( `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 12 + EXTRACT(MONTH FROM `timestamp_col`) - 1, 12 - ) + 1 = 12 - THEN 1 - ELSE MOD( + ) + ) AS INT64) + 1 + ELSE CAST(FLOOR( + IEEE_DIVIDE( `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 12 + EXTRACT(MONTH FROM `timestamp_col`) - 1, 12 - ) + 1 + 1 - END, - 1, - 0, - 0, - 0 - ) - ) - INTERVAL 1 DAY AS TIMESTAMP) AS `bfcol_2` - FROM `bfcte_0` -) -SELECT - `bfcol_2` AS `non_fixed_freq_monthly` -FROM `bfcte_1` \ No newline at end of file + ) + ) AS INT64) + END, + CASE + WHEN MOD( + `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 12 + EXTRACT(MONTH FROM `timestamp_col`) - 1, + 12 + ) + 1 = 12 + THEN 1 + ELSE MOD( + `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 12 + EXTRACT(MONTH FROM `timestamp_col`) - 1, + 12 + ) + 1 + 1 + END, + 1, + 0, + 0, + 0 + ) + ) - INTERVAL 1 DAY AS TIMESTAMP) AS `non_fixed_freq_monthly` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_quarter/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_quarter/out.sql index 58064855a9e..ba2311dee6f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_quarter/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_quarter/out.sql @@ -1,54 +1,43 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(DATETIME( - CASE - WHEN ( - MOD( - `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 4 + EXTRACT(QUARTER FROM `timestamp_col`) - 1, - 4 - ) + 1 - ) * 3 = 12 - THEN CAST(FLOOR( - IEEE_DIVIDE( - `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 4 + EXTRACT(QUARTER FROM `timestamp_col`) - 1, - 4 - ) - ) AS INT64) + 1 - ELSE CAST(FLOOR( - IEEE_DIVIDE( - `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 4 + EXTRACT(QUARTER FROM `timestamp_col`) - 1, - 4 - ) - ) AS INT64) - END, - CASE - WHEN ( - MOD( - `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 4 + EXTRACT(QUARTER FROM `timestamp_col`) - 1, - 4 - ) + 1 - ) * 3 = 12 - THEN 1 - ELSE ( - MOD( - `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 4 + EXTRACT(QUARTER FROM `timestamp_col`) - 1, - 4 - ) + 1 - ) * 3 + 1 - END, - 1, - 0, - 0, - 0 - ) - INTERVAL 1 DAY AS TIMESTAMP) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `non_fixed_freq` -FROM `bfcte_1` \ No newline at end of file + CAST(DATETIME( + CASE + WHEN ( + MOD( + `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 4 + EXTRACT(QUARTER FROM `timestamp_col`) - 1, + 4 + ) + 1 + ) * 3 = 12 + THEN CAST(FLOOR( + IEEE_DIVIDE( + `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 4 + EXTRACT(QUARTER FROM `timestamp_col`) - 1, + 4 + ) + ) AS INT64) + 1 + ELSE CAST(FLOOR( + IEEE_DIVIDE( + `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 4 + EXTRACT(QUARTER FROM `timestamp_col`) - 1, + 4 + ) + ) AS INT64) + END, + CASE + WHEN ( + MOD( + `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 4 + EXTRACT(QUARTER FROM `timestamp_col`) - 1, + 4 + ) + 1 + ) * 3 = 12 + THEN 1 + ELSE ( + MOD( + `rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) * 4 + EXTRACT(QUARTER FROM `timestamp_col`) - 1, + 4 + ) + 1 + ) * 3 + 1 + END, + 1, + 0, + 0, + 0 + ) - INTERVAL 1 DAY AS TIMESTAMP) AS `non_fixed_freq` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_week/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_week/out.sql index 142f8561f48..26960cbc290 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_week/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_week/out.sql @@ -1,18 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(TIMESTAMP_MICROS( - CAST(CAST(`rowindex` AS BIGNUMERIC) * 604800000000 + CAST(UNIX_MICROS( - TIMESTAMP_TRUNC(CAST(`timestamp_col` AS TIMESTAMP), WEEK(MONDAY)) + INTERVAL 6 DAY - ) AS BIGNUMERIC) AS INT64) - ) AS TIMESTAMP) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `non_fixed_freq_weekly` -FROM `bfcte_1` \ No newline at end of file + CAST(TIMESTAMP_MICROS( + CAST(CAST(`rowindex` AS BIGNUMERIC) * 604800000000 + CAST(UNIX_MICROS( + TIMESTAMP_TRUNC(CAST(`timestamp_col` AS TIMESTAMP), WEEK(MONDAY)) + INTERVAL 6 DAY + ) AS BIGNUMERIC) AS INT64) + ) AS TIMESTAMP) AS `non_fixed_freq_weekly` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_year/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_year/out.sql index ab77a9d1906..e4bed8e69fc 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_year/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_year/out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(TIMESTAMP(DATETIME(`rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) + 1, 1, 1, 0, 0, 0)) - INTERVAL 1 DAY AS TIMESTAMP) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `non_fixed_freq_yearly` -FROM `bfcte_1` \ No newline at end of file + CAST(TIMESTAMP(DATETIME(`rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) + 1, 1, 1, 0, 0, 0)) - INTERVAL 1 DAY AS TIMESTAMP) AS `non_fixed_freq_yearly` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 9422844b34f..2277875a21c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_day/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_day/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(MOD(EXTRACT(DAYOFWEEK FROM `timestamp_col`) + 5, 7) AS INT64) + 1 AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(MOD(EXTRACT(DAYOFWEEK FROM `timestamp_col`) + 5, 7) AS INT64) + 1 AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 4db49fb10fa..0c7ec5a8717 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_week/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_week/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(ISOWEEK FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(ISOWEEK FROM `timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 8d49933202c..6e0b7f264a2 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_year/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_iso_year/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(ISOYEAR FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(ISOYEAR FROM `timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 e089a77af51..ed1842262cb 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_minute/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_minute/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(MINUTE FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(MINUTE FROM `timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 53d135903ba..1f122f03929 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_month/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_month/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(MONTH FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(MONTH FROM `timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 b542dfea72a..0fc59582f78 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_normalize/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_normalize/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIMESTAMP_TRUNC(`timestamp_col`, DAY) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + TIMESTAMP_TRUNC(`timestamp_col`, DAY) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 4a232cb5a30..6738427f768 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_quarter/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_quarter/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(QUARTER FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(QUARTER FROM `timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 e86d830b737..740eb3234b3 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_second/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_second/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(SECOND FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(SECOND FROM `timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 1d8f62f948a..ac523e0da5a 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,22 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `datetime_col`, - `time_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FORMAT_DATE('%Y-%m-%d', `date_col`) AS `bfcol_8`, - FORMAT_DATETIME('%Y-%m-%d', `datetime_col`) AS `bfcol_9`, - FORMAT_TIME('%Y-%m-%d', `time_col`) AS `bfcol_10`, - FORMAT_TIMESTAMP('%Y-%m-%d', `timestamp_col`) AS `bfcol_11` - FROM `bfcte_0` -) SELECT - `bfcol_8` AS `date_col`, - `bfcol_9` AS `datetime_col`, - `bfcol_10` AS `time_col`, - `bfcol_11` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + FORMAT_DATE('%Y-%m-%d', `date_col`) AS `date_col`, + FORMAT_DATETIME('%Y-%m-%d', `datetime_col`) AS `datetime_col`, + FORMAT_TIME('%Y-%m-%d', `time_col`) AS `time_col`, + FORMAT_TIMESTAMP('%Y-%m-%d', `timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 ebcffd67f61..8c53679af1d 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,11 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `duration_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_8`, - `timestamp_col` AS `bfcol_9`, - `date_col` AS `bfcol_10`, - `duration_col` AS `bfcol_11` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_11` AS `bfcol_18`, - `bfcol_10` AS `bfcol_19`, - TIMESTAMP_SUB(CAST(`bfcol_10` AS DATETIME), INTERVAL `bfcol_11` MICROSECOND) AS `bfcol_20` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_19` AS `bfcol_29`, - `bfcol_20` AS `bfcol_30`, - TIMESTAMP_SUB(`bfcol_17`, INTERVAL `bfcol_18` MICROSECOND) AS `bfcol_31` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - `bfcol_30` AS `bfcol_42`, - `bfcol_31` AS `bfcol_43`, - TIMESTAMP_DIFF(CAST(`bfcol_29` AS DATETIME), CAST(`bfcol_29` AS DATETIME), MICROSECOND) AS `bfcol_44` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - `bfcol_38` AS `bfcol_52`, - `bfcol_39` AS `bfcol_53`, - `bfcol_40` AS `bfcol_54`, - `bfcol_41` AS `bfcol_55`, - `bfcol_42` AS `bfcol_56`, - `bfcol_43` AS `bfcol_57`, - `bfcol_44` AS `bfcol_58`, - TIMESTAMP_DIFF(`bfcol_39`, `bfcol_39`, MICROSECOND) AS `bfcol_59` - FROM `bfcte_4` -), `bfcte_6` AS ( - SELECT - *, - `bfcol_52` AS `bfcol_68`, - `bfcol_53` AS `bfcol_69`, - `bfcol_54` AS `bfcol_70`, - `bfcol_55` AS `bfcol_71`, - `bfcol_56` AS `bfcol_72`, - `bfcol_57` AS `bfcol_73`, - `bfcol_58` AS `bfcol_74`, - `bfcol_59` AS `bfcol_75`, - `bfcol_54` - `bfcol_54` AS `bfcol_76` - FROM `bfcte_5` -) SELECT - `bfcol_68` AS `rowindex`, - `bfcol_69` AS `timestamp_col`, - `bfcol_70` AS `duration_col`, - `bfcol_71` AS `date_col`, - `bfcol_72` AS `date_sub_timedelta`, - `bfcol_73` AS `timestamp_sub_timedelta`, - `bfcol_74` AS `timestamp_sub_date`, - `bfcol_75` AS `date_sub_timestamp`, - `bfcol_76` AS `timedelta_sub_timedelta` -FROM `bfcte_6` \ No newline at end of file + `rowindex`, + `timestamp_col`, + `duration_col`, + `date_col`, + TIMESTAMP_SUB(CAST(`date_col` AS DATETIME), INTERVAL `duration_col` MICROSECOND) AS `date_sub_timedelta`, + TIMESTAMP_SUB(`timestamp_col`, INTERVAL `duration_col` MICROSECOND) AS `timestamp_sub_timedelta`, + TIMESTAMP_DIFF(CAST(`date_col` AS DATETIME), CAST(`date_col` AS DATETIME), MICROSECOND) AS `timestamp_sub_date`, + TIMESTAMP_DIFF(`timestamp_col`, `timestamp_col`, MICROSECOND) AS `date_sub_timestamp`, + `duration_col` - `duration_col` AS `timedelta_sub_timedelta` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 5a8ab600bac..52125d4b831 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_time/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_time/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIME(`timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + TIME(`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 a8d40a84867..430ee6ef8be 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,19 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col` * 0.001) AS INT64)) AS DATETIME) AS `bfcol_6`, - SAFE_CAST(`string_col` AS DATETIME) AS `bfcol_7`, - CAST(TIMESTAMP_MICROS(CAST(TRUNC(`float64_col` * 0.001) AS INT64)) AS DATETIME) AS `bfcol_8` - FROM `bfcte_0` -) SELECT - `bfcol_6` AS `int64_col`, - `bfcol_7` AS `string_col`, - `bfcol_8` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col` * 0.001) AS INT64)) AS DATETIME) AS `int64_col`, + SAFE_CAST(`string_col` AS DATETIME), + CAST(TIMESTAMP_MICROS(CAST(TRUNC(`float64_col` * 0.001) AS INT64)) AS DATETIME) AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 a5f9ee1112b..84c8660c885 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,24 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col` * 0.001) AS INT64)) AS TIMESTAMP) AS `bfcol_2`, - CAST(TIMESTAMP_MICROS(CAST(TRUNC(`float64_col` * 0.001) AS INT64)) AS TIMESTAMP) AS `bfcol_3`, - CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col` * 1000000) AS INT64)) AS TIMESTAMP) AS `bfcol_4`, - CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col` * 1000) AS INT64)) AS TIMESTAMP) AS `bfcol_5`, - CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col`) AS INT64)) AS TIMESTAMP) AS `bfcol_6`, - CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col` * 0.001) AS INT64)) AS TIMESTAMP) AS `bfcol_7` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int64_col`, - `bfcol_3` AS `float64_col`, - `bfcol_4` AS `int64_col_s`, - `bfcol_5` AS `int64_col_ms`, - `bfcol_6` AS `int64_col_us`, - `bfcol_7` AS `int64_col_ns` -FROM `bfcte_1` \ No newline at end of file + CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col` * 0.001) AS INT64)) AS TIMESTAMP) AS `int64_col`, + CAST(TIMESTAMP_MICROS(CAST(TRUNC(`float64_col` * 0.001) AS INT64)) AS TIMESTAMP) AS `float64_col`, + CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col` * 1000000) AS INT64)) AS TIMESTAMP) AS `int64_col_s`, + CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col` * 1000) AS INT64)) AS TIMESTAMP) AS `int64_col_ms`, + CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col`) AS INT64)) AS TIMESTAMP) AS `int64_col_us`, + CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col` * 0.001) AS INT64)) AS TIMESTAMP) AS `int64_col_ns` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 e6515017f25..55d199f02d4 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_MICROS(`timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + UNIX_MICROS(`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 caec5effe0a..39c4bf42154 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_MILLIS(`timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + UNIX_MILLIS(`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 6dc0ea2a02a..a4da6182c13 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_seconds/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_unix_seconds/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_SECONDS(`timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + UNIX_SECONDS(`timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 1ceb674137c..8e60460ce69 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_year/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_year/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(YEAR FROM `timestamp_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(YEAR FROM `timestamp_col`) AS `timestamp_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 1f90accd0bb..1a347f5a9af 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_bool/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_bool/out.sql @@ -1,18 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bool_col` AS `bfcol_2`, - `float64_col` <> 0 AS `bfcol_3`, - `float64_col` <> 0 AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `bool_col`, - `bfcol_3` AS `float64_col`, - `bfcol_4` AS `float64_w_safe` -FROM `bfcte_1` \ No newline at end of file + `bool_col`, + `float64_col` <> 0 AS `float64_col`, + `float64_col` <> 0 AS `float64_w_safe` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 32c8da56fa4..840436d1515 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_float/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_float/out.sql @@ -1,17 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(CAST(`bool_col` AS INT64) AS FLOAT64) AS `bfcol_1`, - CAST('1.34235e4' AS FLOAT64) AS `bfcol_2`, - SAFE_CAST(SAFE_CAST(`bool_col` AS INT64) AS FLOAT64) AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `bool_col`, - `bfcol_2` AS `str_const`, - `bfcol_3` AS `bool_w_safe` -FROM `bfcte_1` \ No newline at end of file + CAST(CAST(`bool_col` AS INT64) AS FLOAT64), + CAST('1.34235e4' AS FLOAT64) AS `str_const`, + SAFE_CAST(SAFE_CAST(`bool_col` AS INT64) AS FLOAT64) AS `bool_w_safe` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 d1577c0664d..882c7bc6f02 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - INT64(`json_col`) AS `bfcol_1`, - FLOAT64(`json_col`) AS `bfcol_2`, - BOOL(`json_col`) AS `bfcol_3`, - STRING(`json_col`) AS `bfcol_4`, - SAFE.INT64(`json_col`) AS `bfcol_5` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col`, - `bfcol_2` AS `float64_col`, - `bfcol_3` AS `bool_col`, - `bfcol_4` AS `string_col`, - `bfcol_5` AS `int64_w_safe` -FROM `bfcte_1` \ No newline at end of file + INT64(`json_col`) AS `int64_col`, + FLOAT64(`json_col`) AS `float64_col`, + BOOL(`json_col`) AS `bool_col`, + STRING(`json_col`) AS `string_col`, + SAFE.INT64(`json_col`) AS `int64_w_safe` +FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ 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 e0fe2af9a9d..37e544db6b5 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_int/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_int/out.sql @@ -1,33 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `datetime_col`, - `float64_col`, - `numeric_col`, - `time_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_MICROS(CAST(`datetime_col` AS TIMESTAMP)) AS `bfcol_5`, - UNIX_MICROS(SAFE_CAST(`datetime_col` AS TIMESTAMP)) AS `bfcol_6`, - TIME_DIFF(CAST(`time_col` AS TIME), '00:00:00', MICROSECOND) AS `bfcol_7`, - TIME_DIFF(SAFE_CAST(`time_col` AS TIME), '00:00:00', MICROSECOND) AS `bfcol_8`, - UNIX_MICROS(`timestamp_col`) AS `bfcol_9`, - CAST(TRUNC(`numeric_col`) AS INT64) AS `bfcol_10`, - CAST(TRUNC(`float64_col`) AS INT64) AS `bfcol_11`, - SAFE_CAST(TRUNC(`float64_col`) AS INT64) AS `bfcol_12`, - CAST('100' AS INT64) AS `bfcol_13` - FROM `bfcte_0` -) SELECT - `bfcol_5` AS `datetime_col`, - `bfcol_6` AS `datetime_w_safe`, - `bfcol_7` AS `time_col`, - `bfcol_8` AS `time_w_safe`, - `bfcol_9` AS `timestamp_col`, - `bfcol_10` AS `numeric_col`, - `bfcol_11` AS `float64_col`, - `bfcol_12` AS `float64_w_safe`, - `bfcol_13` AS `str_const` -FROM `bfcte_1` \ No newline at end of file + UNIX_MICROS(CAST(`datetime_col` AS TIMESTAMP)) AS `datetime_col`, + UNIX_MICROS(SAFE_CAST(`datetime_col` AS TIMESTAMP)) AS `datetime_w_safe`, + TIME_DIFF(CAST(`time_col` AS TIME), '00:00:00', MICROSECOND) AS `time_col`, + TIME_DIFF(SAFE_CAST(`time_col` AS TIME), '00:00:00', MICROSECOND) AS `time_w_safe`, + UNIX_MICROS(`timestamp_col`) AS `timestamp_col`, + CAST(TRUNC(`numeric_col`) AS INT64) AS `numeric_col`, + CAST(TRUNC(`float64_col`) AS INT64) AS `float64_col`, + SAFE_CAST(TRUNC(`float64_col`) AS INT64) AS `float64_w_safe`, + CAST('100' AS INT64) AS `str_const` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 4ffaf7256a1..f3293d2f87f 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,8 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - PARSE_JSON(CAST(`int64_col` AS STRING)) AS `bfcol_4`, - PARSE_JSON(CAST(`float64_col` AS STRING)) AS `bfcol_5`, - PARSE_JSON(CAST(`bool_col` AS STRING)) AS `bfcol_6`, - PARSE_JSON(`string_col`) AS `bfcol_7`, - PARSE_JSON(CAST(`bool_col` AS STRING)) AS `bfcol_8`, - SAFE.PARSE_JSON(`string_col`) AS `bfcol_9` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `int64_col`, - `bfcol_5` AS `float64_col`, - `bfcol_6` AS `bool_col`, - `bfcol_7` AS `string_col`, - `bfcol_8` AS `bool_w_safe`, - `bfcol_9` AS `string_w_safe` -FROM `bfcte_1` \ No newline at end of file + PARSE_JSON(CAST(`int64_col` AS STRING)) AS `int64_col`, + PARSE_JSON(CAST(`float64_col` AS STRING)) AS `float64_col`, + PARSE_JSON(CAST(`bool_col` AS STRING)) AS `bool_col`, + PARSE_JSON(`string_col`) AS `string_col`, + PARSE_JSON(CAST(`bool_col` AS STRING)) AS `bool_w_safe`, + SAFE.PARSE_JSON(`string_col`) AS `string_w_safe` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 da6eb6ce187..aabdb6a40d1 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,5 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(`int64_col` AS STRING) AS `bfcol_2`, - INITCAP(CAST(`bool_col` AS STRING)) AS `bfcol_3`, - INITCAP(SAFE_CAST(`bool_col` AS STRING)) AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int64_col`, - `bfcol_3` AS `bool_col`, - `bfcol_4` AS `bool_w_safe` -FROM `bfcte_1` \ No newline at end of file + CAST(`int64_col` AS STRING), + INITCAP(CAST(`bool_col` AS STRING)) AS `bool_col`, + INITCAP(SAFE_CAST(`bool_col` AS STRING)) AS `bool_w_safe` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 6523d8376cc..36d8ec09630 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_time_like/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_time_like/out.sql @@ -1,19 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(TIMESTAMP_MICROS(`int64_col`) AS DATETIME) AS `bfcol_1`, - CAST(TIMESTAMP_MICROS(`int64_col`) AS TIME) AS `bfcol_2`, - CAST(TIMESTAMP_MICROS(`int64_col`) AS TIMESTAMP) AS `bfcol_3`, - SAFE_CAST(TIMESTAMP_MICROS(`int64_col`) AS TIME) AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_to_datetime`, - `bfcol_2` AS `int64_to_time`, - `bfcol_3` AS `int64_to_timestamp`, - `bfcol_4` AS `int64_to_time_safe` -FROM `bfcte_1` \ No newline at end of file + CAST(TIMESTAMP_MICROS(`int64_col`) AS DATETIME) AS `int64_to_datetime`, + CAST(TIMESTAMP_MICROS(`int64_col`) AS TIME) AS `int64_to_time`, + CAST(TIMESTAMP_MICROS(`int64_col`) AS TIMESTAMP) AS `int64_to_timestamp`, + SAFE_CAST(TIMESTAMP_MICROS(`int64_col`) AS TIME) AS `int64_to_time_safe` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_binary_remote_function_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_binary_remote_function_op/out.sql index 7272a3a5be1..93dc413d80c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_binary_remote_function_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_binary_remote_function_op/out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `my_project`.`my_dataset`.`my_routine`(`int64_col`, `float64_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + `my_project`.`my_dataset`.`my_routine`(`int64_col`, `float64_col`) AS `int64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_case_when_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_case_when_op/out.sql index 08a489e2401..9bd61690932 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_case_when_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_case_when_op/out.sql @@ -1,29 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col`, - `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `bool_col` THEN `int64_col` END AS `bfcol_4`, - CASE WHEN `bool_col` THEN `int64_col` WHEN `bool_col` THEN `int64_too` END AS `bfcol_5`, - CASE WHEN `bool_col` THEN `bool_col` WHEN `bool_col` THEN `bool_col` END AS `bfcol_6`, - CASE - WHEN `bool_col` - THEN `int64_col` - WHEN `bool_col` - THEN CAST(`bool_col` AS INT64) - WHEN `bool_col` - THEN `float64_col` - END AS `bfcol_7` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `single_case`, - `bfcol_5` AS `double_case`, - `bfcol_6` AS `bool_types_case`, - `bfcol_7` AS `mixed_types_cast` -FROM `bfcte_1` \ No newline at end of file + CASE WHEN `bool_col` THEN `int64_col` END AS `single_case`, + CASE WHEN `bool_col` THEN `int64_col` WHEN `bool_col` THEN `int64_too` END AS `double_case`, + CASE WHEN `bool_col` THEN `bool_col` WHEN `bool_col` THEN `bool_col` END AS `bool_types_case`, + CASE + WHEN `bool_col` + THEN `int64_col` + WHEN `bool_col` + THEN CAST(`bool_col` AS INT64) + WHEN `bool_col` + THEN `float64_col` + END AS `mixed_types_cast` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_clip/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_clip/out.sql index b1625931478..9106faf6c8b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_clip/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_clip/out.sql @@ -1,15 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `int64_too`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - GREATEST(LEAST(`rowindex`, `int64_too`), `int64_col`) AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_3` AS `result_col` -FROM `bfcte_1` \ No newline at end of file + GREATEST(LEAST(`rowindex`, `int64_too`), `int64_col`) AS `result_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_coalesce/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_coalesce/out.sql index 451de48b642..96fa1244029 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_coalesce/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_coalesce/out.sql @@ -1,16 +1,4 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `int64_col` AS `bfcol_2`, - COALESCE(`int64_too`, `int64_col`) AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int64_col`, - `bfcol_3` AS `int64_too` -FROM `bfcte_1` \ No newline at end of file + `int64_col`, + COALESCE(`int64_too`, `int64_col`) AS `int64_too` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_fillna/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_fillna/out.sql index 07f2877e740..52594023e9d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_fillna/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_fillna/out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COALESCE(`int64_col`, `float64_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + COALESCE(`int64_col`, `float64_col`) AS `int64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 19fce600910..52d0758ae4f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_hash/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_hash/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FARM_FINGERPRINT(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + FARM_FINGERPRINT(`string_col`) AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_invert/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_invert/out.sql index 1bd2eb7426c..f16f4232de3 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_invert/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_invert/out.sql @@ -1,25 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `bytes_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ~( - `int64_col` - ) AS `bfcol_6`, - ~( - `bytes_col` - ) AS `bfcol_7`, - NOT ( - `bool_col` - ) AS `bfcol_8` - FROM `bfcte_0` -) SELECT - `bfcol_6` AS `int64_col`, - `bfcol_7` AS `bytes_col`, - `bfcol_8` AS `bool_col` -FROM `bfcte_1` \ No newline at end of file + ~( + `int64_col` + ) AS `int64_col`, + ~( + `bytes_col` + ) AS `bytes_col`, + NOT ( + `bool_col` + ) AS `bool_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 0a549bdd442..40c799a4e4d 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,5 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `float64_col` IS NULL AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + ( + `float64_col` + ) IS NULL AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 49eada22301..c217a632f38 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,19 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `string_col` = 'value1' - THEN 'mapped1' - WHEN `string_col` IS NULL - THEN 'UNKNOWN' - ELSE `string_col` - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `string_col` = 'value1' + THEN 'mapped1' + WHEN `string_col` IS NULL + THEN 'UNKNOWN' + ELSE `string_col` + END AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_nary_remote_function_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_nary_remote_function_op/out.sql index a6641b13db6..c330d2b0e68 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_nary_remote_function_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_nary_remote_function_op/out.sql @@ -1,15 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `my_project`.`my_dataset`.`my_routine`(`int64_col`, `float64_col`, `string_col`) AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_3` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + `my_project`.`my_dataset`.`my_routine`(`int64_col`, `float64_col`, `string_col`) AS `int64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 bf3425fe6de..1865e24c4cf 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_notnull/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_notnull/out.sql @@ -1,13 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - NOT `float64_col` IS NULL AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + NOT ( + `float64_col` + ) IS NULL AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_remote_function_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_remote_function_op/out.sql index dee0d35355b..4f83586edf1 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_remote_function_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_remote_function_op/out.sql @@ -1,19 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `my_project`.`my_dataset`.`my_routine`(`int64_col`) AS `bfcol_1`, - IF( - `int64_col` IS NULL, - `int64_col`, - `my_project`.`my_dataset`.`my_routine`(`int64_col`) - ) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `apply_on_null_true`, - `bfcol_2` AS `apply_on_null_false` -FROM `bfcte_1` \ No newline at end of file + `my_project`.`my_dataset`.`my_routine`(`int64_col`) AS `apply_on_null_true`, + IF( + `int64_col` IS NULL, + `int64_col`, + `my_project`.`my_dataset`.`my_routine`(`int64_col`) + ) AS `apply_on_null_false` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_row_key/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_row_key/out.sql index 13b27c2e146..d0646c18c18 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_row_key/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_row_key/out.sql @@ -1,70 +1,46 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `bytes_col`, - `date_col`, - `datetime_col`, - `duration_col`, - `float64_col`, - `geography_col`, - `int64_col`, - `int64_too`, - `numeric_col`, - `rowindex`, - `rowindex_2`, - `string_col`, - `time_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CONCAT( - CAST(FARM_FINGERPRINT( - CONCAT( - CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`bool_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`bytes_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`date_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`datetime_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(ST_ASTEXT(`geography_col`), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`int64_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`int64_too` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`numeric_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`float64_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex_2` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(`string_col`, ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`time_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`timestamp_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`duration_col` AS STRING), ''), '\\', '\\\\')) - ) - ) AS STRING), - CAST(FARM_FINGERPRINT( - CONCAT( - CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`bool_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`bytes_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`date_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`datetime_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(ST_ASTEXT(`geography_col`), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`int64_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`int64_too` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`numeric_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`float64_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex_2` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(`string_col`, ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`time_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`timestamp_col` AS STRING), ''), '\\', '\\\\')), - CONCAT('\\', REPLACE(COALESCE(CAST(`duration_col` AS STRING), ''), '\\', '\\\\')), - '_' - ) - ) AS STRING), - CAST(RAND() AS STRING) - ) AS `bfcol_31` - FROM `bfcte_0` -) SELECT - `bfcol_31` AS `row_key` -FROM `bfcte_1` \ No newline at end of file + CONCAT( + CAST(FARM_FINGERPRINT( + CONCAT( + CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`bool_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`bytes_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`date_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`datetime_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(ST_ASTEXT(`geography_col`), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`int64_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`int64_too` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`numeric_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`float64_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex_2` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(`string_col`, ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`time_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`timestamp_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`duration_col` AS STRING), ''), '\\', '\\\\')) + ) + ) AS STRING), + CAST(FARM_FINGERPRINT( + CONCAT( + CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`bool_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`bytes_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`date_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`datetime_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(ST_ASTEXT(`geography_col`), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`int64_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`int64_too` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`numeric_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`float64_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`rowindex_2` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(`string_col`, ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`time_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`timestamp_col` AS STRING), ''), '\\', '\\\\')), + CONCAT('\\', REPLACE(COALESCE(CAST(`duration_col` AS STRING), ''), '\\', '\\\\')), + '_' + ) + ) AS STRING), + CAST(RAND() AS STRING) + ) AS `row_key` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_sql_scalar_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_sql_scalar_op/out.sql index 611cbf4e7e8..64a6e907028 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_sql_scalar_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_sql_scalar_op/out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `bytes_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(`bool_col` AS INT64) + BYTE_LENGTH(`bytes_col`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `bool_col` -FROM `bfcte_1` \ No newline at end of file + CAST(`bool_col` AS INT64) + BYTE_LENGTH(`bytes_col`) AS `bool_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_where/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_where/out.sql index 872c7943335..651f24ffc7f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_where/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_where/out.sql @@ -1,15 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - IF(`bool_col`, `int64_col`, `float64_col`) AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_3` AS `result_col` -FROM `bfcte_1` \ No newline at end of file + IF(`bool_col`, `int64_col`, `float64_col`) AS `result_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 105b5f1665d..d6de4f45769 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_area/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_area/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_AREA(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + ST_AREA(`geography_col`) AS `geography_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 c338baeb5f1..39eccc28459 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_astext/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_astext/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_ASTEXT(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + ST_ASTEXT(`geography_col`) AS `geography_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 2d4ac2e9609..4ae9288c59f 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_BOUNDARY(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + ST_BOUNDARY(`geography_col`) AS `geography_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 84b3ab1600e..d9273e11e89 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_BUFFER(`geography_col`, 1.0, 8.0, FALSE) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + ST_BUFFER(`geography_col`, 1.0, 8.0, FALSE) AS `geography_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 733f1e9495b..375caae748f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_centroid/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_centroid/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_CENTROID(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + ST_CENTROID(`geography_col`) AS `geography_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 11b3b7f6917..36e4daa6879 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_CONVEXHULL(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + ST_CONVEXHULL(`geography_col`) AS `geography_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_difference/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_difference/out.sql index 4e18216ddac..81e1cd09953 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_difference/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_difference/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_DIFFERENCE(`geography_col`, `geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + ST_DIFFERENCE(`geography_col`, `geography_col`) AS `geography_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_distance/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_distance/out.sql index e98a581de72..24eab471096 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_distance/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_distance/out.sql @@ -1,15 +1,4 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_DISTANCE(`geography_col`, `geography_col`, TRUE) AS `bfcol_1`, - ST_DISTANCE(`geography_col`, `geography_col`, FALSE) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `spheroid`, - `bfcol_2` AS `no_spheroid` -FROM `bfcte_1` \ No newline at end of file + ST_DISTANCE(`geography_col`, `geography_col`, TRUE) AS `spheroid`, + ST_DISTANCE(`geography_col`, `geography_col`, FALSE) AS `no_spheroid` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 1bbb1143493..2554b1a017e 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SAFE.ST_GEOGFROMTEXT(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + SAFE.ST_GEOGFROMTEXT(`string_col`) AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogpoint/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogpoint/out.sql index f6c953d161a..eddd11cc3d0 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogpoint/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogpoint/out.sql @@ -1,14 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex`, - `rowindex_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_GEOGPOINT(`rowindex`, `rowindex_2`) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `rowindex` -FROM `bfcte_1` \ No newline at end of file + ST_GEOGPOINT(`rowindex`, `rowindex_2`) AS `rowindex` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_intersection/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_intersection/out.sql index f9290fe01a6..b60b7248d93 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_intersection/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_intersection/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_INTERSECTION(`geography_col`, `geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + ST_INTERSECTION(`geography_col`, `geography_col`) AS `geography_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 516f175c13b..32189c1bb90 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_ISCLOSED(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + ST_ISCLOSED(`geography_col`) AS `geography_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 80eef1c906e..18701e4d990 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_LENGTH(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + ST_LENGTH(`geography_col`) AS `geography_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 826eb9f209d..bb44db105f2 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_x/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_x/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_X(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + ST_X(`geography_col`) AS `geography_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 dd411820b28..e41be63567e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_y/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_y/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_Y(`geography_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + ST_Y(`geography_col`) AS `geography_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 435ee96df15..95930efe79c 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_EXTRACT(`json_col`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_EXTRACT(`json_col`, '$') AS `json_col` +FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ 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 6c9c02594d9..013bb32fef0 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_EXTRACT_ARRAY(`json_col`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_EXTRACT_ARRAY(`json_col`, '$') AS `json_col` +FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ 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 a3a51be3781..3a0a623659e 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_EXTRACT_STRING_ARRAY(`json_col`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_EXTRACT_STRING_ARRAY(`json_col`, '$') AS `json_col` +FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_keys/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_keys/out.sql index 640f933bb2b..4ae4786c190 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_keys/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_keys/out.sql @@ -1,15 +1,4 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_KEYS(`json_col`, NULL) AS `bfcol_1`, - JSON_KEYS(`json_col`, 2) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_keys`, - `bfcol_2` AS `json_keys_w_max_depth` -FROM `bfcte_1` \ No newline at end of file + JSON_KEYS(`json_col`, NULL) AS `json_keys`, + JSON_KEYS(`json_col`, 2) AS `json_keys_w_max_depth` +FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ 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 164fe2e4267..d37a9db1bf8 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_QUERY(`json_col`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_QUERY(`json_col`, '$') AS `json_col` +FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ 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 4c3fa8e7e9b..26e40b21d93 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_QUERY_ARRAY(`json_col`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_QUERY_ARRAY(`json_col`, '$') AS `json_col` +FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ 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 f41979ea2e8..8e9de92fa52 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_SET(`json_col`, '$.a', 100) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_SET(`json_col`, '$.a', 100) AS `json_col` +FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ 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 72f72372409..0bb8d89c33e 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_VALUE(`json_col`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_VALUE(`json_col`, '$') AS `json_col` +FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ 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 5f80187ba0c..e8be6759627 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - PARSE_JSON(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + PARSE_JSON(`string_col`) AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_to_json/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_to_json/out.sql index ebca0c51c52..2f7c6cbe086 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_to_json/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_to_json/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TO_JSON(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + TO_JSON(`string_col`) AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 e282c89c80e..fd4d74162af 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - TO_JSON_STRING(`json_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + TO_JSON_STRING(`json_col`) AS `json_col` +FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ 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 0fb9589387a..971a1492530 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_abs/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_abs/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ABS(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + ABS(`float64_col`) AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 1707aad8c1f..5243fcbd2d0 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` + `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` + 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` + CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) + `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_add_int`, - `bfcol_40` AS `int_add_1`, - `bfcol_41` AS `int_add_bool`, - `bfcol_42` AS `bool_add_int` -FROM `bfcte_4` \ No newline at end of file + `rowindex`, + `int64_col`, + `bool_col`, + `int64_col` + `int64_col` AS `int_add_int`, + `int64_col` + 1 AS `int_add_1`, + `int64_col` + CAST(`bool_col` AS INT64) AS `int_add_bool`, + CAST(`bool_col` AS INT64) + `int64_col` AS `bool_add_int` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_string/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_string/out.sql index cb674787ff1..0031882bc70 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_string/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_string/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CONCAT(`string_col`, 'a') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CONCAT(`string_col`, 'a') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_timedelta/out.sql index 2fef18eeb8a..f5a3b94c0bb 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_timedelta/out.sql @@ -1,60 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `timestamp_col` AS `bfcol_7`, - `date_col` AS `bfcol_8`, - TIMESTAMP_ADD(CAST(`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - TIMESTAMP_ADD(`bfcol_7`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - TIMESTAMP_ADD(CAST(`bfcol_16` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - TIMESTAMP_ADD(`bfcol_25`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_42` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - 172800000000 AS `bfcol_50` - FROM `bfcte_4` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `timestamp_col`, - `bfcol_38` AS `date_col`, - `bfcol_39` AS `date_add_timedelta`, - `bfcol_40` AS `timestamp_add_timedelta`, - `bfcol_41` AS `timedelta_add_date`, - `bfcol_42` AS `timedelta_add_timestamp`, - `bfcol_50` AS `timedelta_add_timedelta` -FROM `bfcte_5` \ No newline at end of file + `rowindex`, + `timestamp_col`, + `date_col`, + TIMESTAMP_ADD(CAST(`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `date_add_timedelta`, + TIMESTAMP_ADD(`timestamp_col`, INTERVAL 86400000000 MICROSECOND) AS `timestamp_add_timedelta`, + TIMESTAMP_ADD(CAST(`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_date`, + TIMESTAMP_ADD(`timestamp_col`, INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_timestamp`, + 172800000000 AS `timedelta_add_timedelta` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 bb1766adf35..6469c88421c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arccos/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arccos/out.sql @@ -1,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`float64_col`) > 1 - THEN CAST('NaN' AS FLOAT64) - ELSE ACOS(`float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN ABS(`float64_col`) > 1 + THEN CAST('NaN' AS FLOAT64) + ELSE ACOS(`float64_col`) + END AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 af556b9c3a3..13fd28298db 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arccosh/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arccosh/out.sql @@ -1,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `float64_col` < 1 - THEN CAST('NaN' AS FLOAT64) - ELSE ACOSH(`float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `float64_col` < 1 + THEN CAST('NaN' AS FLOAT64) + ELSE ACOSH(`float64_col`) + END AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 8243232e0b5..48ba4a9fdbd 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arcsin/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arcsin/out.sql @@ -1,17 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`float64_col`) > 1 - THEN CAST('NaN' AS FLOAT64) - ELSE ASIN(`float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN ABS(`float64_col`) > 1 + THEN CAST('NaN' AS FLOAT64) + ELSE ASIN(`float64_col`) + END AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 e6bf3b339c0..c6409c13734 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ASINH(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + ASINH(`float64_col`) AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 a85ff6403cb..70025441dba 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ATAN(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + ATAN(`float64_col`) AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan2/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan2/out.sql index 28fc8c869d7..044c0a01511 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan2/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan2/out.sql @@ -1,17 +1,4 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ATAN2(`int64_col`, `float64_col`) AS `bfcol_6`, - ATAN2(CAST(`bool_col` AS INT64), `float64_col`) AS `bfcol_7` - FROM `bfcte_0` -) SELECT - `bfcol_6` AS `int64_col`, - `bfcol_7` AS `bool_col` -FROM `bfcte_1` \ No newline at end of file + ATAN2(`int64_col`, `float64_col`) AS `int64_col`, + ATAN2(CAST(`bool_col` AS INT64), `float64_col`) AS `bool_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 dc6de62e7bc..218cd7f4908 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,19 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`float64_col`) < 1 - THEN ATANH(`float64_col`) - WHEN ABS(`float64_col`) > 1 - THEN CAST('NaN' AS FLOAT64) - ELSE CAST('Infinity' AS FLOAT64) * `float64_col` - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN ABS(`float64_col`) < 1 + THEN ATANH(`float64_col`) + WHEN ABS(`float64_col`) > 1 + THEN CAST('NaN' AS FLOAT64) + ELSE CAST('Infinity' AS FLOAT64) * `float64_col` + END AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 922fe5c5508..b202cc874d3 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CEIL(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CEIL(`float64_col`) AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 0acb2bfa944..bd57e61deab 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cos/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cos/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COS(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + COS(`float64_col`) AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 8c84a250475..4666fc9443c 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`float64_col`) > 709.78 - THEN CAST('Infinity' AS FLOAT64) - ELSE COSH(`float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN ABS(`float64_col`) > 709.78 + THEN CAST('Infinity' AS FLOAT64) + ELSE COSH(`float64_col`) + END AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosine_distance/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosine_distance/out.sql index ba6b6bfa9fa..e80dd7d91b6 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosine_distance/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosine_distance/out.sql @@ -1,16 +1,4 @@ -WITH `bfcte_0` AS ( - SELECT - `float_list_col`, - `int_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ML.DISTANCE(`int_list_col`, `int_list_col`, 'COSINE') AS `bfcol_2`, - ML.DISTANCE(`float_list_col`, `float_list_col`, 'COSINE') AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int_list_col`, - `bfcol_3` AS `float_list_col` -FROM `bfcte_1` \ No newline at end of file + ML.DISTANCE(`int_list_col`, `int_list_col`, 'COSINE') AS `int_list_col`, + ML.DISTANCE(`float_list_col`, `float_list_col`, 'COSINE') AS `float_list_col` +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ 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 db11f1529fa..42928d83a45 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_div_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_div_numeric/out.sql @@ -1,122 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_8`, - `int64_col` AS `bfcol_9`, - `bool_col` AS `bfcol_10`, - `float64_col` AS `bfcol_11`, - IEEE_DIVIDE(`int64_col`, `int64_col`) AS `bfcol_12` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_8` AS `bfcol_18`, - `bfcol_9` AS `bfcol_19`, - `bfcol_10` AS `bfcol_20`, - `bfcol_11` AS `bfcol_21`, - `bfcol_12` AS `bfcol_22`, - IEEE_DIVIDE(`bfcol_9`, 1) AS `bfcol_23` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_18` AS `bfcol_30`, - `bfcol_19` AS `bfcol_31`, - `bfcol_20` AS `bfcol_32`, - `bfcol_21` AS `bfcol_33`, - `bfcol_22` AS `bfcol_34`, - `bfcol_23` AS `bfcol_35`, - IEEE_DIVIDE(`bfcol_19`, 0.0) AS `bfcol_36` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_30` AS `bfcol_44`, - `bfcol_31` AS `bfcol_45`, - `bfcol_32` AS `bfcol_46`, - `bfcol_33` AS `bfcol_47`, - `bfcol_34` AS `bfcol_48`, - `bfcol_35` AS `bfcol_49`, - `bfcol_36` AS `bfcol_50`, - IEEE_DIVIDE(`bfcol_31`, `bfcol_33`) AS `bfcol_51` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - `bfcol_44` AS `bfcol_60`, - `bfcol_45` AS `bfcol_61`, - `bfcol_46` AS `bfcol_62`, - `bfcol_47` AS `bfcol_63`, - `bfcol_48` AS `bfcol_64`, - `bfcol_49` AS `bfcol_65`, - `bfcol_50` AS `bfcol_66`, - `bfcol_51` AS `bfcol_67`, - IEEE_DIVIDE(`bfcol_47`, `bfcol_45`) AS `bfcol_68` - FROM `bfcte_4` -), `bfcte_6` AS ( - SELECT - *, - `bfcol_60` AS `bfcol_78`, - `bfcol_61` AS `bfcol_79`, - `bfcol_62` AS `bfcol_80`, - `bfcol_63` AS `bfcol_81`, - `bfcol_64` AS `bfcol_82`, - `bfcol_65` AS `bfcol_83`, - `bfcol_66` AS `bfcol_84`, - `bfcol_67` AS `bfcol_85`, - `bfcol_68` AS `bfcol_86`, - IEEE_DIVIDE(`bfcol_63`, 0.0) AS `bfcol_87` - FROM `bfcte_5` -), `bfcte_7` AS ( - SELECT - *, - `bfcol_78` AS `bfcol_98`, - `bfcol_79` AS `bfcol_99`, - `bfcol_80` AS `bfcol_100`, - `bfcol_81` AS `bfcol_101`, - `bfcol_82` AS `bfcol_102`, - `bfcol_83` AS `bfcol_103`, - `bfcol_84` AS `bfcol_104`, - `bfcol_85` AS `bfcol_105`, - `bfcol_86` AS `bfcol_106`, - `bfcol_87` AS `bfcol_107`, - IEEE_DIVIDE(`bfcol_79`, CAST(`bfcol_80` AS INT64)) AS `bfcol_108` - FROM `bfcte_6` -), `bfcte_8` AS ( - SELECT - *, - `bfcol_98` AS `bfcol_120`, - `bfcol_99` AS `bfcol_121`, - `bfcol_100` AS `bfcol_122`, - `bfcol_101` AS `bfcol_123`, - `bfcol_102` AS `bfcol_124`, - `bfcol_103` AS `bfcol_125`, - `bfcol_104` AS `bfcol_126`, - `bfcol_105` AS `bfcol_127`, - `bfcol_106` AS `bfcol_128`, - `bfcol_107` AS `bfcol_129`, - `bfcol_108` AS `bfcol_130`, - IEEE_DIVIDE(CAST(`bfcol_100` AS INT64), `bfcol_99`) AS `bfcol_131` - FROM `bfcte_7` -) SELECT - `bfcol_120` AS `rowindex`, - `bfcol_121` AS `int64_col`, - `bfcol_122` AS `bool_col`, - `bfcol_123` AS `float64_col`, - `bfcol_124` AS `int_div_int`, - `bfcol_125` AS `int_div_1`, - `bfcol_126` AS `int_div_0`, - `bfcol_127` AS `int_div_float`, - `bfcol_128` AS `float_div_int`, - `bfcol_129` AS `float_div_0`, - `bfcol_130` AS `int_div_bool`, - `bfcol_131` AS `bool_div_int` -FROM `bfcte_8` \ No newline at end of file + `rowindex`, + `int64_col`, + `bool_col`, + `float64_col`, + IEEE_DIVIDE(`int64_col`, `int64_col`) AS `int_div_int`, + IEEE_DIVIDE(`int64_col`, 1) AS `int_div_1`, + IEEE_DIVIDE(`int64_col`, 0.0) AS `int_div_0`, + IEEE_DIVIDE(`int64_col`, `float64_col`) AS `int_div_float`, + IEEE_DIVIDE(`float64_col`, `int64_col`) AS `float_div_int`, + IEEE_DIVIDE(`float64_col`, 0.0) AS `float_div_0`, + IEEE_DIVIDE(`int64_col`, CAST(`bool_col` AS INT64)) AS `int_div_bool`, + IEEE_DIVIDE(CAST(`bool_col` AS INT64), `int64_col`) AS `bool_div_int` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 1a82a67368c..f8eaf06e5f2 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_div_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_div_timedelta/out.sql @@ -1,21 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `timestamp_col` AS `bfcol_7`, - `int64_col` AS `bfcol_8`, - CAST(FLOOR(IEEE_DIVIDE(86400000000, `int64_col`)) AS INT64) AS `bfcol_9` - FROM `bfcte_0` -) SELECT - `bfcol_6` AS `rowindex`, - `bfcol_7` AS `timestamp_col`, - `bfcol_8` AS `int64_col`, - `bfcol_9` AS `timedelta_div_numeric` -FROM `bfcte_1` \ No newline at end of file + `rowindex`, + `timestamp_col`, + `int64_col`, + CAST(FLOOR(IEEE_DIVIDE(86400000000, `int64_col`)) AS INT64) AS `timedelta_div_numeric` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_euclidean_distance/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_euclidean_distance/out.sql index 3327a99f4b6..18bbd3d412d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_euclidean_distance/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_euclidean_distance/out.sql @@ -1,16 +1,4 @@ -WITH `bfcte_0` AS ( - SELECT - `int_list_col`, - `numeric_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ML.DISTANCE(`int_list_col`, `int_list_col`, 'EUCLIDEAN') AS `bfcol_2`, - ML.DISTANCE(`numeric_list_col`, `numeric_list_col`, 'EUCLIDEAN') AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `int_list_col`, - `bfcol_3` AS `numeric_list_col` -FROM `bfcte_1` \ No newline at end of file + ML.DISTANCE(`int_list_col`, `int_list_col`, 'EUCLIDEAN') AS `int_list_col`, + ML.DISTANCE(`numeric_list_col`, `numeric_list_col`, 'EUCLIDEAN') AS `numeric_list_col` +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ 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 610b96cda70..b854008e1ee 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `float64_col` > 709.78 - THEN CAST('Infinity' AS FLOAT64) - ELSE EXP(`float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `float64_col` > 709.78 + THEN CAST('Infinity' AS FLOAT64) + ELSE EXP(`float64_col`) + END AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 13038bf8e85..86ab545c1da 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,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - IF(`float64_col` > 709.78, CAST('Infinity' AS FLOAT64), EXP(`float64_col`) - 1) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF(`float64_col` > 709.78, CAST('Infinity' AS FLOAT64), EXP(`float64_col`) - 1) AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 e0c2e1072e8..c53e2143138 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FLOOR(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + FLOOR(`float64_col`) AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 2fe20fb6188..bbcc43d1fc3 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_floordiv_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_floordiv_timedelta/out.sql @@ -1,18 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - 43200000000 AS `bfcol_6` - FROM `bfcte_0` -) SELECT `rowindex`, `timestamp_col`, `date_col`, - `bfcol_6` AS `timedelta_div_numeric` -FROM `bfcte_1` \ No newline at end of file + 43200000000 AS `timedelta_div_numeric` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 bd4cfa7c9a3..4d28ba6c771 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,21 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `float64_col` IS NULL - THEN NULL - WHEN `float64_col` > 0 - THEN LN(`float64_col`) - WHEN `float64_col` < 0 - THEN CAST('NaN' AS FLOAT64) - ELSE CAST('-Infinity' AS FLOAT64) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `float64_col` IS NULL + THEN NULL + WHEN `float64_col` > 0 + THEN LN(`float64_col`) + WHEN `float64_col` < 0 + THEN CAST('NaN' AS FLOAT64) + ELSE CAST('-Infinity' AS FLOAT64) + END AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 c5bbff0e624..509ca0a2f33 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,21 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `float64_col` IS NULL - THEN NULL - WHEN `float64_col` > 0 - THEN LOG(`float64_col`, 10) - WHEN `float64_col` < 0 - THEN CAST('NaN' AS FLOAT64) - ELSE CAST('-Infinity' AS FLOAT64) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `float64_col` IS NULL + THEN NULL + WHEN `float64_col` > 0 + THEN LOG(`float64_col`, 10) + WHEN `float64_col` < 0 + THEN CAST('NaN' AS FLOAT64) + ELSE CAST('-Infinity' AS FLOAT64) + END AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 22e67e24eed..4e63205a287 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,21 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `float64_col` IS NULL - THEN NULL - WHEN `float64_col` > -1 - THEN LN(1 + `float64_col`) - WHEN `float64_col` < -1 - THEN CAST('NaN' AS FLOAT64) - ELSE CAST('-Infinity' AS FLOAT64) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN `float64_col` IS NULL + THEN NULL + WHEN `float64_col` > -1 + THEN LN(1 + `float64_col`) + WHEN `float64_col` < -1 + THEN CAST('NaN' AS FLOAT64) + ELSE CAST('-Infinity' AS FLOAT64) + END AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_manhattan_distance/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_manhattan_distance/out.sql index 185bb7b277c..35e53e1ee29 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_manhattan_distance/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_manhattan_distance/out.sql @@ -1,16 +1,4 @@ -WITH `bfcte_0` AS ( - SELECT - `float_list_col`, - `numeric_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ML.DISTANCE(`float_list_col`, `float_list_col`, 'MANHATTAN') AS `bfcol_2`, - ML.DISTANCE(`numeric_list_col`, `numeric_list_col`, 'MANHATTAN') AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_2` AS `float_list_col`, - `bfcol_3` AS `numeric_list_col` -FROM `bfcte_1` \ No newline at end of file + ML.DISTANCE(`float_list_col`, `float_list_col`, 'MANHATTAN') AS `float_list_col`, + ML.DISTANCE(`numeric_list_col`, `numeric_list_col`, 'MANHATTAN') AS `numeric_list_col` +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mod_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mod_numeric/out.sql index 241ffa0b5ea..fdd6f3f305a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mod_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mod_numeric/out.sql @@ -1,292 +1,193 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `float64_col` AS `bfcol_8`, - CASE - WHEN `int64_col` = CAST(0 AS INT64) - THEN CAST(0 AS INT64) * `int64_col` - WHEN `int64_col` < CAST(0 AS INT64) - AND ( - MOD(`int64_col`, `int64_col`) - ) > CAST(0 AS INT64) - THEN `int64_col` + ( - MOD(`int64_col`, `int64_col`) - ) - WHEN `int64_col` > CAST(0 AS INT64) - AND ( - MOD(`int64_col`, `int64_col`) - ) < CAST(0 AS INT64) - THEN `int64_col` + ( - MOD(`int64_col`, `int64_col`) - ) - ELSE MOD(`int64_col`, `int64_col`) - END AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - CASE - WHEN -( - `bfcol_7` - ) = CAST(0 AS INT64) - THEN CAST(0 AS INT64) * `bfcol_7` - WHEN -( - `bfcol_7` - ) < CAST(0 AS INT64) - AND ( - MOD(`bfcol_7`, -( - `bfcol_7` - )) - ) > CAST(0 AS INT64) - THEN -( - `bfcol_7` - ) + ( - MOD(`bfcol_7`, -( - `bfcol_7` - )) - ) - WHEN -( - `bfcol_7` - ) > CAST(0 AS INT64) - AND ( - MOD(`bfcol_7`, -( - `bfcol_7` - )) - ) < CAST(0 AS INT64) - THEN -( - `bfcol_7` - ) + ( - MOD(`bfcol_7`, -( - `bfcol_7` - )) - ) - ELSE MOD(`bfcol_7`, -( - `bfcol_7` +SELECT + `rowindex`, + `int64_col`, + `float64_col`, + CASE + WHEN `int64_col` = CAST(0 AS INT64) + THEN CAST(0 AS INT64) * `int64_col` + WHEN `int64_col` < CAST(0 AS INT64) + AND ( + MOD(`int64_col`, `int64_col`) + ) > CAST(0 AS INT64) + THEN `int64_col` + ( + MOD(`int64_col`, `int64_col`) + ) + WHEN `int64_col` > CAST(0 AS INT64) + AND ( + MOD(`int64_col`, `int64_col`) + ) < CAST(0 AS INT64) + THEN `int64_col` + ( + MOD(`int64_col`, `int64_col`) + ) + ELSE MOD(`int64_col`, `int64_col`) + END AS `int_mod_int`, + CASE + WHEN -( + `int64_col` + ) = CAST(0 AS INT64) + THEN CAST(0 AS INT64) * `int64_col` + WHEN -( + `int64_col` + ) < CAST(0 AS INT64) + AND ( + MOD(`int64_col`, -( + `int64_col` + )) + ) > CAST(0 AS INT64) + THEN -( + `int64_col` + ) + ( + MOD(`int64_col`, -( + `int64_col` + )) + ) + WHEN -( + `int64_col` + ) > CAST(0 AS INT64) + AND ( + MOD(`int64_col`, -( + `int64_col` + )) + ) < CAST(0 AS INT64) + THEN -( + `int64_col` + ) + ( + MOD(`int64_col`, -( + `int64_col` )) - END AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - CASE - WHEN 1 = CAST(0 AS INT64) - THEN CAST(0 AS INT64) * `bfcol_15` - WHEN 1 < CAST(0 AS INT64) AND ( - MOD(`bfcol_15`, 1) - ) > CAST(0 AS INT64) - THEN 1 + ( - MOD(`bfcol_15`, 1) - ) - WHEN 1 > CAST(0 AS INT64) AND ( - MOD(`bfcol_15`, 1) - ) < CAST(0 AS INT64) - THEN 1 + ( - MOD(`bfcol_15`, 1) - ) - ELSE MOD(`bfcol_15`, 1) - END AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CASE - WHEN 0 = CAST(0 AS INT64) - THEN CAST(0 AS INT64) * `bfcol_25` - WHEN 0 < CAST(0 AS INT64) AND ( - MOD(`bfcol_25`, 0) - ) > CAST(0 AS INT64) - THEN 0 + ( - MOD(`bfcol_25`, 0) - ) - WHEN 0 > CAST(0 AS INT64) AND ( - MOD(`bfcol_25`, 0) - ) < CAST(0 AS INT64) - THEN 0 + ( - MOD(`bfcol_25`, 0) - ) - ELSE MOD(`bfcol_25`, 0) - END AS `bfcol_42` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - `bfcol_36` AS `bfcol_50`, - `bfcol_37` AS `bfcol_51`, - `bfcol_38` AS `bfcol_52`, - `bfcol_39` AS `bfcol_53`, - `bfcol_40` AS `bfcol_54`, - `bfcol_41` AS `bfcol_55`, - `bfcol_42` AS `bfcol_56`, - CASE - WHEN CAST(`bfcol_38` AS BIGNUMERIC) = CAST(0 AS INT64) - THEN CAST('NaN' AS FLOAT64) * CAST(`bfcol_38` AS BIGNUMERIC) - WHEN CAST(`bfcol_38` AS BIGNUMERIC) < CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_38` AS BIGNUMERIC), CAST(`bfcol_38` AS BIGNUMERIC)) - ) > CAST(0 AS INT64) - THEN CAST(`bfcol_38` AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_38` AS BIGNUMERIC), CAST(`bfcol_38` AS BIGNUMERIC)) - ) - WHEN CAST(`bfcol_38` AS BIGNUMERIC) > CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_38` AS BIGNUMERIC), CAST(`bfcol_38` AS BIGNUMERIC)) - ) < CAST(0 AS INT64) - THEN CAST(`bfcol_38` AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_38` AS BIGNUMERIC), CAST(`bfcol_38` AS BIGNUMERIC)) - ) - ELSE MOD(CAST(`bfcol_38` AS BIGNUMERIC), CAST(`bfcol_38` AS BIGNUMERIC)) - END AS `bfcol_57` - FROM `bfcte_4` -), `bfcte_6` AS ( - SELECT - *, - `bfcol_50` AS `bfcol_66`, - `bfcol_51` AS `bfcol_67`, - `bfcol_52` AS `bfcol_68`, - `bfcol_53` AS `bfcol_69`, - `bfcol_54` AS `bfcol_70`, - `bfcol_55` AS `bfcol_71`, - `bfcol_56` AS `bfcol_72`, - `bfcol_57` AS `bfcol_73`, - CASE - WHEN CAST(-( - `bfcol_52` - ) AS BIGNUMERIC) = CAST(0 AS INT64) - THEN CAST('NaN' AS FLOAT64) * CAST(`bfcol_52` AS BIGNUMERIC) - WHEN CAST(-( - `bfcol_52` - ) AS BIGNUMERIC) < CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-( - `bfcol_52` - ) AS BIGNUMERIC)) - ) > CAST(0 AS INT64) - THEN CAST(-( - `bfcol_52` - ) AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-( - `bfcol_52` - ) AS BIGNUMERIC)) - ) - WHEN CAST(-( - `bfcol_52` - ) AS BIGNUMERIC) > CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-( - `bfcol_52` - ) AS BIGNUMERIC)) - ) < CAST(0 AS INT64) - THEN CAST(-( - `bfcol_52` - ) AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-( - `bfcol_52` - ) AS BIGNUMERIC)) - ) - ELSE MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-( - `bfcol_52` + ) + ELSE MOD(`int64_col`, -( + `int64_col` + )) + END AS `int_mod_int_neg`, + CASE + WHEN 1 = CAST(0 AS INT64) + THEN CAST(0 AS INT64) * `int64_col` + WHEN 1 < CAST(0 AS INT64) AND ( + MOD(`int64_col`, 1) + ) > CAST(0 AS INT64) + THEN 1 + ( + MOD(`int64_col`, 1) + ) + WHEN 1 > CAST(0 AS INT64) AND ( + MOD(`int64_col`, 1) + ) < CAST(0 AS INT64) + THEN 1 + ( + MOD(`int64_col`, 1) + ) + ELSE MOD(`int64_col`, 1) + END AS `int_mod_1`, + CASE + WHEN 0 = CAST(0 AS INT64) + THEN CAST(0 AS INT64) * `int64_col` + WHEN 0 < CAST(0 AS INT64) AND ( + MOD(`int64_col`, 0) + ) > CAST(0 AS INT64) + THEN 0 + ( + MOD(`int64_col`, 0) + ) + WHEN 0 > CAST(0 AS INT64) AND ( + MOD(`int64_col`, 0) + ) < CAST(0 AS INT64) + THEN 0 + ( + MOD(`int64_col`, 0) + ) + ELSE MOD(`int64_col`, 0) + END AS `int_mod_0`, + CASE + WHEN CAST(`float64_col` AS BIGNUMERIC) = CAST(0 AS INT64) + THEN CAST('NaN' AS FLOAT64) * CAST(`float64_col` AS BIGNUMERIC) + WHEN CAST(`float64_col` AS BIGNUMERIC) < CAST(0 AS INT64) + AND ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(`float64_col` AS BIGNUMERIC)) + ) > CAST(0 AS INT64) + THEN CAST(`float64_col` AS BIGNUMERIC) + ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(`float64_col` AS BIGNUMERIC)) + ) + WHEN CAST(`float64_col` AS BIGNUMERIC) > CAST(0 AS INT64) + AND ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(`float64_col` AS BIGNUMERIC)) + ) < CAST(0 AS INT64) + THEN CAST(`float64_col` AS BIGNUMERIC) + ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(`float64_col` AS BIGNUMERIC)) + ) + ELSE MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(`float64_col` AS BIGNUMERIC)) + END AS `float_mod_float`, + CASE + WHEN CAST(-( + `float64_col` + ) AS BIGNUMERIC) = CAST(0 AS INT64) + THEN CAST('NaN' AS FLOAT64) * CAST(`float64_col` AS BIGNUMERIC) + WHEN CAST(-( + `float64_col` + ) AS BIGNUMERIC) < CAST(0 AS INT64) + AND ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(-( + `float64_col` ) AS BIGNUMERIC)) - END AS `bfcol_74` - FROM `bfcte_5` -), `bfcte_7` AS ( - SELECT - *, - `bfcol_66` AS `bfcol_84`, - `bfcol_67` AS `bfcol_85`, - `bfcol_68` AS `bfcol_86`, - `bfcol_69` AS `bfcol_87`, - `bfcol_70` AS `bfcol_88`, - `bfcol_71` AS `bfcol_89`, - `bfcol_72` AS `bfcol_90`, - `bfcol_73` AS `bfcol_91`, - `bfcol_74` AS `bfcol_92`, - CASE - WHEN CAST(1 AS BIGNUMERIC) = CAST(0 AS INT64) - THEN CAST('NaN' AS FLOAT64) * CAST(`bfcol_68` AS BIGNUMERIC) - WHEN CAST(1 AS BIGNUMERIC) < CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_68` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) - ) > CAST(0 AS INT64) - THEN CAST(1 AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_68` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) - ) - WHEN CAST(1 AS BIGNUMERIC) > CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_68` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) - ) < CAST(0 AS INT64) - THEN CAST(1 AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_68` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) - ) - ELSE MOD(CAST(`bfcol_68` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) - END AS `bfcol_93` - FROM `bfcte_6` -), `bfcte_8` AS ( - SELECT - *, - `bfcol_84` AS `bfcol_104`, - `bfcol_85` AS `bfcol_105`, - `bfcol_86` AS `bfcol_106`, - `bfcol_87` AS `bfcol_107`, - `bfcol_88` AS `bfcol_108`, - `bfcol_89` AS `bfcol_109`, - `bfcol_90` AS `bfcol_110`, - `bfcol_91` AS `bfcol_111`, - `bfcol_92` AS `bfcol_112`, - `bfcol_93` AS `bfcol_113`, - CASE - WHEN CAST(0 AS BIGNUMERIC) = CAST(0 AS INT64) - THEN CAST('NaN' AS FLOAT64) * CAST(`bfcol_86` AS BIGNUMERIC) - WHEN CAST(0 AS BIGNUMERIC) < CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_86` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) - ) > CAST(0 AS INT64) - THEN CAST(0 AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_86` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) - ) - WHEN CAST(0 AS BIGNUMERIC) > CAST(0 AS INT64) - AND ( - MOD(CAST(`bfcol_86` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) - ) < CAST(0 AS INT64) - THEN CAST(0 AS BIGNUMERIC) + ( - MOD(CAST(`bfcol_86` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) - ) - ELSE MOD(CAST(`bfcol_86` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) - END AS `bfcol_114` - FROM `bfcte_7` -) -SELECT - `bfcol_104` AS `rowindex`, - `bfcol_105` AS `int64_col`, - `bfcol_106` AS `float64_col`, - `bfcol_107` AS `int_mod_int`, - `bfcol_108` AS `int_mod_int_neg`, - `bfcol_109` AS `int_mod_1`, - `bfcol_110` AS `int_mod_0`, - `bfcol_111` AS `float_mod_float`, - `bfcol_112` AS `float_mod_float_neg`, - `bfcol_113` AS `float_mod_1`, - `bfcol_114` AS `float_mod_0` -FROM `bfcte_8` \ No newline at end of file + ) > CAST(0 AS INT64) + THEN CAST(-( + `float64_col` + ) AS BIGNUMERIC) + ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(-( + `float64_col` + ) AS BIGNUMERIC)) + ) + WHEN CAST(-( + `float64_col` + ) AS BIGNUMERIC) > CAST(0 AS INT64) + AND ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(-( + `float64_col` + ) AS BIGNUMERIC)) + ) < CAST(0 AS INT64) + THEN CAST(-( + `float64_col` + ) AS BIGNUMERIC) + ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(-( + `float64_col` + ) AS BIGNUMERIC)) + ) + ELSE MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(-( + `float64_col` + ) AS BIGNUMERIC)) + END AS `float_mod_float_neg`, + CASE + WHEN CAST(1 AS BIGNUMERIC) = CAST(0 AS INT64) + THEN CAST('NaN' AS FLOAT64) * CAST(`float64_col` AS BIGNUMERIC) + WHEN CAST(1 AS BIGNUMERIC) < CAST(0 AS INT64) + AND ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) + ) > CAST(0 AS INT64) + THEN CAST(1 AS BIGNUMERIC) + ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) + ) + WHEN CAST(1 AS BIGNUMERIC) > CAST(0 AS INT64) + AND ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) + ) < CAST(0 AS INT64) + THEN CAST(1 AS BIGNUMERIC) + ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) + ) + ELSE MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(1 AS BIGNUMERIC)) + END AS `float_mod_1`, + CASE + WHEN CAST(0 AS BIGNUMERIC) = CAST(0 AS INT64) + THEN CAST('NaN' AS FLOAT64) * CAST(`float64_col` AS BIGNUMERIC) + WHEN CAST(0 AS BIGNUMERIC) < CAST(0 AS INT64) + AND ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) + ) > CAST(0 AS INT64) + THEN CAST(0 AS BIGNUMERIC) + ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) + ) + WHEN CAST(0 AS BIGNUMERIC) > CAST(0 AS INT64) + AND ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) + ) < CAST(0 AS INT64) + THEN CAST(0 AS BIGNUMERIC) + ( + MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) + ) + ELSE MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) + END AS `float_mod_0` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 d0c537e4820..00c4d64fb4d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` * `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` * 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` * CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) * `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_mul_int`, - `bfcol_40` AS `int_mul_1`, - `bfcol_41` AS `int_mul_bool`, - `bfcol_42` AS `bool_mul_int` -FROM `bfcte_4` \ No newline at end of file + `rowindex`, + `int64_col`, + `bool_col`, + `int64_col` * `int64_col` AS `int_mul_int`, + `int64_col` * 1 AS `int_mul_1`, + `int64_col` * CAST(`bool_col` AS INT64) AS `int_mul_bool`, + CAST(`bool_col` AS INT64) * `int64_col` AS `bool_mul_int` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_timedelta/out.sql index ebdf296b2b2..30ca104e614 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_timedelta/out.sql @@ -1,43 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `duration_col`, - `int64_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_8`, - `timestamp_col` AS `bfcol_9`, - `int64_col` AS `bfcol_10`, - `duration_col` AS `bfcol_11` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_10` AS `bfcol_18`, - `bfcol_11` AS `bfcol_19`, - CAST(FLOOR(`bfcol_11` * `bfcol_10`) AS INT64) AS `bfcol_20` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_19` AS `bfcol_29`, - `bfcol_20` AS `bfcol_30`, - CAST(FLOOR(`bfcol_18` * `bfcol_19`) AS INT64) AS `bfcol_31` - FROM `bfcte_2` -) SELECT - `bfcol_26` AS `rowindex`, - `bfcol_27` AS `timestamp_col`, - `bfcol_28` AS `int64_col`, - `bfcol_29` AS `duration_col`, - `bfcol_30` AS `timedelta_mul_numeric`, - `bfcol_31` AS `numeric_mul_timedelta` -FROM `bfcte_3` \ No newline at end of file + `rowindex`, + `timestamp_col`, + `int64_col`, + `duration_col`, + CAST(FLOOR(`duration_col` * `int64_col`) AS INT64) AS `timedelta_mul_numeric`, + CAST(FLOOR(`int64_col` * `duration_col`) AS INT64) AS `numeric_mul_timedelta` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 4374af349b7..a2141579ca2 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_neg/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_neg/out.sql @@ -1,15 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - -( - `float64_col` - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + -( + `float64_col` + ) AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 1ed016029a2..9174e063743 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pos/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pos/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `float64_col` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pow/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pow/out.sql index 05fbaa12c92..213d8a011b0 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pow/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pow/out.sql @@ -1,329 +1,234 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `float64_col` AS `bfcol_8`, - CASE - WHEN `int64_col` <> 0 AND `int64_col` * LN(ABS(`int64_col`)) > 43.66827237527655 - THEN NULL - ELSE CAST(POWER(CAST(`int64_col` AS NUMERIC), `int64_col`) AS INT64) - END AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - CASE - WHEN `bfcol_8` = CAST(0 AS INT64) - THEN 1 - WHEN `bfcol_7` = 1 - THEN 1 - WHEN `bfcol_7` = CAST(0 AS INT64) AND `bfcol_8` < CAST(0 AS INT64) - THEN CAST('Infinity' AS FLOAT64) - WHEN ABS(`bfcol_7`) = CAST('Infinity' AS FLOAT64) - THEN POWER( - `bfcol_7`, - CASE - WHEN ABS(`bfcol_8`) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(`bfcol_8`) - ELSE `bfcol_8` - END - ) - WHEN ABS(`bfcol_8`) > 9007199254740992 - THEN POWER( - `bfcol_7`, - CASE - WHEN ABS(`bfcol_8`) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(`bfcol_8`) - ELSE `bfcol_8` - END - ) - WHEN `bfcol_7` < CAST(0 AS INT64) AND NOT CAST(`bfcol_8` AS INT64) = `bfcol_8` - THEN CAST('NaN' AS FLOAT64) - WHEN `bfcol_7` <> CAST(0 AS INT64) AND `bfcol_8` * LN(ABS(`bfcol_7`)) > 709.78 - THEN CAST('Infinity' AS FLOAT64) * CASE - WHEN `bfcol_7` < CAST(0 AS INT64) AND MOD(CAST(`bfcol_8` AS INT64), 2) = 1 - THEN -1 - ELSE 1 +SELECT + `rowindex`, + `int64_col`, + `float64_col`, + CASE + WHEN `int64_col` <> 0 AND `int64_col` * LN(ABS(`int64_col`)) > 43.66827237527655 + THEN NULL + ELSE CAST(POWER(CAST(`int64_col` AS NUMERIC), `int64_col`) AS INT64) + END AS `int_pow_int`, + CASE + WHEN `float64_col` = CAST(0 AS INT64) + THEN 1 + WHEN `int64_col` = 1 + THEN 1 + WHEN `int64_col` = CAST(0 AS INT64) AND `float64_col` < CAST(0 AS INT64) + THEN CAST('Infinity' AS FLOAT64) + WHEN ABS(`int64_col`) = CAST('Infinity' AS FLOAT64) + THEN POWER( + `int64_col`, + CASE + WHEN ABS(`float64_col`) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(`float64_col`) + ELSE `float64_col` END - ELSE POWER( - `bfcol_7`, - CASE - WHEN ABS(`bfcol_8`) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(`bfcol_8`) - ELSE `bfcol_8` - END - ) - END AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - CASE - WHEN `bfcol_15` = CAST(0 AS INT64) - THEN 1 - WHEN `bfcol_16` = 1 - THEN 1 - WHEN `bfcol_16` = CAST(0 AS INT64) AND `bfcol_15` < CAST(0 AS INT64) - THEN CAST('Infinity' AS FLOAT64) - WHEN ABS(`bfcol_16`) = CAST('Infinity' AS FLOAT64) - THEN POWER( - `bfcol_16`, - CASE - WHEN ABS(`bfcol_15`) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(`bfcol_15`) - ELSE `bfcol_15` - END - ) - WHEN ABS(`bfcol_15`) > 9007199254740992 - THEN POWER( - `bfcol_16`, - CASE - WHEN ABS(`bfcol_15`) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(`bfcol_15`) - ELSE `bfcol_15` - END - ) - WHEN `bfcol_16` < CAST(0 AS INT64) AND NOT CAST(`bfcol_15` AS INT64) = `bfcol_15` - THEN CAST('NaN' AS FLOAT64) - WHEN `bfcol_16` <> CAST(0 AS INT64) AND `bfcol_15` * LN(ABS(`bfcol_16`)) > 709.78 - THEN CAST('Infinity' AS FLOAT64) * CASE - WHEN `bfcol_16` < CAST(0 AS INT64) AND MOD(CAST(`bfcol_15` AS INT64), 2) = 1 - THEN -1 - ELSE 1 + ) + WHEN ABS(`float64_col`) > 9007199254740992 + THEN POWER( + `int64_col`, + CASE + WHEN ABS(`float64_col`) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(`float64_col`) + ELSE `float64_col` + END + ) + WHEN `int64_col` < CAST(0 AS INT64) + AND NOT CAST(`float64_col` AS INT64) = `float64_col` + THEN CAST('NaN' AS FLOAT64) + WHEN `int64_col` <> CAST(0 AS INT64) AND `float64_col` * LN(ABS(`int64_col`)) > 709.78 + THEN CAST('Infinity' AS FLOAT64) * CASE + WHEN `int64_col` < CAST(0 AS INT64) AND MOD(CAST(`float64_col` AS INT64), 2) = 1 + THEN -1 + ELSE 1 + END + ELSE POWER( + `int64_col`, + CASE + WHEN ABS(`float64_col`) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(`float64_col`) + ELSE `float64_col` + END + ) + END AS `int_pow_float`, + CASE + WHEN `int64_col` = CAST(0 AS INT64) + THEN 1 + WHEN `float64_col` = 1 + THEN 1 + WHEN `float64_col` = CAST(0 AS INT64) AND `int64_col` < CAST(0 AS INT64) + THEN CAST('Infinity' AS FLOAT64) + WHEN ABS(`float64_col`) = CAST('Infinity' AS FLOAT64) + THEN POWER( + `float64_col`, + CASE + WHEN ABS(`int64_col`) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(`int64_col`) + ELSE `int64_col` + END + ) + WHEN ABS(`int64_col`) > 9007199254740992 + THEN POWER( + `float64_col`, + CASE + WHEN ABS(`int64_col`) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(`int64_col`) + ELSE `int64_col` + END + ) + WHEN `float64_col` < CAST(0 AS INT64) AND NOT CAST(`int64_col` AS INT64) = `int64_col` + THEN CAST('NaN' AS FLOAT64) + WHEN `float64_col` <> CAST(0 AS INT64) + AND `int64_col` * LN(ABS(`float64_col`)) > 709.78 + THEN CAST('Infinity' AS FLOAT64) * CASE + WHEN `float64_col` < CAST(0 AS INT64) AND MOD(CAST(`int64_col` AS INT64), 2) = 1 + THEN -1 + ELSE 1 + END + ELSE POWER( + `float64_col`, + CASE + WHEN ABS(`int64_col`) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(`int64_col`) + ELSE `int64_col` END - ELSE POWER( - `bfcol_16`, - CASE - WHEN ABS(`bfcol_15`) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(`bfcol_15`) - ELSE `bfcol_15` - END - ) - END AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CASE - WHEN `bfcol_26` = CAST(0 AS INT64) - THEN 1 - WHEN `bfcol_26` = 1 - THEN 1 - WHEN `bfcol_26` = CAST(0 AS INT64) AND `bfcol_26` < CAST(0 AS INT64) - THEN CAST('Infinity' AS FLOAT64) - WHEN ABS(`bfcol_26`) = CAST('Infinity' AS FLOAT64) - THEN POWER( - `bfcol_26`, - CASE - WHEN ABS(`bfcol_26`) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(`bfcol_26`) - ELSE `bfcol_26` - END - ) - WHEN ABS(`bfcol_26`) > 9007199254740992 - THEN POWER( - `bfcol_26`, - CASE - WHEN ABS(`bfcol_26`) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(`bfcol_26`) - ELSE `bfcol_26` - END - ) - WHEN `bfcol_26` < CAST(0 AS INT64) AND NOT CAST(`bfcol_26` AS INT64) = `bfcol_26` - THEN CAST('NaN' AS FLOAT64) - WHEN `bfcol_26` <> CAST(0 AS INT64) AND `bfcol_26` * LN(ABS(`bfcol_26`)) > 709.78 - THEN CAST('Infinity' AS FLOAT64) * CASE - WHEN `bfcol_26` < CAST(0 AS INT64) AND MOD(CAST(`bfcol_26` AS INT64), 2) = 1 - THEN -1 + ) + END AS `float_pow_int`, + CASE + WHEN `float64_col` = CAST(0 AS INT64) + THEN 1 + WHEN `float64_col` = 1 + THEN 1 + WHEN `float64_col` = CAST(0 AS INT64) AND `float64_col` < CAST(0 AS INT64) + THEN CAST('Infinity' AS FLOAT64) + WHEN ABS(`float64_col`) = CAST('Infinity' AS FLOAT64) + THEN POWER( + `float64_col`, + CASE + WHEN ABS(`float64_col`) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(`float64_col`) + ELSE `float64_col` + END + ) + WHEN ABS(`float64_col`) > 9007199254740992 + THEN POWER( + `float64_col`, + CASE + WHEN ABS(`float64_col`) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(`float64_col`) + ELSE `float64_col` + END + ) + WHEN `float64_col` < CAST(0 AS INT64) + AND NOT CAST(`float64_col` AS INT64) = `float64_col` + THEN CAST('NaN' AS FLOAT64) + WHEN `float64_col` <> CAST(0 AS INT64) + AND `float64_col` * LN(ABS(`float64_col`)) > 709.78 + THEN CAST('Infinity' AS FLOAT64) * CASE + WHEN `float64_col` < CAST(0 AS INT64) AND MOD(CAST(`float64_col` AS INT64), 2) = 1 + THEN -1 + ELSE 1 + END + ELSE POWER( + `float64_col`, + CASE + WHEN ABS(`float64_col`) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(`float64_col`) + ELSE `float64_col` + END + ) + END AS `float_pow_float`, + CASE + WHEN `int64_col` <> 0 AND 0 * LN(ABS(`int64_col`)) > 43.66827237527655 + THEN NULL + ELSE CAST(POWER(CAST(`int64_col` AS NUMERIC), 0) AS INT64) + END AS `int_pow_0`, + CASE + WHEN 0 = CAST(0 AS INT64) + THEN 1 + WHEN `float64_col` = 1 + THEN 1 + WHEN `float64_col` = CAST(0 AS INT64) AND 0 < CAST(0 AS INT64) + THEN CAST('Infinity' AS FLOAT64) + WHEN ABS(`float64_col`) = CAST('Infinity' AS FLOAT64) + THEN POWER( + `float64_col`, + CASE + WHEN ABS(0) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(0) + ELSE 0 + END + ) + WHEN ABS(0) > 9007199254740992 + THEN POWER( + `float64_col`, + CASE + WHEN ABS(0) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(0) + ELSE 0 + END + ) + WHEN `float64_col` < CAST(0 AS INT64) AND NOT CAST(0 AS INT64) = 0 + THEN CAST('NaN' AS FLOAT64) + WHEN `float64_col` <> CAST(0 AS INT64) AND 0 * LN(ABS(`float64_col`)) > 709.78 + THEN CAST('Infinity' AS FLOAT64) * CASE + WHEN `float64_col` < CAST(0 AS INT64) AND MOD(CAST(0 AS INT64), 2) = 1 + THEN -1 + ELSE 1 + END + ELSE POWER( + `float64_col`, + CASE + WHEN ABS(0) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(0) + ELSE 0 + END + ) + END AS `float_pow_0`, + CASE + WHEN `int64_col` <> 0 AND 1 * LN(ABS(`int64_col`)) > 43.66827237527655 + THEN NULL + ELSE CAST(POWER(CAST(`int64_col` AS NUMERIC), 1) AS INT64) + END AS `int_pow_1`, + CASE + WHEN 1 = CAST(0 AS INT64) + THEN 1 + WHEN `float64_col` = 1 + THEN 1 + WHEN `float64_col` = CAST(0 AS INT64) AND 1 < CAST(0 AS INT64) + THEN CAST('Infinity' AS FLOAT64) + WHEN ABS(`float64_col`) = CAST('Infinity' AS FLOAT64) + THEN POWER( + `float64_col`, + CASE + WHEN ABS(1) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(1) ELSE 1 END - ELSE POWER( - `bfcol_26`, - CASE - WHEN ABS(`bfcol_26`) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(`bfcol_26`) - ELSE `bfcol_26` - END - ) - END AS `bfcol_42` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - `bfcol_36` AS `bfcol_50`, - `bfcol_37` AS `bfcol_51`, - `bfcol_38` AS `bfcol_52`, - `bfcol_39` AS `bfcol_53`, - `bfcol_40` AS `bfcol_54`, - `bfcol_41` AS `bfcol_55`, - `bfcol_42` AS `bfcol_56`, - CASE - WHEN `bfcol_37` <> 0 AND 0 * LN(ABS(`bfcol_37`)) > 43.66827237527655 - THEN NULL - ELSE CAST(POWER(CAST(`bfcol_37` AS NUMERIC), 0) AS INT64) - END AS `bfcol_57` - FROM `bfcte_4` -), `bfcte_6` AS ( - SELECT - *, - `bfcol_50` AS `bfcol_66`, - `bfcol_51` AS `bfcol_67`, - `bfcol_52` AS `bfcol_68`, - `bfcol_53` AS `bfcol_69`, - `bfcol_54` AS `bfcol_70`, - `bfcol_55` AS `bfcol_71`, - `bfcol_56` AS `bfcol_72`, - `bfcol_57` AS `bfcol_73`, - CASE - WHEN 0 = CAST(0 AS INT64) - THEN 1 - WHEN `bfcol_52` = 1 - THEN 1 - WHEN `bfcol_52` = CAST(0 AS INT64) AND 0 < CAST(0 AS INT64) - THEN CAST('Infinity' AS FLOAT64) - WHEN ABS(`bfcol_52`) = CAST('Infinity' AS FLOAT64) - THEN POWER( - `bfcol_52`, - CASE - WHEN ABS(0) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(0) - ELSE 0 - END - ) - WHEN ABS(0) > 9007199254740992 - THEN POWER( - `bfcol_52`, - CASE - WHEN ABS(0) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(0) - ELSE 0 - END - ) - WHEN `bfcol_52` < CAST(0 AS INT64) AND NOT CAST(0 AS INT64) = 0 - THEN CAST('NaN' AS FLOAT64) - WHEN `bfcol_52` <> CAST(0 AS INT64) AND 0 * LN(ABS(`bfcol_52`)) > 709.78 - THEN CAST('Infinity' AS FLOAT64) * CASE - WHEN `bfcol_52` < CAST(0 AS INT64) AND MOD(CAST(0 AS INT64), 2) = 1 - THEN -1 + ) + WHEN ABS(1) > 9007199254740992 + THEN POWER( + `float64_col`, + CASE + WHEN ABS(1) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(1) ELSE 1 END - ELSE POWER( - `bfcol_52`, - CASE - WHEN ABS(0) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(0) - ELSE 0 - END - ) - END AS `bfcol_74` - FROM `bfcte_5` -), `bfcte_7` AS ( - SELECT - *, - `bfcol_66` AS `bfcol_84`, - `bfcol_67` AS `bfcol_85`, - `bfcol_68` AS `bfcol_86`, - `bfcol_69` AS `bfcol_87`, - `bfcol_70` AS `bfcol_88`, - `bfcol_71` AS `bfcol_89`, - `bfcol_72` AS `bfcol_90`, - `bfcol_73` AS `bfcol_91`, - `bfcol_74` AS `bfcol_92`, - CASE - WHEN `bfcol_67` <> 0 AND 1 * LN(ABS(`bfcol_67`)) > 43.66827237527655 - THEN NULL - ELSE CAST(POWER(CAST(`bfcol_67` AS NUMERIC), 1) AS INT64) - END AS `bfcol_93` - FROM `bfcte_6` -), `bfcte_8` AS ( - SELECT - *, - `bfcol_84` AS `bfcol_104`, - `bfcol_85` AS `bfcol_105`, - `bfcol_86` AS `bfcol_106`, - `bfcol_87` AS `bfcol_107`, - `bfcol_88` AS `bfcol_108`, - `bfcol_89` AS `bfcol_109`, - `bfcol_90` AS `bfcol_110`, - `bfcol_91` AS `bfcol_111`, - `bfcol_92` AS `bfcol_112`, - `bfcol_93` AS `bfcol_113`, - CASE - WHEN 1 = CAST(0 AS INT64) - THEN 1 - WHEN `bfcol_86` = 1 - THEN 1 - WHEN `bfcol_86` = CAST(0 AS INT64) AND 1 < CAST(0 AS INT64) - THEN CAST('Infinity' AS FLOAT64) - WHEN ABS(`bfcol_86`) = CAST('Infinity' AS FLOAT64) - THEN POWER( - `bfcol_86`, - CASE - WHEN ABS(1) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(1) - ELSE 1 - END - ) - WHEN ABS(1) > 9007199254740992 - THEN POWER( - `bfcol_86`, - CASE - WHEN ABS(1) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(1) - ELSE 1 - END - ) - WHEN `bfcol_86` < CAST(0 AS INT64) AND NOT CAST(1 AS INT64) = 1 - THEN CAST('NaN' AS FLOAT64) - WHEN `bfcol_86` <> CAST(0 AS INT64) AND 1 * LN(ABS(`bfcol_86`)) > 709.78 - THEN CAST('Infinity' AS FLOAT64) * CASE - WHEN `bfcol_86` < CAST(0 AS INT64) AND MOD(CAST(1 AS INT64), 2) = 1 - THEN -1 + ) + WHEN `float64_col` < CAST(0 AS INT64) AND NOT CAST(1 AS INT64) = 1 + THEN CAST('NaN' AS FLOAT64) + WHEN `float64_col` <> CAST(0 AS INT64) AND 1 * LN(ABS(`float64_col`)) > 709.78 + THEN CAST('Infinity' AS FLOAT64) * CASE + WHEN `float64_col` < CAST(0 AS INT64) AND MOD(CAST(1 AS INT64), 2) = 1 + THEN -1 + ELSE 1 + END + ELSE POWER( + `float64_col`, + CASE + WHEN ABS(1) > 9007199254740992 + THEN CAST('Infinity' AS FLOAT64) * SIGN(1) ELSE 1 END - ELSE POWER( - `bfcol_86`, - CASE - WHEN ABS(1) > 9007199254740992 - THEN CAST('Infinity' AS FLOAT64) * SIGN(1) - ELSE 1 - END - ) - END AS `bfcol_114` - FROM `bfcte_7` -) -SELECT - `bfcol_104` AS `rowindex`, - `bfcol_105` AS `int64_col`, - `bfcol_106` AS `float64_col`, - `bfcol_107` AS `int_pow_int`, - `bfcol_108` AS `int_pow_float`, - `bfcol_109` AS `float_pow_int`, - `bfcol_110` AS `float_pow_float`, - `bfcol_111` AS `int_pow_0`, - `bfcol_112` AS `float_pow_0`, - `bfcol_113` AS `int_pow_1`, - `bfcol_114` AS `float_pow_1` -FROM `bfcte_8` \ No newline at end of file + ) + END AS `float_pow_1` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_round/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_round/out.sql index 9ce76f7c63f..2301645eb72 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_round/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_round/out.sql @@ -1,81 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `float64_col` AS `bfcol_8`, - CAST(ROUND(`int64_col`, 0) AS INT64) AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - CAST(ROUND(`bfcol_7`, 1) AS INT64) AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - CAST(ROUND(`bfcol_15`, -1) AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - ROUND(`bfcol_26`, 0) AS `bfcol_42` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - `bfcol_36` AS `bfcol_50`, - `bfcol_37` AS `bfcol_51`, - `bfcol_38` AS `bfcol_52`, - `bfcol_39` AS `bfcol_53`, - `bfcol_40` AS `bfcol_54`, - `bfcol_41` AS `bfcol_55`, - `bfcol_42` AS `bfcol_56`, - ROUND(`bfcol_38`, 1) AS `bfcol_57` - FROM `bfcte_4` -), `bfcte_6` AS ( - SELECT - *, - `bfcol_50` AS `bfcol_66`, - `bfcol_51` AS `bfcol_67`, - `bfcol_52` AS `bfcol_68`, - `bfcol_53` AS `bfcol_69`, - `bfcol_54` AS `bfcol_70`, - `bfcol_55` AS `bfcol_71`, - `bfcol_56` AS `bfcol_72`, - `bfcol_57` AS `bfcol_73`, - ROUND(`bfcol_52`, -1) AS `bfcol_74` - FROM `bfcte_5` -) SELECT - `bfcol_66` AS `rowindex`, - `bfcol_67` AS `int64_col`, - `bfcol_68` AS `float64_col`, - `bfcol_69` AS `int_round_0`, - `bfcol_70` AS `int_round_1`, - `bfcol_71` AS `int_round_m1`, - `bfcol_72` AS `float_round_0`, - `bfcol_73` AS `float_round_1`, - `bfcol_74` AS `float_round_m1` -FROM `bfcte_6` \ No newline at end of file + `rowindex`, + `int64_col`, + `float64_col`, + CAST(ROUND(`int64_col`, 0) AS INT64) AS `int_round_0`, + CAST(ROUND(`int64_col`, 1) AS INT64) AS `int_round_1`, + CAST(ROUND(`int64_col`, -1) AS INT64) AS `int_round_m1`, + ROUND(`float64_col`, 0) AS `float_round_0`, + ROUND(`float64_col`, 1) AS `float_round_1`, + ROUND(`float64_col`, -1) AS `float_round_m1` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 1699b6d8df8..04489505d1b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sin/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sin/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SIN(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + SIN(`float64_col`) AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 c1ea003e2d3..add574e772d 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`float64_col`) > 709.78 - THEN SIGN(`float64_col`) * CAST('Infinity' AS FLOAT64) - ELSE SINH(`float64_col`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN ABS(`float64_col`) > 709.78 + THEN SIGN(`float64_col`) * CAST('Infinity' AS FLOAT64) + ELSE SINH(`float64_col`) + END AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 152545d5505..e6d18871f92 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `float64_col` < 0 THEN CAST('NaN' AS FLOAT64) ELSE SQRT(`float64_col`) END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CASE WHEN `float64_col` < 0 THEN CAST('NaN' AS FLOAT64) ELSE SQRT(`float64_col`) END AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 7e0f07af7b7..dc95e3a28b1 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_numeric/out.sql @@ -1,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `bool_col` AS `bfcol_8`, - `int64_col` - `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` - 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` - CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) - `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_add_int`, - `bfcol_40` AS `int_add_1`, - `bfcol_41` AS `int_add_bool`, - `bfcol_42` AS `bool_add_int` -FROM `bfcte_4` \ No newline at end of file + `rowindex`, + `int64_col`, + `bool_col`, + `int64_col` - `int64_col` AS `int_add_int`, + `int64_col` - 1 AS `int_add_1`, + `int64_col` - CAST(`bool_col` AS INT64) AS `int_add_bool`, + CAST(`bool_col` AS INT64) - `int64_col` AS `bool_add_int` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_timedelta/out.sql index ebcffd67f61..8c53679af1d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_timedelta/out.sql @@ -1,82 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col`, - `duration_col`, - `rowindex`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_8`, - `timestamp_col` AS `bfcol_9`, - `date_col` AS `bfcol_10`, - `duration_col` AS `bfcol_11` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_11` AS `bfcol_18`, - `bfcol_10` AS `bfcol_19`, - TIMESTAMP_SUB(CAST(`bfcol_10` AS DATETIME), INTERVAL `bfcol_11` MICROSECOND) AS `bfcol_20` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_19` AS `bfcol_29`, - `bfcol_20` AS `bfcol_30`, - TIMESTAMP_SUB(`bfcol_17`, INTERVAL `bfcol_18` MICROSECOND) AS `bfcol_31` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - `bfcol_30` AS `bfcol_42`, - `bfcol_31` AS `bfcol_43`, - TIMESTAMP_DIFF(CAST(`bfcol_29` AS DATETIME), CAST(`bfcol_29` AS DATETIME), MICROSECOND) AS `bfcol_44` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - `bfcol_38` AS `bfcol_52`, - `bfcol_39` AS `bfcol_53`, - `bfcol_40` AS `bfcol_54`, - `bfcol_41` AS `bfcol_55`, - `bfcol_42` AS `bfcol_56`, - `bfcol_43` AS `bfcol_57`, - `bfcol_44` AS `bfcol_58`, - TIMESTAMP_DIFF(`bfcol_39`, `bfcol_39`, MICROSECOND) AS `bfcol_59` - FROM `bfcte_4` -), `bfcte_6` AS ( - SELECT - *, - `bfcol_52` AS `bfcol_68`, - `bfcol_53` AS `bfcol_69`, - `bfcol_54` AS `bfcol_70`, - `bfcol_55` AS `bfcol_71`, - `bfcol_56` AS `bfcol_72`, - `bfcol_57` AS `bfcol_73`, - `bfcol_58` AS `bfcol_74`, - `bfcol_59` AS `bfcol_75`, - `bfcol_54` - `bfcol_54` AS `bfcol_76` - FROM `bfcte_5` -) SELECT - `bfcol_68` AS `rowindex`, - `bfcol_69` AS `timestamp_col`, - `bfcol_70` AS `duration_col`, - `bfcol_71` AS `date_col`, - `bfcol_72` AS `date_sub_timedelta`, - `bfcol_73` AS `timestamp_sub_timedelta`, - `bfcol_74` AS `timestamp_sub_date`, - `bfcol_75` AS `date_sub_timestamp`, - `bfcol_76` AS `timedelta_sub_timedelta` -FROM `bfcte_6` \ No newline at end of file + `rowindex`, + `timestamp_col`, + `duration_col`, + `date_col`, + TIMESTAMP_SUB(CAST(`date_col` AS DATETIME), INTERVAL `duration_col` MICROSECOND) AS `date_sub_timedelta`, + TIMESTAMP_SUB(`timestamp_col`, INTERVAL `duration_col` MICROSECOND) AS `timestamp_sub_timedelta`, + TIMESTAMP_DIFF(CAST(`date_col` AS DATETIME), CAST(`date_col` AS DATETIME), MICROSECOND) AS `timestamp_sub_date`, + TIMESTAMP_DIFF(`timestamp_col`, `timestamp_col`, MICROSECOND) AS `date_sub_timestamp`, + `duration_col` - `duration_col` AS `timedelta_sub_timedelta` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 f09d26a188a..d00c5cb791f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_tan/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_tan/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TAN(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + TAN(`float64_col`) AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 a5e5a87fbc4..5d25fc32589 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TANH(`float64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + TANH(`float64_col`) AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_unsafe_pow_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_unsafe_pow_op/out.sql index 9957a346654..ab1e9663ced 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_unsafe_pow_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_unsafe_pow_op/out.sql @@ -1,43 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bool_col` AS `bfcol_3`, - `int64_col` AS `bfcol_4`, - `float64_col` AS `bfcol_5`, - ( - `int64_col` >= 0 - ) AND ( - `int64_col` <= 10 - ) AS `bfcol_6` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - * - FROM `bfcte_1` - WHERE - `bfcol_6` -), `bfcte_3` AS ( - SELECT - *, - POWER(`bfcol_4`, `bfcol_4`) AS `bfcol_14`, - POWER(`bfcol_4`, `bfcol_5`) AS `bfcol_15`, - POWER(`bfcol_5`, `bfcol_4`) AS `bfcol_16`, - POWER(`bfcol_5`, `bfcol_5`) AS `bfcol_17`, - POWER(`bfcol_4`, CAST(`bfcol_3` AS INT64)) AS `bfcol_18`, - POWER(CAST(`bfcol_3` AS INT64), `bfcol_4`) AS `bfcol_19` - FROM `bfcte_2` -) SELECT - `bfcol_14` AS `int_pow_int`, - `bfcol_15` AS `int_pow_float`, - `bfcol_16` AS `float_pow_int`, - `bfcol_17` AS `float_pow_float`, - `bfcol_18` AS `int_pow_bool`, - `bfcol_19` AS `bool_pow_int` -FROM `bfcte_3` \ No newline at end of file + POWER(`int64_col`, `int64_col`) AS `int_pow_int`, + POWER(`int64_col`, `float64_col`) AS `int_pow_float`, + POWER(`float64_col`, `int64_col`) AS `float_pow_int`, + POWER(`float64_col`, `float64_col`) AS `float_pow_float`, + POWER(`int64_col`, CAST(`bool_col` AS INT64)) AS `int_pow_bool`, + POWER(CAST(`bool_col` AS INT64), `int64_col`) AS `bool_pow_int` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +WHERE + ( + `int64_col` >= 0 + ) AND ( + `int64_col` <= 10 + ) \ 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 cb674787ff1..0031882bc70 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_add_string/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_add_string/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CONCAT(`string_col`, 'a') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CONCAT(`string_col`, 'a') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 dd1f1473f41..97c694aaa25 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - INITCAP(`string_col`, '') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + INITCAP(`string_col`, '') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 eeb25740946..0653a3fdc48 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_endswith/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_endswith/out.sql @@ -1,17 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ENDS_WITH(`string_col`, 'ab') AS `bfcol_1`, - ENDS_WITH(`string_col`, 'ab') OR ENDS_WITH(`string_col`, 'cd') AS `bfcol_2`, - FALSE AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `single`, - `bfcol_2` AS `double`, - `bfcol_3` AS `empty` -FROM `bfcte_1` \ No newline at end of file + ENDS_WITH(`string_col`, 'ab') AS `single`, + ENDS_WITH(`string_col`, 'ab') OR ENDS_WITH(`string_col`, 'cd') AS `double`, + FALSE AS `empty` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 61c2643f161..530888a7e00 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isalnum/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isalnum/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`string_col`, '^(\\p{N}|\\p{L})+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REGEXP_CONTAINS(`string_col`, '^(\\p{N}|\\p{L})+$') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 2b086f3e3d9..0e48876157c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isalpha/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isalpha/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`string_col`, '^\\p{L}+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REGEXP_CONTAINS(`string_col`, '^\\p{L}+$') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 d4dddc348f0..fa47e342bb1 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isdecimal/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isdecimal/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`string_col`, '^(\\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(`string_col`, '^(\\p{Nd})+$') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 eba0e51ed09..66a2f8175a7 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,16 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS( - `string_col`, - '^[\\p{Nd}\\x{00B9}\\x{00B2}\\x{00B3}\\x{2070}\\x{2074}-\\x{2079}\\x{2080}-\\x{2089}]+$' - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REGEXP_CONTAINS( + `string_col`, + '^[\\p{Nd}\\x{00B9}\\x{00B2}\\x{00B3}\\x{2070}\\x{2074}-\\x{2079}\\x{2080}-\\x{2089}]+$' + ) AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 b6ff57797c6..861687a301b 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LOWER(`string_col`) = `string_col` AND UPPER(`string_col`) <> `string_col` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + LOWER(`string_col`) = `string_col` AND UPPER(`string_col`) <> `string_col` AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 6143b3685a2..c23fb577bac 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isnumeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isnumeric/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`string_col`, '^\\pN+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REGEXP_CONTAINS(`string_col`, '^\\pN+$') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 47ccd642d40..f38be0bfbc4 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isspace/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_isspace/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`string_col`, '^\\s+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REGEXP_CONTAINS(`string_col`, '^\\s+$') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 54f7b55ce3d..d08f2550529 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UPPER(`string_col`) = `string_col` AND LOWER(`string_col`) <> `string_col` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + UPPER(`string_col`) = `string_col` AND LOWER(`string_col`) <> `string_col` AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 63e8e160bfc..0f5bb072d77 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LENGTH(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + LENGTH(`string_col`) AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len_w_array/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len_w_array/out.sql index 609c4131e65..bbef05c6737 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len_w_array/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len_w_array/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY_LENGTH(`int_list_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int_list_col` -FROM `bfcte_1` \ No newline at end of file + ARRAY_LENGTH(`int_list_col`) AS `int_list_col` +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ 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 0a9623162aa..80b7fd8a589 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_lower/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_lower/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LOWER(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + LOWER(`string_col`) AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 1b73ee32585..d76f4dee73d 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LTRIM(`string_col`, ' ') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + LTRIM(`string_col`, ' ') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 2fd3365a803..0146ddf4c4a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_regex_replace_str/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_regex_replace_str/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_REPLACE(`string_col`, 'e', 'a') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REGEXP_REPLACE(`string_col`, 'e', 'a') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 61b2e2f432d..c3851a294fd 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_replace_str/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_replace_str/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REPLACE(`string_col`, 'e', 'a') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REPLACE(`string_col`, 'e', 'a') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 f9d287a5917..6c919b52e07 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_reverse/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_reverse/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REVERSE(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REVERSE(`string_col`) AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 72bdbba29f1..67c6030b416 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - RTRIM(`string_col`, ' ') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + RTRIM(`string_col`, ' ') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 54c8adb7b86..b0e1f77ad00 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_startswith/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_startswith/out.sql @@ -1,17 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - STARTS_WITH(`string_col`, 'ab') AS `bfcol_1`, - STARTS_WITH(`string_col`, 'ab') OR STARTS_WITH(`string_col`, 'cd') AS `bfcol_2`, - FALSE AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `single`, - `bfcol_2` AS `double`, - `bfcol_3` AS `empty` -FROM `bfcte_1` \ No newline at end of file + STARTS_WITH(`string_col`, 'ab') AS `single`, + STARTS_WITH(`string_col`, 'ab') OR STARTS_WITH(`string_col`, 'cd') AS `double`, + FALSE AS `empty` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 e973a97136b..c8a5d766ef6 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_contains/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_contains/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `string_col` LIKE '%e%' AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + `string_col` LIKE '%e%' AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 510e52e254c..e32010f9e4b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_contains_regex/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_contains_regex/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`string_col`, 'e') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REGEXP_CONTAINS(`string_col`, 'e') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 3a6d48a18c5..96552cc7326 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,23 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - IF( - REGEXP_CONTAINS(`string_col`, '([a-z]*)'), - REGEXP_REPLACE(`string_col`, CONCAT('.*?(', '([a-z]*)', ').*'), '\\1'), - NULL - ) AS `bfcol_1`, - IF( - REGEXP_CONTAINS(`string_col`, '([a-z]*)'), - REGEXP_REPLACE(`string_col`, CONCAT('.*?', '([a-z]*)', '.*'), '\\1'), - NULL - ) AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `zero`, - `bfcol_2` AS `one` -FROM `bfcte_1` \ No newline at end of file + IF( + REGEXP_CONTAINS(`string_col`, '([a-z]*)'), + REGEXP_REPLACE(`string_col`, CONCAT('.*?(', '([a-z]*)', ').*'), '\\1'), + NULL + ) AS `zero`, + IF( + REGEXP_CONTAINS(`string_col`, '([a-z]*)'), + REGEXP_REPLACE(`string_col`, CONCAT('.*?', '([a-z]*)', '.*'), '\\1'), + NULL + ) AS `one` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_find/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_find/out.sql index 82847d5e22c..79a5f7c6388 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_find/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_find/out.sql @@ -1,19 +1,6 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - INSTR(`string_col`, 'e', 1) - 1 AS `bfcol_1`, - INSTR(`string_col`, 'e', 3) - 1 AS `bfcol_2`, - INSTR(SUBSTRING(`string_col`, 1, 5), 'e') - 1 AS `bfcol_3`, - INSTR(SUBSTRING(`string_col`, 3, 3), 'e') - 1 AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `none_none`, - `bfcol_2` AS `start_none`, - `bfcol_3` AS `none_end`, - `bfcol_4` AS `start_end` -FROM `bfcte_1` \ No newline at end of file + INSTR(`string_col`, 'e', 1) - 1 AS `none_none`, + INSTR(`string_col`, 'e', 3) - 1 AS `start_none`, + INSTR(SUBSTRING(`string_col`, 1, 5), 'e') - 1 AS `none_end`, + INSTR(SUBSTRING(`string_col`, 3, 3), 'e') - 1 AS `start_end` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 f868b730327..f2717ede36b 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - IF(SUBSTRING(`string_col`, 2, 1) <> '', SUBSTRING(`string_col`, 2, 1), NULL) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + IF(SUBSTRING(`string_col`, 2, 1) <> '', SUBSTRING(`string_col`, 2, 1), NULL) AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 2bb6042fe99..12ea103743a 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,13 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LPAD(`string_col`, GREATEST(LENGTH(`string_col`), 10), '-') AS `bfcol_1`, - RPAD(`string_col`, GREATEST(LENGTH(`string_col`), 10), '-') AS `bfcol_2`, - RPAD( - LPAD( - `string_col`, - CAST(FLOOR(SAFE_DIVIDE(GREATEST(LENGTH(`string_col`), 10) - LENGTH(`string_col`), 2)) AS INT64) + LENGTH(`string_col`), - '-' - ), - GREATEST(LENGTH(`string_col`), 10), - '-' - ) AS `bfcol_3` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `left`, - `bfcol_2` AS `right`, - `bfcol_3` AS `both` -FROM `bfcte_1` \ No newline at end of file + LPAD(`string_col`, GREATEST(LENGTH(`string_col`), 10), '-') AS `left`, + RPAD(`string_col`, GREATEST(LENGTH(`string_col`), 10), '-') AS `right`, + RPAD( + LPAD( + `string_col`, + CAST(FLOOR(SAFE_DIVIDE(GREATEST(LENGTH(`string_col`), 10) - LENGTH(`string_col`), 2)) AS INT64) + LENGTH(`string_col`), + '-' + ), + GREATEST(LENGTH(`string_col`), 10), + '-' + ) AS `both` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 90a52a40b14..9ad03238efa 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_repeat/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_repeat/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REPEAT(`string_col`, 2) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + REPEAT(`string_col`, 2) AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 8bd2a5f7feb..c0d5886a940 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SUBSTRING(`string_col`, 2, 2) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + SUBSTRING(`string_col`, 2, 2) AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strconcat/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strconcat/out.sql index cb674787ff1..0031882bc70 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strconcat/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strconcat/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CONCAT(`string_col`, 'a') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CONCAT(`string_col`, 'a') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 37b15a0cf91..ca8c4f1d61b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_string_split/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_string_split/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SPLIT(`string_col`, ',') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + SPLIT(`string_col`, ',') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 ebe4c39bbf5..5bf171c0ba0 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,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TRIM(`string_col`, ' ') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + TRIM(`string_col`, ' ') AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 aa14c5f05d8..8e6b2ba657a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_upper/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_upper/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UPPER(`string_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + UPPER(`string_col`) AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 79c4f695aaf..0cfd70950e4 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN STARTS_WITH(`string_col`, '-') - THEN CONCAT('-', LPAD(SUBSTRING(`string_col`, 2), GREATEST(LENGTH(`string_col`), 10) - 1, '0')) - ELSE LPAD(`string_col`, GREATEST(LENGTH(`string_col`), 10), '0') - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CASE + WHEN STARTS_WITH(`string_col`, '-') + THEN CONCAT('-', LPAD(SUBSTRING(`string_col`, 2), GREATEST(LENGTH(`string_col`), 10) - 1, '0')) + ELSE LPAD(`string_col`, GREATEST(LENGTH(`string_col`), 10), '0') + END AS `string_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 b85e88a90a5..de60033454b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_field/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_field/out.sql @@ -1,15 +1,4 @@ -WITH `bfcte_0` AS ( - SELECT - `people` - FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` -), `bfcte_1` AS ( - SELECT - *, - `people`.`name` AS `bfcol_1`, - `people`.`name` AS `bfcol_2` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string`, - `bfcol_2` AS `int` -FROM `bfcte_1` \ No newline at end of file + `people`.`name` AS `string`, + `people`.`name` AS `int` +FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_op/out.sql index 575a1620806..56024b50fc9 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_op/out.sql @@ -1,21 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_col`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - STRUCT( - `bool_col` AS bool_col, - `int64_col` AS int64_col, - `float64_col` AS float64_col, - `string_col` AS string_col - ) AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `result_col` -FROM `bfcte_1` \ No newline at end of file + STRUCT( + `bool_col` AS bool_col, + `int64_col` AS int64_col, + `float64_col` AS float64_col, + `string_col` AS string_col + ) AS `result_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 432aefd7f69..362a958b62e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_timedelta_ops/test_timedelta_floor/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_timedelta_ops/test_timedelta_floor/out.sql @@ -1,13 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FLOOR(`int64_col`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + FLOOR(`int64_col`) AS `int64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 ed7dbc7c8a9..109f72f0dc1 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,54 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `float64_col` AS `bfcol_8`, - `int64_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - CAST(FLOOR(`bfcol_8` * 1000000) AS INT64) AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` * 3600000000 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`, - `bfcol_27` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `float64_col`, - `bfcol_39` AS `duration_us`, - `bfcol_40` AS `duration_s`, - `bfcol_41` AS `duration_w`, - `bfcol_42` AS `duration_on_duration` -FROM `bfcte_4` \ No newline at end of file + `rowindex`, + `int64_col`, + `float64_col`, + `int64_col` AS `duration_us`, + CAST(FLOOR(`float64_col` * 1000000) AS INT64) AS `duration_s`, + `int64_col` * 3600000000 AS `duration_w`, + `int64_col` AS `duration_on_duration` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ 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 949ed82574d..153ff1e03a4 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,19 +1,15 @@ WITH `bfcte_0` AS ( SELECT `bool_col`, - `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, + `int64_too`, `int64_too` AS `bfcol_2`, `bool_col` AS `bfcol_3` - FROM `bfcte_0` -), `bfcte_2` AS ( + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +), `bfcte_1` AS ( SELECT `bfcol_3`, COALESCE(SUM(`bfcol_2`), 0) AS `bfcol_6` - FROM `bfcte_1` + FROM `bfcte_0` WHERE NOT `bfcol_3` IS NULL GROUP BY @@ -22,6 +18,6 @@ WITH `bfcte_0` AS ( SELECT `bfcol_3` AS `bool_col`, `bfcol_6` AS `int64_too` -FROM `bfcte_2` +FROM `bfcte_1` ORDER BY `bfcol_3` 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 3c09250858d..4a9fd5374d3 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate_wo_dropna/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate_wo_dropna/out.sql @@ -1,25 +1,21 @@ WITH `bfcte_0` AS ( SELECT `bool_col`, - `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, + `int64_too`, `int64_too` AS `bfcol_2`, `bool_col` AS `bfcol_3` - FROM `bfcte_0` -), `bfcte_2` AS ( + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +), `bfcte_1` AS ( SELECT `bfcol_3`, COALESCE(SUM(`bfcol_2`), 0) AS `bfcol_6` - FROM `bfcte_1` + FROM `bfcte_0` GROUP BY `bfcol_3` ) SELECT `bfcol_3` AS `bool_col`, `bfcol_6` AS `int64_too` -FROM `bfcte_2` +FROM `bfcte_1` ORDER BY `bfcol_3` 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 db1da10086f..efa7c6cbe95 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,36 +1,4 @@ -WITH `bfcte_1` AS ( - SELECT - `int64_col`, - `rowindex`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( - SELECT - *, - ROW_NUMBER() OVER () - 1 AS `bfcol_7` - FROM `bfcte_1` -), `bfcte_5` AS ( - SELECT - *, - 0 AS `bfcol_8` - FROM `bfcte_3` -), `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - *, - ROW_NUMBER() OVER () - 1 AS `bfcol_22` - FROM `bfcte_0` -), `bfcte_4` AS ( - SELECT - *, - 1 AS `bfcol_23` - FROM `bfcte_2` -), `bfcte_6` AS ( +WITH `bfcte_0` AS ( SELECT `bfcol_9` AS `bfcol_30`, `bfcol_10` AS `bfcol_31`, @@ -45,9 +13,9 @@ WITH `bfcte_1` AS ( `rowindex` AS `bfcol_10`, `int64_col` AS `bfcol_11`, `string_col` AS `bfcol_12`, - `bfcol_8` AS `bfcol_13`, - `bfcol_7` AS `bfcol_14` - FROM `bfcte_5` + 0 AS `bfcol_13`, + ROW_NUMBER() OVER () - 1 AS `bfcol_14` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` ) UNION ALL ( @@ -56,9 +24,9 @@ WITH `bfcte_1` AS ( `rowindex` AS `bfcol_25`, `int64_col` AS `bfcol_26`, `string_col` AS `bfcol_27`, - `bfcol_23` AS `bfcol_28`, - `bfcol_22` AS `bfcol_29` - FROM `bfcte_4` + 1 AS `bfcol_28`, + ROW_NUMBER() OVER () - 1 AS `bfcol_29` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` ) ) ) @@ -67,7 +35,7 @@ SELECT `bfcol_31` AS `rowindex_1`, `bfcol_32` AS `int64_col`, `bfcol_33` AS `string_col` -FROM `bfcte_6` +FROM `bfcte_0` ORDER BY `bfcol_34` ASC NULLS LAST, `bfcol_35` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat_filter_sorted/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat_filter_sorted/out.sql index 65b0f9abd5e..82534292032 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat_filter_sorted/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat_filter_sorted/out.sql @@ -1,72 +1,4 @@ -WITH `bfcte_2` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_6` AS ( - SELECT - *, - ROW_NUMBER() OVER (ORDER BY `int64_col` ASC NULLS LAST) - 1 AS `bfcol_4` - FROM `bfcte_2` -), `bfcte_10` AS ( - SELECT - *, - 0 AS `bfcol_5` - FROM `bfcte_6` -), `bfcte_0` AS ( - SELECT - `bool_col`, - `float64_col`, - `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_4` AS ( - SELECT - * - FROM `bfcte_0` - WHERE - `bool_col` -), `bfcte_8` AS ( - SELECT - *, - ROW_NUMBER() OVER () - 1 AS `bfcol_15` - FROM `bfcte_4` -), `bfcte_12` AS ( - SELECT - *, - 1 AS `bfcol_16` - FROM `bfcte_8` -), `bfcte_1` AS ( - SELECT - `float64_col`, - `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_5` AS ( - SELECT - *, - ROW_NUMBER() OVER (ORDER BY `int64_col` ASC NULLS LAST) - 1 AS `bfcol_25` - FROM `bfcte_1` -), `bfcte_9` AS ( - SELECT - *, - 2 AS `bfcol_26` - FROM `bfcte_5` -), `bfcte_3` AS ( - SELECT - * - FROM `bfcte_0` - WHERE - `bool_col` -), `bfcte_7` AS ( - SELECT - *, - ROW_NUMBER() OVER () - 1 AS `bfcol_36` - FROM `bfcte_3` -), `bfcte_11` AS ( - SELECT - *, - 3 AS `bfcol_37` - FROM `bfcte_7` -), `bfcte_13` AS ( +WITH `bfcte_0` AS ( SELECT `bfcol_6` AS `bfcol_42`, `bfcol_7` AS `bfcol_43`, @@ -77,43 +9,47 @@ WITH `bfcte_2` AS ( SELECT `float64_col` AS `bfcol_6`, `int64_col` AS `bfcol_7`, - `bfcol_5` AS `bfcol_8`, - `bfcol_4` AS `bfcol_9` - FROM `bfcte_10` + 0 AS `bfcol_8`, + ROW_NUMBER() OVER (ORDER BY `int64_col` ASC NULLS LAST) - 1 AS `bfcol_9` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` ) UNION ALL ( SELECT `float64_col` AS `bfcol_17`, `int64_too` AS `bfcol_18`, - `bfcol_16` AS `bfcol_19`, - `bfcol_15` AS `bfcol_20` - FROM `bfcte_12` + 1 AS `bfcol_19`, + ROW_NUMBER() OVER () - 1 AS `bfcol_20` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + WHERE + `bool_col` ) UNION ALL ( SELECT `float64_col` AS `bfcol_27`, `int64_col` AS `bfcol_28`, - `bfcol_26` AS `bfcol_29`, - `bfcol_25` AS `bfcol_30` - FROM `bfcte_9` + 2 AS `bfcol_29`, + ROW_NUMBER() OVER (ORDER BY `int64_col` ASC NULLS LAST) - 1 AS `bfcol_30` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` ) UNION ALL ( SELECT `float64_col` AS `bfcol_38`, `int64_too` AS `bfcol_39`, - `bfcol_37` AS `bfcol_40`, - `bfcol_36` AS `bfcol_41` - FROM `bfcte_11` + 3 AS `bfcol_40`, + ROW_NUMBER() OVER () - 1 AS `bfcol_41` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + WHERE + `bool_col` ) ) ) SELECT `bfcol_42` AS `float64_col`, `bfcol_43` AS `int64_col` -FROM `bfcte_13` +FROM `bfcte_0` ORDER BY `bfcol_44` ASC NULLS LAST, `bfcol_45` 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 f5fff16f602..062e02c24c5 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_filter/test_compile_filter/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_filter/test_compile_filter/out.sql @@ -1,25 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_5`, - `rowindex` AS `bfcol_6`, - `int64_col` AS `bfcol_7`, - `rowindex` >= 1 AS `bfcol_8` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - * - FROM `bfcte_1` - WHERE - `bfcol_8` -) SELECT - `bfcol_5` AS `rowindex`, - `bfcol_6` AS `rowindex_1`, - `bfcol_7` AS `int64_col` -FROM `bfcte_2` \ No newline at end of file + `rowindex`, + `rowindex` AS `rowindex_1`, + `int64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +WHERE + `rowindex` >= 1 \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_regionstats/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_regionstats/out.sql index 63076077cf5..457436e98c4 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_regionstats/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_regionstats/out.sql @@ -2,35 +2,50 @@ WITH `bfcte_0` AS ( SELECT * FROM UNNEST(ARRAY>[STRUCT('POINT(1 1)', 0)]) -), `bfcte_1` AS ( - SELECT - *, - ST_REGIONSTATS( - `bfcol_0`, - 'ee://some/raster/uri', - band => 'band1', - include => 'some equation', - options => JSON '{"scale": 100}' - ) AS `bfcol_2` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_2`.`min` AS `bfcol_5`, - `bfcol_2`.`max` AS `bfcol_6`, - `bfcol_2`.`sum` AS `bfcol_7`, - `bfcol_2`.`count` AS `bfcol_8`, - `bfcol_2`.`mean` AS `bfcol_9`, - `bfcol_2`.`area` AS `bfcol_10` - FROM `bfcte_1` ) SELECT - `bfcol_5` AS `min`, - `bfcol_6` AS `max`, - `bfcol_7` AS `sum`, - `bfcol_8` AS `count`, - `bfcol_9` AS `mean`, - `bfcol_10` AS `area` -FROM `bfcte_2` + ST_REGIONSTATS( + `bfcol_0`, + 'ee://some/raster/uri', + band => 'band1', + include => 'some equation', + options => JSON '{"scale": 100}' + ).`min`, + ST_REGIONSTATS( + `bfcol_0`, + 'ee://some/raster/uri', + band => 'band1', + include => 'some equation', + options => JSON '{"scale": 100}' + ).`max`, + ST_REGIONSTATS( + `bfcol_0`, + 'ee://some/raster/uri', + band => 'band1', + include => 'some equation', + options => JSON '{"scale": 100}' + ).`sum`, + ST_REGIONSTATS( + `bfcol_0`, + 'ee://some/raster/uri', + band => 'band1', + include => 'some equation', + options => JSON '{"scale": 100}' + ).`count`, + ST_REGIONSTATS( + `bfcol_0`, + 'ee://some/raster/uri', + band => 'band1', + include => 'some equation', + options => JSON '{"scale": 100}' + ).`mean`, + ST_REGIONSTATS( + `bfcol_0`, + 'ee://some/raster/uri', + band => 'band1', + include => 'some equation', + options => JSON '{"scale": 100}' + ).`area` +FROM `bfcte_0` ORDER BY `bfcol_1` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_regionstats_without_optional_args/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_regionstats_without_optional_args/out.sql index f7947119611..410909d80c5 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_regionstats_without_optional_args/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_regionstats_without_optional_args/out.sql @@ -2,29 +2,14 @@ WITH `bfcte_0` AS ( SELECT * FROM UNNEST(ARRAY>[STRUCT('POINT(1 1)', 0)]) -), `bfcte_1` AS ( - SELECT - *, - ST_REGIONSTATS(`bfcol_0`, 'ee://some/raster/uri') AS `bfcol_2` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_2`.`min` AS `bfcol_5`, - `bfcol_2`.`max` AS `bfcol_6`, - `bfcol_2`.`sum` AS `bfcol_7`, - `bfcol_2`.`count` AS `bfcol_8`, - `bfcol_2`.`mean` AS `bfcol_9`, - `bfcol_2`.`area` AS `bfcol_10` - FROM `bfcte_1` ) SELECT - `bfcol_5` AS `min`, - `bfcol_6` AS `max`, - `bfcol_7` AS `sum`, - `bfcol_8` AS `count`, - `bfcol_9` AS `mean`, - `bfcol_10` AS `area` -FROM `bfcte_2` + ST_REGIONSTATS(`bfcol_0`, 'ee://some/raster/uri').`min`, + ST_REGIONSTATS(`bfcol_0`, 'ee://some/raster/uri').`max`, + ST_REGIONSTATS(`bfcol_0`, 'ee://some/raster/uri').`sum`, + ST_REGIONSTATS(`bfcol_0`, 'ee://some/raster/uri').`count`, + ST_REGIONSTATS(`bfcol_0`, 'ee://some/raster/uri').`mean`, + ST_REGIONSTATS(`bfcol_0`, 'ee://some/raster/uri').`area` +FROM `bfcte_0` ORDER BY `bfcol_1` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_simplify/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_simplify/out.sql index b8dd1587a86..1c146e1e1be 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_simplify/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_simplify/out.sql @@ -2,14 +2,9 @@ WITH `bfcte_0` AS ( SELECT * FROM UNNEST(ARRAY>[STRUCT('POINT(1 1)', 0)]) -), `bfcte_1` AS ( - SELECT - *, - ST_SIMPLIFY(`bfcol_0`, 123.125) AS `bfcol_2` - FROM `bfcte_0` ) SELECT - `bfcol_2` AS `0` -FROM `bfcte_1` + ST_SIMPLIFY(`bfcol_0`, 123.125) AS `0` +FROM `bfcte_0` ORDER BY `bfcol_1` ASC NULLS LAST \ 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 77aef6ad8bb..410b400f920 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_isin/test_compile_isin/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_isin/test_compile_isin/out.sql @@ -1,41 +1,36 @@ -WITH `bfcte_1` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +WITH `bfcte_2` AS ( SELECT `rowindex` AS `bfcol_2`, `int64_col` AS `bfcol_3` - FROM `bfcte_1` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` ), `bfcte_0` AS ( SELECT `int64_too` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( +), `bfcte_1` AS ( SELECT `int64_too` FROM `bfcte_0` GROUP BY `int64_too` -), `bfcte_4` AS ( +), `bfcte_3` AS ( SELECT - `bfcte_3`.*, + `bfcte_2`.*, EXISTS( SELECT 1 FROM ( SELECT `int64_too` AS `bfcol_4` - FROM `bfcte_2` + FROM `bfcte_1` ) AS `bft_0` WHERE - COALESCE(`bfcte_3`.`bfcol_3`, 0) = COALESCE(`bft_0`.`bfcol_4`, 0) - AND COALESCE(`bfcte_3`.`bfcol_3`, 1) = COALESCE(`bft_0`.`bfcol_4`, 1) + 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_3` + FROM `bfcte_2` ) SELECT `bfcol_2` AS `rowindex`, `bfcol_5` AS `int64_col` -FROM `bfcte_4` \ No newline at end of file +FROM `bfcte_3` \ 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 8089c5b462b..61d4185a0d1 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_isin/test_compile_isin_not_nullable/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_isin/test_compile_isin_not_nullable/out.sql @@ -1,34 +1,29 @@ -WITH `bfcte_1` AS ( - SELECT - `rowindex`, - `rowindex_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +WITH `bfcte_2` AS ( SELECT `rowindex` AS `bfcol_2`, `rowindex_2` AS `bfcol_3` - FROM `bfcte_1` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` ), `bfcte_0` AS ( SELECT `rowindex_2` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( +), `bfcte_1` AS ( SELECT `rowindex_2` FROM `bfcte_0` GROUP BY `rowindex_2` -), `bfcte_4` AS ( +), `bfcte_3` AS ( SELECT - `bfcte_3`.*, - `bfcte_3`.`bfcol_3` IN (( + `bfcte_2`.*, + `bfcte_2`.`bfcol_3` IN (( SELECT `rowindex_2` AS `bfcol_4` - FROM `bfcte_2` + FROM `bfcte_1` )) AS `bfcol_5` - FROM `bfcte_3` + FROM `bfcte_2` ) SELECT `bfcol_2` AS `rowindex`, `bfcol_5` AS `rowindex_2` -FROM `bfcte_4` \ No newline at end of file +FROM `bfcte_3` \ 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 3a7ff60d3ee..baddb66b09d 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,22 @@ -WITH `bfcte_1` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( +WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_2`, `int64_col` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `int64_col`, - `int64_too` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +), `bfcte_1` AS ( SELECT `int64_col` AS `bfcol_6`, `int64_too` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +), `bfcte_2` AS ( SELECT * - FROM `bfcte_2` - LEFT JOIN `bfcte_3` + FROM `bfcte_0` + LEFT JOIN `bfcte_1` 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 +FROM `bfcte_2` \ 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 30f363e900e..8f55e7a6ef8 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,28 +1,18 @@ -WITH `bfcte_1` AS ( - SELECT - `bool_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( +WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_2`, `bool_col` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `bool_col`, - `rowindex` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +), `bfcte_1` AS ( SELECT `rowindex` AS `bfcol_6`, `bool_col` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +), `bfcte_2` AS ( SELECT * - FROM `bfcte_2` - INNER JOIN `bfcte_3` + FROM `bfcte_0` + INNER JOIN `bfcte_1` 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') ) @@ -30,4 +20,4 @@ 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 +FROM `bfcte_2` \ 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 9fa7673fb31..1bf5912bce6 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,28 +1,18 @@ -WITH `bfcte_1` AS ( - SELECT - `float64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( +WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_2`, `float64_col` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `float64_col`, - `rowindex` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +), `bfcte_1` AS ( SELECT `rowindex` AS `bfcol_6`, `float64_col` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +), `bfcte_2` AS ( SELECT * - FROM `bfcte_2` - INNER JOIN `bfcte_3` + FROM `bfcte_0` + INNER JOIN `bfcte_1` 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)) ) @@ -30,4 +20,4 @@ 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 +FROM `bfcte_2` \ 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 c9fca069d6a..3e0f105a7be 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,28 +1,18 @@ -WITH `bfcte_1` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( +WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_2`, `int64_col` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +), `bfcte_1` AS ( SELECT `rowindex` AS `bfcol_6`, `int64_col` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +), `bfcte_2` AS ( SELECT * - FROM `bfcte_2` - INNER JOIN `bfcte_3` + FROM `bfcte_0` + INNER JOIN `bfcte_1` ON COALESCE(`bfcol_3`, 0) = COALESCE(`bfcol_7`, 0) AND COALESCE(`bfcol_3`, 1) = COALESCE(`bfcol_7`, 1) ) @@ -30,4 +20,4 @@ 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 +FROM `bfcte_2` \ 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 88649c65188..b2481e07ace 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,28 +1,18 @@ -WITH `bfcte_1` AS ( - SELECT - `numeric_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( +WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_2`, `numeric_col` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `numeric_col`, - `rowindex` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +), `bfcte_1` AS ( SELECT `rowindex` AS `bfcol_6`, `numeric_col` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +), `bfcte_2` AS ( SELECT * - FROM `bfcte_2` - INNER JOIN `bfcte_3` + FROM `bfcte_0` + INNER JOIN `bfcte_1` 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)) ) @@ -30,4 +20,4 @@ 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 +FROM `bfcte_2` \ 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 8758ec8340e..f804b0d1f87 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,18 @@ -WITH `bfcte_1` AS ( - SELECT - `rowindex`, - `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( +WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_0`, `string_col` AS `bfcol_1` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `rowindex`, - `string_col` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +), `bfcte_1` AS ( SELECT `rowindex` AS `bfcol_4`, `string_col` AS `bfcol_5` - FROM `bfcte_0` -), `bfcte_4` AS ( + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +), `bfcte_2` AS ( SELECT * - FROM `bfcte_2` - INNER JOIN `bfcte_3` + FROM `bfcte_0` + INNER JOIN `bfcte_1` 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') ) @@ -30,4 +20,4 @@ SELECT `bfcol_0` AS `rowindex_x`, `bfcol_1` AS `string_col`, `bfcol_4` AS `rowindex_y` -FROM `bfcte_4` \ No newline at end of file +FROM `bfcte_2` \ 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 42fc15cd1d4..8fc9e135eee 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,18 @@ -WITH `bfcte_1` AS ( - SELECT - `rowindex`, - `time_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( +WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_0`, `time_col` AS `bfcol_1` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `rowindex`, - `time_col` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +), `bfcte_1` AS ( SELECT `rowindex` AS `bfcol_4`, `time_col` AS `bfcol_5` - FROM `bfcte_0` -), `bfcte_4` AS ( + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +), `bfcte_2` AS ( SELECT * - FROM `bfcte_2` - INNER JOIN `bfcte_3` + FROM `bfcte_0` + INNER JOIN `bfcte_1` 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') ) @@ -30,4 +20,4 @@ SELECT `bfcol_0` AS `rowindex_x`, `bfcol_1` AS `time_col`, `bfcol_4` AS `rowindex_y` -FROM `bfcte_4` \ No newline at end of file +FROM `bfcte_2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_random_sample/test_compile_random_sample/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_random_sample/test_compile_random_sample/out.sql index aae34716d86..2f80d6ffbcc 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_random_sample/test_compile_random_sample/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_random_sample/test_compile_random_sample/out.sql @@ -1,7 +1,6 @@ WITH `bfcte_0` AS ( SELECT - *, - RAND() AS `bfcol_16` + * FROM UNNEST(ARRAY>[STRUCT( TRUE, CAST(b'Hello, World!' AS BYTES), @@ -161,7 +160,7 @@ WITH `bfcte_0` AS ( * FROM `bfcte_0` WHERE - `bfcol_16` < 0.1 + RAND() < 0.1 ) SELECT `bfcol_0` AS `bool_col`, 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 959a31a2a35..e0f6e7f3d2e 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,22 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `bytes_col`, - `date_col`, - `datetime_col`, - `duration_col`, - `float64_col`, - `geography_col`, - `int64_col`, - `int64_too`, - `numeric_col`, - `rowindex`, - `rowindex_2`, - `string_col`, - `time_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -) SELECT `rowindex`, `bool_col`, @@ -34,4 +15,4 @@ SELECT `time_col`, `timestamp_col`, `duration_col` -FROM `bfcte_0` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_columns_filters/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_columns_filters/out.sql index 0d8a10c9566..c9a42b73f1a 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_columns_filters/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_columns_filters/out.sql @@ -1,8 +1,6 @@ WITH `bfcte_0` AS ( SELECT - `int64_col`, - `rowindex`, - `string_col` + * FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` WHERE `rowindex` > 0 AND `string_col` IN ('Hello, World!') 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 4b5750d7aaf..f65f3a10f0f 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,4 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -) SELECT `rowindex`, `json_col` -FROM `bfcte_0` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ 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 856c7061dac..90ad5b0186f 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,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -) SELECT `rowindex`, `int64_col` -FROM `bfcte_0` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` 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 79ae1ac9072..678b3b694f0 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_nested_structs_types/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_nested_structs_types/out.sql @@ -1,11 +1,5 @@ -WITH `bfcte_0` AS ( - SELECT - `id`, - `people` - FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` -) SELECT `id`, `id` AS `id_1`, `people` -FROM `bfcte_0` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` \ 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 edb8d7fbf4b..fb114c50e81 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,6 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -) SELECT `rowindex`, `int64_col` -FROM `bfcte_0` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` 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 a22c845ef1c..41f0d13d4fd 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,15 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_list_col`, - `date_list_col`, - `date_time_list_col`, - `float_list_col`, - `int_list_col`, - `numeric_list_col`, - `rowindex`, - `string_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -) SELECT `rowindex`, `rowindex` AS `rowindex_1`, @@ -20,4 +8,4 @@ SELECT `date_time_list_col`, `numeric_list_col`, `string_list_col` -FROM `bfcte_0` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql index 59c36870803..d188899e7c2 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql @@ -1,22 +1,3 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `bytes_col`, - `date_col`, - `datetime_col`, - `duration_col`, - `float64_col`, - `geography_col`, - `int64_col`, - `int64_too`, - `numeric_col`, - `rowindex`, - `rowindex_2`, - `string_col`, - `time_col`, - `timestamp_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` FOR SYSTEM_TIME AS OF '2025-11-09T03:04:05.678901+00:00' -) SELECT `bool_col`, `bytes_col`, @@ -33,4 +14,4 @@ SELECT `time_col`, `timestamp_col`, `duration_col` -FROM `bfcte_0` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` FOR SYSTEM_TIME AS OF '2025-11-09T03:04:05.678901+00:00' \ 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 0dca6d9d49e..155b7fae20f 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,55 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col`, - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `rowindex` AS `bfcol_6`, - `bool_col` AS `bfcol_7`, - `int64_col` AS `bfcol_8`, - `bool_col` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - * - FROM `bfcte_1` - WHERE - NOT `bfcol_9` IS NULL -), `bfcte_3` AS ( - SELECT - *, - CASE - WHEN COALESCE( - SUM(CAST(NOT `bfcol_7` IS NULL AS INT64)) OVER ( - PARTITION BY `bfcol_9` - ORDER BY `bfcol_9` ASC NULLS LAST, `rowindex` ASC NULLS LAST - ROWS BETWEEN 3 PRECEDING AND CURRENT ROW - ), - 0 - ) < 3 - THEN NULL - ELSE COALESCE( - SUM(CAST(`bfcol_7` AS INT64)) OVER ( - PARTITION BY `bfcol_9` - ORDER BY `bfcol_9` ASC NULLS LAST, `rowindex` ASC NULLS LAST - ROWS BETWEEN 3 PRECEDING AND CURRENT ROW - ), - 0 - ) - END AS `bfcol_15` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - CASE - WHEN COALESCE( - SUM(CAST(NOT `bfcol_8` IS NULL AS INT64)) OVER ( - PARTITION BY `bfcol_9` - ORDER BY `bfcol_9` ASC NULLS LAST, `rowindex` ASC NULLS LAST - ROWS BETWEEN 3 PRECEDING AND CURRENT ROW - ), - 0 - ) < 3 - THEN NULL - ELSE COALESCE( - SUM(`bfcol_8`) OVER ( - PARTITION BY `bfcol_9` - ORDER BY `bfcol_9` ASC NULLS LAST, `rowindex` ASC NULLS LAST - ROWS BETWEEN 3 PRECEDING AND CURRENT ROW - ), - 0 - ) - END AS `bfcol_16` - FROM `bfcte_3` -) SELECT - `bfcol_9` AS `bool_col`, - `bfcol_6` AS `rowindex`, - `bfcol_15` AS `bool_col_1`, - `bfcol_16` AS `int64_col` -FROM `bfcte_4` + `bool_col`, + `rowindex`, + CASE + WHEN COALESCE( + SUM(CAST(NOT ( + `bool_col` + ) IS NULL AS INT64)) OVER ( + PARTITION BY `bool_col` + ORDER BY `bool_col` ASC NULLS LAST, `rowindex` ASC NULLS LAST + ROWS BETWEEN 3 PRECEDING AND CURRENT ROW + ), + 0 + ) < 3 + THEN NULL + WHEN TRUE + THEN COALESCE( + SUM(CAST(`bool_col` AS INT64)) OVER ( + PARTITION BY `bool_col` + ORDER BY `bool_col` ASC NULLS LAST, `rowindex` ASC NULLS LAST + ROWS BETWEEN 3 PRECEDING AND CURRENT ROW + ), + 0 + ) + END AS `bool_col_1`, + CASE + WHEN COALESCE( + SUM(CAST(NOT ( + `int64_col` + ) IS NULL AS INT64)) OVER ( + PARTITION BY `bool_col` + ORDER BY `bool_col` ASC NULLS LAST, `rowindex` ASC NULLS LAST + ROWS BETWEEN 3 PRECEDING AND CURRENT ROW + ), + 0 + ) < 3 + THEN NULL + WHEN TRUE + THEN COALESCE( + SUM(`int64_col`) OVER ( + PARTITION BY `bool_col` + ORDER BY `bool_col` ASC NULLS LAST, `rowindex` ASC NULLS LAST + ROWS BETWEEN 3 PRECEDING AND CURRENT ROW + ), + 0 + ) + END AS `int64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +WHERE + NOT ( + `bool_col` + ) IS NULL ORDER BY - `bfcol_9` ASC NULLS LAST, + `bool_col` ASC NULLS LAST, `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_w_range_rolling/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_range_rolling/out.sql index fe4cea08cb2..2cee33d5997 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 @@ -2,32 +2,30 @@ WITH `bfcte_0` AS ( 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 COALESCE( - SUM(CAST(NOT `bfcol_1` IS NULL AS INT64)) OVER ( - ORDER BY UNIX_MICROS(`bfcol_0`) ASC - RANGE BETWEEN 2999999 PRECEDING AND CURRENT ROW - ), - 0 - ) < 1 - THEN NULL - ELSE COALESCE( - SUM(`bfcol_1`) OVER ( - ORDER BY UNIX_MICROS(`bfcol_0`) ASC - 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` + CASE + WHEN COALESCE( + SUM(CAST(NOT ( + `bfcol_1` + ) IS NULL AS INT64)) OVER ( + ORDER BY UNIX_MICROS(`bfcol_0`) ASC + RANGE BETWEEN 2999999 PRECEDING AND CURRENT ROW + ), + 0 + ) < 1 + THEN NULL + WHEN TRUE + THEN COALESCE( + SUM(`bfcol_1`) OVER ( + ORDER BY UNIX_MICROS(`bfcol_0`) ASC + RANGE BETWEEN 2999999 PRECEDING AND CURRENT ROW + ), + 0 + ) + END AS `int_col` +FROM `bfcte_0` ORDER BY `bfcol_0` ASC NULLS LAST, `bfcol_2` 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 bf1e76c55c7..03babee3801 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,27 +1,19 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN COALESCE( - SUM(CAST(NOT `int64_col` IS NULL AS INT64)) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), - 0 - ) < 3 - THEN NULL - ELSE COALESCE( - SUM(`int64_col`) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), - 0 - ) - END AS `bfcol_4` - FROM `bfcte_0` -) SELECT `rowindex`, - `bfcol_4` AS `int64_col` -FROM `bfcte_1` + CASE + WHEN COALESCE( + SUM(CAST(NOT ( + `int64_col` + ) IS NULL AS INT64)) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + 0 + ) < 3 + THEN NULL + WHEN TRUE + THEN COALESCE( + SUM(`int64_col`) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + 0 + ) + END AS `int64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` 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 5ad435ddbb7..f9496e983eb 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_wo_skips_nulls_op/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_wo_skips_nulls_op/out.sql @@ -1,21 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col`, - `rowindex` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN COUNT(CAST(NOT `int64_col` IS NULL AS INT64)) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) < 5 - THEN NULL - ELSE COUNT(`int64_col`) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) - END AS `bfcol_4` - FROM `bfcte_0` -) SELECT `rowindex`, - `bfcol_4` AS `int64_col` -FROM `bfcte_1` + CASE + WHEN COUNT(NOT ( + `int64_col` + ) IS NULL) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) < 5 + THEN NULL + WHEN TRUE + THEN COUNT(`int64_col`) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) + END AS `int64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` ORDER BY `rowindex` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/test_scalar_compiler.py b/tests/unit/core/compile/sqlglot/test_scalar_compiler.py index 3469d15d74b..07ae59e881e 100644 --- a/tests/unit/core/compile/sqlglot/test_scalar_compiler.py +++ b/tests/unit/core/compile/sqlglot/test_scalar_compiler.py @@ -17,13 +17,13 @@ import bigframes_vendored.sqlglot.expressions as sge import pytest +import bigframes.core.compile.sqlglot.expression_compiler as expression_compiler from bigframes.core.compile.sqlglot.expressions.typed_expr import TypedExpr -import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler import bigframes.operations as ops def test_register_unary_op(): - compiler = scalar_compiler.ScalarOpCompiler() + compiler = expression_compiler.ExpressionCompiler() class MockUnaryOp(ops.UnaryOp): name = "mock_unary_op" @@ -43,7 +43,7 @@ def _(expr: TypedExpr) -> sge.Expression: def test_register_unary_op_pass_op(): - compiler = scalar_compiler.ScalarOpCompiler() + compiler = expression_compiler.ExpressionCompiler() class MockUnaryOp(ops.UnaryOp): name = "mock_unary_op_pass_op" @@ -63,7 +63,7 @@ def _(expr: TypedExpr, op: ops.UnaryOp) -> sge.Expression: def test_register_binary_op(): - compiler = scalar_compiler.ScalarOpCompiler() + compiler = expression_compiler.ExpressionCompiler() class MockBinaryOp(ops.BinaryOp): name = "mock_binary_op" @@ -84,7 +84,7 @@ def _(left: TypedExpr, right: TypedExpr) -> sge.Expression: def test_register_binary_op_pass_on(): - compiler = scalar_compiler.ScalarOpCompiler() + compiler = expression_compiler.ExpressionCompiler() class MockBinaryOp(ops.BinaryOp): name = "mock_binary_op_pass_op" @@ -105,7 +105,7 @@ def _(left: TypedExpr, right: TypedExpr, op: ops.BinaryOp) -> sge.Expression: def test_register_ternary_op(): - compiler = scalar_compiler.ScalarOpCompiler() + compiler = expression_compiler.ExpressionCompiler() class MockTernaryOp(ops.TernaryOp): name = "mock_ternary_op" @@ -127,7 +127,7 @@ def _(arg1: TypedExpr, arg2: TypedExpr, arg3: TypedExpr) -> sge.Expression: def test_register_nary_op(): - compiler = scalar_compiler.ScalarOpCompiler() + compiler = expression_compiler.ExpressionCompiler() class MockNaryOp(ops.NaryOp): name = "mock_nary_op" @@ -148,7 +148,7 @@ def _(*args: TypedExpr) -> sge.Expression: def test_register_nary_op_pass_on(): - compiler = scalar_compiler.ScalarOpCompiler() + compiler = expression_compiler.ExpressionCompiler() class MockNaryOp(ops.NaryOp): name = "mock_nary_op_pass_op" @@ -171,7 +171,7 @@ def _(*args: TypedExpr, op: ops.NaryOp) -> sge.Expression: def test_binary_op_parentheses(): - compiler = scalar_compiler.ScalarOpCompiler() + compiler = expression_compiler.ExpressionCompiler() class MockAddOp(ops.BinaryOp): name = "mock_add_op" @@ -208,7 +208,7 @@ def _(left: TypedExpr, right: TypedExpr) -> sge.Expression: def test_register_duplicate_op_raises(): - compiler = scalar_compiler.ScalarOpCompiler() + compiler = expression_compiler.ExpressionCompiler() class MockUnaryOp(ops.UnaryOp): name = "mock_unary_op_duplicate" From e36dd8b492fd7ab433fa4cac732b31774c1e428b Mon Sep 17 00:00:00 2001 From: Shuowei Li Date: Wed, 11 Feb 2026 10:55:52 -0800 Subject: [PATCH 04/17] docs: Update multimodal notebook to use public runtime helpers (#2451) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR updates notebooks/multimodal/multimodal_dataframe.ipynb to use public APIs (bigframes.bigquery.obj and bigframes.bigquery.to_json_string) instead of internal operations for retrieving runtime JSON strings. Fixes # 🦕 --- .../multimodal/multimodal_dataframe.ipynb | 78 ++++++++++--------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/notebooks/multimodal/multimodal_dataframe.ipynb b/notebooks/multimodal/multimodal_dataframe.ipynb index 29c2bd468a1..b98a5e73378 100644 --- a/notebooks/multimodal/multimodal_dataframe.ipynb +++ b/notebooks/multimodal/multimodal_dataframe.ipynb @@ -92,7 +92,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -128,6 +128,38 @@ "import bigframes.bigquery as bbq" ] }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import bigframes.bigquery as bbq\n", + "\n", + "def get_runtime_json_str(series, mode=\"R\", with_metadata=False):\n", + " \"\"\"\n", + " Get the runtime (contains signed URL to access gcs data) and apply the\n", + " ToJSONSTring transformation.\n", + " \n", + " Args:\n", + " series: bigframes.series.Series to operate on.\n", + " mode: \"R\" for read, \"RW\" for read/write.\n", + " with_metadata: Whether to fetch and include blob metadata.\n", + " \"\"\"\n", + " # 1. Optionally fetch metadata\n", + " s = (\n", + " bbq.obj.fetch_metadata(series)\n", + " if with_metadata\n", + " else series\n", + " )\n", + " \n", + " # 2. Retrieve the access URL runtime object\n", + " runtime = bbq.obj.get_access_url(s, mode=mode)\n", + " \n", + " # 3. Convert the runtime object to a JSON string\n", + " return bbq.to_json_string(runtime)" + ] + }, { "cell_type": "markdown", "metadata": { @@ -1290,22 +1322,11 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 3, "metadata": { "id": "oDDuYtUm5Yiy" }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n" - ] - } - ], + "outputs": [], "source": [ "df_pdf = bpd.from_glob_path(\"gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/documents/*\", name=\"pdf\")" ] @@ -1464,7 +1485,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -1474,7 +1495,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -1486,26 +1507,9 @@ "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n" ] - }, - { - "data": { - "text/html": [ - "
0    Now, as all books, not primarily intended as p...
" - ], - "text/plain": [ - "0 Now, as all books, not primarily intended as p...\n", - "Name: transcribed_content, dtype: string" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" } ], "source": [ - "import bigframes.bigquery as bbq\n", - "import bigframes.operations as ops\n", - "\n", "# The audio_transcribe function is a convenience wrapper around bigframes.bigquery.ai.generate.\n", "# Here's how to perform the same operation directly:\n", "\n", @@ -1519,8 +1523,8 @@ "\n", "# Convert the audio series to the runtime representation required by the model.\n", "# This involves fetching metadata and getting a signed access URL.\n", - "audio_metadata = audio_series._apply_unary_op(ops.obj_fetch_metadata_op)\n", - "audio_runtime = audio_metadata._apply_unary_op(ops.ObjGetAccessUrl(mode=\"R\"))\n", + "audio_metadata = bbq.obj.fetch_metadata(audio_series)\n", + "audio_runtime = bbq.obj.get_access_url(audio_metadata, mode=\"R\")\n", "\n", "transcribed_results = bbq.ai.generate(\n", " prompt=(prompt_text, audio_runtime),\n", @@ -1534,7 +1538,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -1638,7 +1642,7 @@ "\n", "# Generate a JSON string containing the runtime information (including signed read URLs)\n", "# This allows the UDF to download the images from Google Cloud Storage\n", - "access_urls = exif_image_df[\"blob_col\"].blob.get_runtime_json_str(mode=\"R\")\n", + "access_urls = get_runtime_json_str(exif_image_df[\"blob_col\"], mode=\"R\")\n", "\n", "# Apply the BigQuery Python UDF to the runtime JSON strings\n", "# We cast to string to ensure the input matches the UDF's signature\n", From a6aafaa65ad2e6fc0ab22b20eb94f7106c0494e9 Mon Sep 17 00:00:00 2001 From: Chelsea Lin Date: Wed, 11 Feb 2026 11:07:02 -0800 Subject: [PATCH 05/17] refactor: add brackets on sqlglot `NOT` expression (#2450) --- .../sqlglot/aggregations/unary_compiler.py | 6 +++- .../sqlglot/expressions/generic_ops.py | 5 ++- .../sqlglot/expressions/numeric_ops.py | 2 +- .../test_unary_compiler/test_cut/int_bins.sql | 4 ++- .../test_cut/int_bins_labels.sql | 4 ++- .../test_unary_compiler/test_qcut/out.sql | 32 +++++++++---------- .../test_generic_ops/test_notnull/out.sql | 4 +-- .../test_numeric_ops/test_isfinite/out.sql | 3 ++ .../test_numeric_ops/test_pow/out.sql | 21 +++++++++--- .../sqlglot/expressions/test_numeric_ops.py | 11 +++++++ .../out.sql | 12 +++---- .../out.sql | 4 +-- .../out.sql | 4 +-- .../out.sql | 4 +-- 14 files changed, 76 insertions(+), 40 deletions(-) create mode 100644 tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_isfinite/out.sql diff --git a/bigframes/core/compile/sqlglot/aggregations/unary_compiler.py b/bigframes/core/compile/sqlglot/aggregations/unary_compiler.py index 381b472bceb..add3ccd9231 100644 --- a/bigframes/core/compile/sqlglot/aggregations/unary_compiler.py +++ b/bigframes/core/compile/sqlglot/aggregations/unary_compiler.py @@ -16,6 +16,7 @@ import typing +import bigframes_vendored.sqlglot as sg import bigframes_vendored.sqlglot.expressions as sge import pandas as pd @@ -189,7 +190,10 @@ def _cut_ops_w_int_bins( condition: sge.Expression if this_bin == bins - 1: - condition = sge.Is(this=column.expr, expression=sge.Not(this=sge.Null())) + condition = sge.Is( + this=sge.paren(column.expr, copy=False), + expression=sg.not_(sge.Null(), copy=False), + ) else: if op.right: condition = sge.LTE( diff --git a/bigframes/core/compile/sqlglot/expressions/generic_ops.py b/bigframes/core/compile/sqlglot/expressions/generic_ops.py index 94ff12a7ef8..14af91e591b 100644 --- a/bigframes/core/compile/sqlglot/expressions/generic_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/generic_ops.py @@ -125,7 +125,10 @@ def _(expr: TypedExpr, op: ops.MapOp) -> sge.Expression: @register_unary_op(ops.notnull_op) def _(expr: TypedExpr) -> sge.Expression: - return sge.Not(this=sge.Is(this=sge.paren(expr.expr), expression=sge.Null())) + return sge.Is( + this=sge.paren(expr.expr, copy=False), + expression=sg.not_(sge.Null(), copy=False), + ) @register_ternary_op(ops.where_op) diff --git a/bigframes/core/compile/sqlglot/expressions/numeric_ops.py b/bigframes/core/compile/sqlglot/expressions/numeric_ops.py index f2ae6cd82eb..2285a3a0bc5 100644 --- a/bigframes/core/compile/sqlglot/expressions/numeric_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/numeric_ops.py @@ -362,7 +362,7 @@ def _float_pow_op( sge.If( this=sge.and_( sge.LT(this=left_expr, expression=constants._ZERO), - sge.Not(this=exponent_is_whole), + sge.Not(this=sge.paren(exponent_is_whole)), ), true=constants._NAN, ), diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins.sql index d7b0fde7103..0a4aa961ab8 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins.sql @@ -30,7 +30,9 @@ SELECT 2 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) ) + 0 AS `right_inclusive` ) - WHEN `int64_col` IS NOT NULL + WHEN ( + `int64_col` + ) IS NOT NULL THEN STRUCT( ( MIN(`int64_col`) OVER () + ( diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins_labels.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins_labels.sql index 1a3aede0502..b1042288360 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins_labels.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins_labels.sql @@ -8,7 +8,9 @@ SELECT 2 * IEEE_DIVIDE(MAX(`int64_col`) OVER () - MIN(`int64_col`) OVER (), 3) ) THEN 'b' - WHEN `int64_col` IS NOT NULL + WHEN ( + `int64_col` + ) IS NOT NULL THEN 'c' END AS `int_bins_labels` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_qcut/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_qcut/out.sql index e24f5050303..35a95c5367e 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_qcut/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_qcut/out.sql @@ -2,17 +2,17 @@ SELECT `rowindex`, `int64_col`, IF( - NOT ( + ( `int64_col` - ) IS NULL, + ) IS NOT NULL, IF( `int64_col` IS NULL, NULL, CAST(GREATEST( CEIL( - PERCENT_RANK() OVER (PARTITION BY NOT ( + PERCENT_RANK() OVER (PARTITION BY ( `int64_col` - ) IS NULL ORDER BY `int64_col` ASC) * 4 + ) IS NOT NULL ORDER BY `int64_col` ASC) * 4 ) - 1, 0 ) AS INT64) @@ -20,29 +20,29 @@ SELECT NULL ) AS `qcut_w_int`, IF( - NOT ( + ( `int64_col` - ) IS NULL, + ) IS NOT NULL, CASE - WHEN PERCENT_RANK() OVER (PARTITION BY NOT ( + WHEN PERCENT_RANK() OVER (PARTITION BY ( `int64_col` - ) IS NULL ORDER BY `int64_col` ASC) < 0 + ) IS NOT NULL ORDER BY `int64_col` ASC) < 0 THEN NULL - WHEN PERCENT_RANK() OVER (PARTITION BY NOT ( + WHEN PERCENT_RANK() OVER (PARTITION BY ( `int64_col` - ) IS NULL ORDER BY `int64_col` ASC) <= 0.25 + ) IS NOT NULL ORDER BY `int64_col` ASC) <= 0.25 THEN 0 - WHEN PERCENT_RANK() OVER (PARTITION BY NOT ( + WHEN PERCENT_RANK() OVER (PARTITION BY ( `int64_col` - ) IS NULL ORDER BY `int64_col` ASC) <= 0.5 + ) IS NOT NULL ORDER BY `int64_col` ASC) <= 0.5 THEN 1 - WHEN PERCENT_RANK() OVER (PARTITION BY NOT ( + WHEN PERCENT_RANK() OVER (PARTITION BY ( `int64_col` - ) IS NULL ORDER BY `int64_col` ASC) <= 0.75 + ) IS NOT NULL ORDER BY `int64_col` ASC) <= 0.75 THEN 2 - WHEN PERCENT_RANK() OVER (PARTITION BY NOT ( + WHEN PERCENT_RANK() OVER (PARTITION BY ( `int64_col` - ) IS NULL ORDER BY `int64_col` ASC) <= 1 + ) IS NOT NULL ORDER BY `int64_col` ASC) <= 1 THEN 3 ELSE NULL END, 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 1865e24c4cf..c65fda76eb3 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,5 +1,5 @@ SELECT - NOT ( + ( `float64_col` - ) IS NULL AS `float64_col` + ) IS NOT NULL AS `float64_col` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_isfinite/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_isfinite/out.sql new file mode 100644 index 00000000000..500d6a6769f --- /dev/null +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_isfinite/out.sql @@ -0,0 +1,3 @@ +SELECT + NOT IS_INF(`float64_col`) OR IS_NAN(`float64_col`) AS `float64_col` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pow/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pow/out.sql index 213d8a011b0..8455e4a66fb 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pow/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pow/out.sql @@ -33,7 +33,9 @@ SELECT END ) WHEN `int64_col` < CAST(0 AS INT64) - AND NOT CAST(`float64_col` AS INT64) = `float64_col` + AND NOT ( + CAST(`float64_col` AS INT64) = `float64_col` + ) THEN CAST('NaN' AS FLOAT64) WHEN `int64_col` <> CAST(0 AS INT64) AND `float64_col` * LN(ABS(`int64_col`)) > 709.78 THEN CAST('Infinity' AS FLOAT64) * CASE @@ -75,7 +77,10 @@ SELECT ELSE `int64_col` END ) - WHEN `float64_col` < CAST(0 AS INT64) AND NOT CAST(`int64_col` AS INT64) = `int64_col` + WHEN `float64_col` < CAST(0 AS INT64) + AND NOT ( + CAST(`int64_col` AS INT64) = `int64_col` + ) THEN CAST('NaN' AS FLOAT64) WHEN `float64_col` <> CAST(0 AS INT64) AND `int64_col` * LN(ABS(`float64_col`)) > 709.78 @@ -119,7 +124,9 @@ SELECT END ) WHEN `float64_col` < CAST(0 AS INT64) - AND NOT CAST(`float64_col` AS INT64) = `float64_col` + AND NOT ( + CAST(`float64_col` AS INT64) = `float64_col` + ) THEN CAST('NaN' AS FLOAT64) WHEN `float64_col` <> CAST(0 AS INT64) AND `float64_col` * LN(ABS(`float64_col`)) > 709.78 @@ -167,7 +174,9 @@ SELECT ELSE 0 END ) - WHEN `float64_col` < CAST(0 AS INT64) AND NOT CAST(0 AS INT64) = 0 + WHEN `float64_col` < CAST(0 AS INT64) AND NOT ( + CAST(0 AS INT64) = 0 + ) THEN CAST('NaN' AS FLOAT64) WHEN `float64_col` <> CAST(0 AS INT64) AND 0 * LN(ABS(`float64_col`)) > 709.78 THEN CAST('Infinity' AS FLOAT64) * CASE @@ -214,7 +223,9 @@ SELECT ELSE 1 END ) - WHEN `float64_col` < CAST(0 AS INT64) AND NOT CAST(1 AS INT64) = 1 + WHEN `float64_col` < CAST(0 AS INT64) AND NOT ( + CAST(1 AS INT64) = 1 + ) THEN CAST('NaN' AS FLOAT64) WHEN `float64_col` <> CAST(0 AS INT64) AND 1 * LN(ABS(`float64_col`)) > 709.78 THEN CAST('Infinity' AS FLOAT64) * CASE diff --git a/tests/unit/core/compile/sqlglot/expressions/test_numeric_ops.py b/tests/unit/core/compile/sqlglot/expressions/test_numeric_ops.py index 1a08a80eb1d..f0237159bc7 100644 --- a/tests/unit/core/compile/sqlglot/expressions/test_numeric_ops.py +++ b/tests/unit/core/compile/sqlglot/expressions/test_numeric_ops.py @@ -17,6 +17,7 @@ from bigframes import operations as ops import bigframes.core.expression as ex +from bigframes.operations import numeric_ops import bigframes.pandas as bpd from bigframes.testing import utils @@ -156,6 +157,16 @@ def test_floor(scalar_types_df: bpd.DataFrame, snapshot): snapshot.assert_match(sql, "out.sql") +def test_isfinite(scalar_types_df: bpd.DataFrame, snapshot): + col_name = "float64_col" + bf_df = scalar_types_df[[col_name]] + sql = utils._apply_ops_to_sql( + bf_df, [numeric_ops.isfinite_op.as_expr(col_name)], [col_name] + ) + + snapshot.assert_match(sql, "out.sql") + + def test_ln(scalar_types_df: bpd.DataFrame, snapshot): col_name = "float64_col" bf_df = scalar_types_df[[col_name]] 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 155b7fae20f..b91aafcbee5 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 @@ -3,9 +3,9 @@ SELECT `rowindex`, CASE WHEN COALESCE( - SUM(CAST(NOT ( + SUM(CAST(( `bool_col` - ) IS NULL AS INT64)) OVER ( + ) IS NOT NULL AS INT64)) OVER ( PARTITION BY `bool_col` ORDER BY `bool_col` ASC NULLS LAST, `rowindex` ASC NULLS LAST ROWS BETWEEN 3 PRECEDING AND CURRENT ROW @@ -25,9 +25,9 @@ SELECT END AS `bool_col_1`, CASE WHEN COALESCE( - SUM(CAST(NOT ( + SUM(CAST(( `int64_col` - ) IS NULL AS INT64)) OVER ( + ) IS NOT NULL AS INT64)) OVER ( PARTITION BY `bool_col` ORDER BY `bool_col` ASC NULLS LAST, `rowindex` ASC NULLS LAST ROWS BETWEEN 3 PRECEDING AND CURRENT ROW @@ -47,9 +47,9 @@ SELECT END AS `int64_col` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` WHERE - NOT ( + ( `bool_col` - ) IS NULL + ) IS NOT NULL ORDER BY `bool_col` ASC NULLS LAST, `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_w_range_rolling/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_range_rolling/out.sql index 2cee33d5997..887e7e9212d 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 @@ -7,9 +7,9 @@ SELECT `bfcol_0` AS `ts_col`, CASE WHEN COALESCE( - SUM(CAST(NOT ( + SUM(CAST(( `bfcol_1` - ) IS NULL AS INT64)) OVER ( + ) IS NOT NULL AS INT64)) OVER ( ORDER BY UNIX_MICROS(`bfcol_0`) ASC RANGE BETWEEN 2999999 PRECEDING AND CURRENT ROW ), 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 03babee3801..8a8bf6445a1 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 @@ -2,9 +2,9 @@ SELECT `rowindex`, CASE WHEN COALESCE( - SUM(CAST(NOT ( + SUM(CAST(( `int64_col` - ) IS NULL AS INT64)) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + ) IS NOT NULL AS INT64)) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), 0 ) < 3 THEN NULL 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 f9496e983eb..cf14f1cd055 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,9 +1,9 @@ SELECT `rowindex`, CASE - WHEN COUNT(NOT ( + WHEN COUNT(( `int64_col` - ) IS NULL) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) < 5 + ) IS NOT NULL) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) < 5 THEN NULL WHEN TRUE THEN COUNT(`int64_col`) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) From b925aa243dad0e42ad126c9397f42be0aad7152d Mon Sep 17 00:00:00 2001 From: Garrett Wu <6505921+GarrettWu@users.noreply.github.com> Date: Wed, 11 Feb 2026 12:44:34 -0800 Subject: [PATCH 06/17] feat: add bigquery.ai.generate_table function (#2453) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery-dataframes/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes # 🦕 --- bigframes/bigquery/_operations/ai.py | 95 ++++++++++++++++++++++++++ bigframes/bigquery/ai.py | 2 + tests/system/large/bigquery/test_ai.py | 17 +++++ tests/unit/bigquery/test_ai.py | 49 +++++++++++++ 4 files changed, 163 insertions(+) diff --git a/bigframes/bigquery/_operations/ai.py b/bigframes/bigquery/_operations/ai.py index bc2ab8dd206..7f9c3eb55f8 100644 --- a/bigframes/bigquery/_operations/ai.py +++ b/bigframes/bigquery/_operations/ai.py @@ -601,6 +601,101 @@ def generate_text( return session.read_gbq_query(query) +@log_adapter.method_logger(custom_base_name="bigquery_ai") +def generate_table( + model: Union[bigframes.ml.base.BaseEstimator, str, pd.Series], + data: Union[dataframe.DataFrame, series.Series, pd.DataFrame, pd.Series], + *, + output_schema: str, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + max_output_tokens: Optional[int] = None, + stop_sequences: Optional[List[str]] = None, + request_type: Optional[str] = None, +) -> dataframe.DataFrame: + """ + Generates a table using a BigQuery ML model. + + See the `AI.GENERATE_TABLE function syntax + `_ + for additional reference. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> import bigframes.bigquery as bbq + >>> # The user is responsible for constructing a DataFrame that contains + >>> # the necessary columns for the model's prompt. For example, a + >>> # DataFrame with a 'prompt' column for text classification. + >>> df = bpd.DataFrame({'prompt': ["some text to classify"]}) + >>> result = bbq.ai.generate_table( + ... "project.dataset.model_name", + ... data=df, + ... output_schema="category STRING" + ... ) # doctest: +SKIP + + Args: + model (bigframes.ml.base.BaseEstimator or str): + The model to use for table generation. + data (bigframes.pandas.DataFrame or bigframes.pandas.Series): + The data to generate embeddings for. If a Series is provided, it is + treated as the 'content' column. If a DataFrame is provided, it + must contain a 'content' column, or you must rename the column you + wish to embed to 'content'. + output_schema (str): + A string defining the output schema (e.g., "col1 STRING, col2 INT64"). + temperature (float, optional): + A FLOAT64 value that is used for sampling promiscuity. The value + must be in the range ``[0.0, 1.0]``. + top_p (float, optional): + A FLOAT64 value that changes how the model selects tokens for + output. + max_output_tokens (int, optional): + An INT64 value that sets the maximum number of tokens in the + generated table. + stop_sequences (List[str], optional): + An ARRAY value that contains the stop sequences for the model. + request_type (str, optional): + A STRING value that contains the request type for the model. + + Returns: + bigframes.pandas.DataFrame: + The generated table. + """ + data = _to_dataframe(data, series_rename="prompt") + model_name, session = bq_utils.get_model_name_and_session(model, data) + table_sql = bq_utils.to_sql(data) + + struct_fields_bq: Dict[str, bigframes.core.sql.literals.STRUCT_VALUES] = { + "output_schema": output_schema + } + if temperature is not None: + struct_fields_bq["temperature"] = temperature + if top_p is not None: + struct_fields_bq["top_p"] = top_p + if max_output_tokens is not None: + struct_fields_bq["max_output_tokens"] = max_output_tokens + if stop_sequences is not None: + struct_fields_bq["stop_sequences"] = stop_sequences + if request_type is not None: + struct_fields_bq["request_type"] = request_type + + struct_sql = bigframes.core.sql.literals.struct_literal(struct_fields_bq) + query = f""" + SELECT * + FROM AI.GENERATE_TABLE( + MODEL `{model_name}`, + ({table_sql}), + {struct_sql} + ) + """ + + if session is None: + return bpd.read_gbq_query(query) + else: + return session.read_gbq_query(query) + + @log_adapter.method_logger(custom_base_name="bigquery_ai") def if_( prompt: PROMPT_TYPE, diff --git a/bigframes/bigquery/ai.py b/bigframes/bigquery/ai.py index 053ee7352a8..bb24d5dc33f 100644 --- a/bigframes/bigquery/ai.py +++ b/bigframes/bigquery/ai.py @@ -24,6 +24,7 @@ generate_double, generate_embedding, generate_int, + generate_table, generate_text, if_, score, @@ -37,6 +38,7 @@ "generate_double", "generate_embedding", "generate_int", + "generate_table", "generate_text", "if_", "score", diff --git a/tests/system/large/bigquery/test_ai.py b/tests/system/large/bigquery/test_ai.py index e318a8a720f..86cf4d7f001 100644 --- a/tests/system/large/bigquery/test_ai.py +++ b/tests/system/large/bigquery/test_ai.py @@ -94,3 +94,20 @@ def test_generate_text_with_options(text_model): # It basically asserts that the results are still returned. assert len(result) == 2 + + +def test_generate_table(text_model): + df = bpd.DataFrame( + {"prompt": ["Generate a table of 2 programming languages and their creators."]} + ) + + result = ai.generate_table( + text_model, + df, + output_schema="language STRING, creator STRING", + ) + + assert "language" in result.columns + assert "creator" in result.columns + # The model may not always return the exact number of rows requested. + assert len(result) > 0 diff --git a/tests/unit/bigquery/test_ai.py b/tests/unit/bigquery/test_ai.py index 0be32b9e8a5..796e86f9245 100644 --- a/tests/unit/bigquery/test_ai.py +++ b/tests/unit/bigquery/test_ai.py @@ -220,6 +220,55 @@ def test_generate_text_defaults(mock_dataframe, mock_session): assert "STRUCT()" in query +def test_generate_table_with_dataframe(mock_dataframe, mock_session): + model_name = "project.dataset.model" + + bbq.ai.generate_table( + model_name, + mock_dataframe, + output_schema="col1 STRING, col2 INT64", + ) + + mock_session.read_gbq_query.assert_called_once() + query = mock_session.read_gbq_query.call_args[0][0] + + # Normalize whitespace for comparison + query = " ".join(query.split()) + + expected_part_1 = "SELECT * FROM AI.GENERATE_TABLE(" + expected_part_2 = f"MODEL `{model_name}`," + expected_part_3 = "(SELECT * FROM my_table)," + expected_part_4 = "STRUCT('col1 STRING, col2 INT64' AS output_schema)" + + assert expected_part_1 in query + assert expected_part_2 in query + assert expected_part_3 in query + assert expected_part_4 in query + + +def test_generate_table_with_options(mock_dataframe, mock_session): + model_name = "project.dataset.model" + + bbq.ai.generate_table( + model_name, + mock_dataframe, + output_schema="col1 STRING", + temperature=0.5, + max_output_tokens=100, + ) + + mock_session.read_gbq_query.assert_called_once() + query = mock_session.read_gbq_query.call_args[0][0] + query = " ".join(query.split()) + + assert f"MODEL `{model_name}`" in query + assert "(SELECT * FROM my_table)" in query + assert ( + "STRUCT('col1 STRING' AS output_schema, 0.5 AS temperature, 100 AS max_output_tokens)" + in query + ) + + @mock.patch("bigframes.pandas.read_pandas") def test_generate_text_with_pandas_dataframe( read_pandas_mock, mock_dataframe, mock_session From ae35a9890a2f9903b12e431488362c091118bbdd Mon Sep 17 00:00:00 2001 From: TrevorBergeron Date: Wed, 11 Feb 2026 12:45:23 -0800 Subject: [PATCH 07/17] feat: Initial support for biglake iceberg tables (#2409) --- bigframes/core/array_value.py | 13 +- bigframes/core/bq_data.py | 186 +++++++++++++-- .../compile/ibis_compiler/ibis_compiler.py | 4 +- bigframes/core/nodes.py | 4 +- bigframes/core/schema.py | 27 +-- bigframes/dtypes.py | 4 +- bigframes/pandas/io/api.py | 17 +- .../session/_io/bigquery/read_gbq_table.py | 211 +++++------------- bigframes/session/bq_caching_executor.py | 9 +- bigframes/session/dry_runs.py | 27 ++- bigframes/session/iceberg.py | 204 +++++++++++++++++ bigframes/session/loader.py | 127 +++++++++-- bigframes/session/read_api_execution.py | 5 +- bigframes/streaming/dataframe.py | 2 +- setup.py | 1 + testing/constraints-3.10.txt | 90 +++++++- tests/system/small/test_iceberg.py | 49 ++++ .../compile/sqlglot/test_compile_readtable.py | 3 +- tests/unit/core/rewrite/conftest.py | 7 +- tests/unit/core/rewrite/test_identifiers.py | 5 +- tests/unit/session/test_read_gbq_table.py | 11 +- tests/unit/session/test_session.py | 5 +- tests/unit/test_planner.py | 4 +- 23 files changed, 753 insertions(+), 262 deletions(-) create mode 100644 bigframes/session/iceberg.py create mode 100644 tests/system/small/test_iceberg.py diff --git a/bigframes/core/array_value.py b/bigframes/core/array_value.py index 7901243e4b0..ccec1f9b954 100644 --- a/bigframes/core/array_value.py +++ b/bigframes/core/array_value.py @@ -17,9 +17,8 @@ import datetime import functools import typing -from typing import Iterable, List, Mapping, Optional, Sequence, Tuple +from typing import Iterable, List, Mapping, Optional, Sequence, Tuple, Union -import google.cloud.bigquery import pandas import pyarrow as pa @@ -91,7 +90,7 @@ def from_range(cls, start, end, step): @classmethod def from_table( cls, - table: google.cloud.bigquery.Table, + table: Union[bq_data.BiglakeIcebergTable, bq_data.GbqNativeTable], session: Session, *, columns: Optional[Sequence[str]] = None, @@ -103,8 +102,6 @@ def from_table( ): if offsets_col and primary_key: raise ValueError("must set at most one of 'offests', 'primary_key'") - # define data source only for needed columns, this makes row-hashing cheaper - table_def = bq_data.GbqTable.from_table(table, columns=columns or ()) # create ordering from info ordering = None @@ -115,7 +112,9 @@ def from_table( [ids.ColumnId(key_part) for key_part in primary_key] ) - bf_schema = schemata.ArraySchema.from_bq_table(table, columns=columns) + bf_schema = schemata.ArraySchema.from_bq_schema( + table.physical_schema, columns=columns + ) # Scan all columns by default, we define this list as it can be pruned while preserving source_def scan_list = nodes.ScanList( tuple( @@ -124,7 +123,7 @@ def from_table( ) ) source_def = bq_data.BigqueryDataSource( - table=table_def, + table=table, schema=bf_schema, at_time=at_time, sql_predicate=predicate, diff --git a/bigframes/core/bq_data.py b/bigframes/core/bq_data.py index 3b42ff7c031..c9847194657 100644 --- a/bigframes/core/bq_data.py +++ b/bigframes/core/bq_data.py @@ -22,7 +22,7 @@ import queue import threading import typing -from typing import Any, Iterator, Optional, Sequence, Tuple +from typing import Any, Iterator, List, Literal, Optional, Sequence, Tuple, Union from google.cloud import bigquery_storage_v1 import google.cloud.bigquery as bq @@ -30,6 +30,7 @@ from google.protobuf import timestamp_pb2 import pyarrow as pa +import bigframes.constants from bigframes.core import pyarrow_utils import bigframes.core.schema @@ -37,59 +38,198 @@ import bigframes.core.ordering as orderings +def _resolve_standard_gcp_region(bq_region: str): + """ + Resolve bq regions to standardized + """ + if bq_region.casefold() == "US": + return "us-central1" + elif bq_region.casefold() == "EU": + return "europe-west4" + return bq_region + + +def is_irc_table(table_id: str): + """ + Determines if a table id should be resolved through the iceberg rest catalog. + """ + return len(table_id.split(".")) == 4 + + +def is_compatible( + data_region: Union[GcsRegion, BigQueryRegion], session_location: str +) -> bool: + # based on https://docs.cloud.google.com/bigquery/docs/locations#storage-location-considerations + if isinstance(data_region, BigQueryRegion): + return data_region.name == session_location + else: + assert isinstance(data_region, GcsRegion) + # TODO(b/463675088): Multi-regions don't yet support rest catalog tables + if session_location in bigframes.constants.BIGQUERY_MULTIREGIONS: + return False + return _resolve_standard_gcp_region(session_location) in data_region.included + + +def get_default_bq_region(data_region: Union[GcsRegion, BigQueryRegion]) -> str: + if isinstance(data_region, BigQueryRegion): + return data_region.name + elif isinstance(data_region, GcsRegion): + # should maybe try to track and prefer primary replica? + return data_region.included[0] + + +@dataclasses.dataclass(frozen=True) +class BigQueryRegion: + name: str + + +@dataclasses.dataclass(frozen=True) +class GcsRegion: + # this is the name of gcs regions, which may be names for multi-regions, so shouldn't be compared with non-gcs locations + storage_regions: tuple[str, ...] + # this tracks all the included standard, specific regions (eg us-east1), and should be comparable to bq regions (except non-standard US, EU, omni regions) + included: tuple[str, ...] + + +# what is the line between metadata and core fields? Mostly metadata fields are optional or unreliable, but its fuzzy @dataclasses.dataclass(frozen=True) -class GbqTable: +class TableMetadata: + # this size metadata might be stale, don't use where strict correctness is needed + location: Union[BigQueryRegion, GcsRegion] + type: Literal["TABLE", "EXTERNAL", "VIEW", "MATERIALIZE_VIEW", "SNAPSHOT"] + numBytes: Optional[int] = None + numRows: Optional[int] = None + created_time: Optional[datetime.datetime] = None + modified_time: Optional[datetime.datetime] = None + + +@dataclasses.dataclass(frozen=True) +class GbqNativeTable: project_id: str = dataclasses.field() dataset_id: str = dataclasses.field() table_id: str = dataclasses.field() physical_schema: Tuple[bq.SchemaField, ...] = dataclasses.field() - is_physically_stored: bool = dataclasses.field() - cluster_cols: typing.Optional[Tuple[str, ...]] + metadata: TableMetadata = dataclasses.field() + partition_col: Optional[str] = None + cluster_cols: typing.Optional[Tuple[str, ...]] = None + primary_key: Optional[Tuple[str, ...]] = None @staticmethod - def from_table(table: bq.Table, columns: Sequence[str] = ()) -> GbqTable: + def from_table(table: bq.Table, columns: Sequence[str] = ()) -> GbqNativeTable: # Subsetting fields with columns can reduce cost of row-hash default ordering if columns: schema = tuple(item for item in table.schema if item.name in columns) else: schema = tuple(table.schema) - return GbqTable( + + metadata = TableMetadata( + numBytes=table.num_bytes, + numRows=table.num_rows, + location=BigQueryRegion(table.location), # type: ignore + type=table.table_type or "TABLE", # type: ignore + created_time=table.created, + modified_time=table.modified, + ) + partition_col = None + if table.range_partitioning: + partition_col = table.range_partitioning.field + elif table.time_partitioning: + partition_col = table.time_partitioning.field + + return GbqNativeTable( project_id=table.project, dataset_id=table.dataset_id, table_id=table.table_id, physical_schema=schema, - is_physically_stored=(table.table_type in ["TABLE", "MATERIALIZED_VIEW"]), + partition_col=partition_col, cluster_cols=None - if table.clustering_fields is None + if (table.clustering_fields is None) else tuple(table.clustering_fields), + primary_key=tuple(_get_primary_keys(table)), + metadata=metadata, ) @staticmethod def from_ref_and_schema( table_ref: bq.TableReference, schema: Sequence[bq.SchemaField], + location: str, + table_type: Literal["TABLE"] = "TABLE", cluster_cols: Optional[Sequence[str]] = None, - ) -> GbqTable: - return GbqTable( + ) -> GbqNativeTable: + return GbqNativeTable( project_id=table_ref.project, dataset_id=table_ref.dataset_id, table_id=table_ref.table_id, + metadata=TableMetadata(location=BigQueryRegion(location), type=table_type), physical_schema=tuple(schema), - is_physically_stored=True, cluster_cols=tuple(cluster_cols) if cluster_cols else None, ) + @property + def is_physically_stored(self) -> bool: + return self.metadata.type in ["TABLE", "MATERIALIZED_VIEW"] + def get_table_ref(self) -> bq.TableReference: return bq.TableReference( bq.DatasetReference(self.project_id, self.dataset_id), self.table_id ) + def get_full_id(self, quoted: bool = False) -> str: + if quoted: + return f"`{self.project_id}`.`{self.dataset_id}`.`{self.table_id}`" + return f"{self.project_id}.{self.dataset_id}.{self.table_id}" + @property @functools.cache def schema_by_id(self): return {col.name: col for col in self.physical_schema} +@dataclasses.dataclass(frozen=True) +class BiglakeIcebergTable: + project_id: str = dataclasses.field() + catalog_id: str = dataclasses.field() + namespace_id: str = dataclasses.field() + table_id: str = dataclasses.field() + physical_schema: Tuple[bq.SchemaField, ...] = dataclasses.field() + cluster_cols: typing.Optional[Tuple[str, ...]] + metadata: TableMetadata + + def get_full_id(self, quoted: bool = False) -> str: + if quoted: + return f"`{self.project_id}`.`{self.catalog_id}`.`{self.namespace_id}`.`{self.table_id}`" + return ( + f"{self.project_id}.{self.catalog_id}.{self.namespace_id}.{self.table_id}" + ) + + @property + @functools.cache + def schema_by_id(self): + return {col.name: col for col in self.physical_schema} + + @property + def partition_col(self) -> Optional[str]: + # TODO: Use iceberg partition metadata + return None + + @property + def dataset_id(self) -> str: + """ + Not a true dataset, but serves as the dataset component of the identifer in sql queries + """ + return f"{self.catalog_id}.{self.namespace_id}" + + @property + def primary_key(self) -> Optional[Tuple[str, ...]]: + return None + + def get_table_ref(self) -> bq.TableReference: + return bq.TableReference( + bq.DatasetReference(self.project_id, self.dataset_id), self.table_id + ) + + @dataclasses.dataclass(frozen=True) class BigqueryDataSource: """ @@ -104,13 +244,13 @@ def __post_init__(self): self.schema.names ) - table: GbqTable + table: Union[GbqNativeTable, BiglakeIcebergTable] schema: bigframes.core.schema.ArraySchema at_time: typing.Optional[datetime.datetime] = None # Added for backwards compatibility, not validated sql_predicate: typing.Optional[str] = None ordering: typing.Optional[orderings.RowOrdering] = None - # Optimization field + # Optimization field, must be correct if set, don't put maybe-stale number here n_rows: Optional[int] = None @@ -188,6 +328,8 @@ def get_arrow_batches( project_id: str, sample_rate: Optional[float] = None, ) -> ReadResult: + assert isinstance(data.table, GbqNativeTable) + table_mod_options = {} read_options_dict: dict[str, Any] = {"selected_fields": list(columns)} @@ -245,3 +387,21 @@ def process_batch(pa_batch): return ReadResult( batches, session.estimated_row_count, session.estimated_total_bytes_scanned ) + + +def _get_primary_keys( + table: bq.Table, +) -> List[str]: + """Get primary keys from table if they are set.""" + + primary_keys: List[str] = [] + if ( + (table_constraints := getattr(table, "table_constraints", None)) is not None + and (primary_key := table_constraints.primary_key) is not None + # This will be False for either None or empty list. + # We want primary_keys = None if no primary keys are set. + and (columns := primary_key.columns) + ): + primary_keys = columns if columns is not None else [] + + return primary_keys diff --git a/bigframes/core/compile/ibis_compiler/ibis_compiler.py b/bigframes/core/compile/ibis_compiler/ibis_compiler.py index 9e209ea3b34..8d40a9eb740 100644 --- a/bigframes/core/compile/ibis_compiler/ibis_compiler.py +++ b/bigframes/core/compile/ibis_compiler/ibis_compiler.py @@ -215,9 +215,7 @@ def _table_to_ibis( source: bq_data.BigqueryDataSource, scan_cols: typing.Sequence[str], ) -> ibis_types.Table: - full_table_name = ( - f"{source.table.project_id}.{source.table.dataset_id}.{source.table.table_id}" - ) + full_table_name = source.table.get_full_id(quoted=False) # Physical schema might include unused columns, unsupported datatypes like JSON physical_schema = ibis_bigquery.BigQuerySchema.to_ibis( list(source.table.physical_schema) diff --git a/bigframes/core/nodes.py b/bigframes/core/nodes.py index ddccb39ef98..4b1efcb285c 100644 --- a/bigframes/core/nodes.py +++ b/bigframes/core/nodes.py @@ -825,9 +825,7 @@ def variables_introduced(self) -> int: @property def row_count(self) -> typing.Optional[int]: - if self.source.sql_predicate is None and self.source.table.is_physically_stored: - return self.source.n_rows - return None + return self.source.n_rows @property def node_defined_ids(self) -> Tuple[identifiers.ColumnId, ...]: diff --git a/bigframes/core/schema.py b/bigframes/core/schema.py index 395ad55f492..d0c6d8656cb 100644 --- a/bigframes/core/schema.py +++ b/bigframes/core/schema.py @@ -17,7 +17,7 @@ from dataclasses import dataclass import functools import typing -from typing import Dict, List, Optional, Sequence +from typing import Dict, Optional, Sequence import google.cloud.bigquery import pyarrow @@ -40,31 +40,16 @@ class ArraySchema: def __iter__(self): yield from self.items - @classmethod - def from_bq_table( - cls, - table: google.cloud.bigquery.Table, - column_type_overrides: Optional[ - typing.Dict[str, bigframes.dtypes.Dtype] - ] = None, - columns: Optional[Sequence[str]] = None, - ): - if not columns: - fields = table.schema - else: - lookup = {field.name: field for field in table.schema} - fields = [lookup[col] for col in columns] - - return ArraySchema.from_bq_schema( - fields, column_type_overrides=column_type_overrides - ) - @classmethod def from_bq_schema( cls, - schema: List[google.cloud.bigquery.SchemaField], + schema: Sequence[google.cloud.bigquery.SchemaField], column_type_overrides: Optional[Dict[str, bigframes.dtypes.Dtype]] = None, + columns: Optional[Sequence[str]] = None, ): + if columns: + lookup = {field.name: field for field in schema} + schema = [lookup[col] for col in columns] if column_type_overrides is None: column_type_overrides = {} items = tuple( diff --git a/bigframes/dtypes.py b/bigframes/dtypes.py index 29e1be1acea..8caddcdb002 100644 --- a/bigframes/dtypes.py +++ b/bigframes/dtypes.py @@ -800,7 +800,7 @@ def convert_to_schema_field( name, inner_field.field_type, mode="REPEATED", fields=inner_field.fields ) if pa.types.is_struct(bigframes_dtype.pyarrow_dtype): - inner_fields: list[pa.Field] = [] + inner_fields: list[google.cloud.bigquery.SchemaField] = [] struct_type = typing.cast(pa.StructType, bigframes_dtype.pyarrow_dtype) for i in range(struct_type.num_fields): field = struct_type.field(i) @@ -823,7 +823,7 @@ def convert_to_schema_field( def bf_type_from_type_kind( - bq_schema: list[google.cloud.bigquery.SchemaField], + bq_schema: Sequence[google.cloud.bigquery.SchemaField], ) -> typing.Dict[str, Dtype]: """Converts bigquery sql type to the default bigframes dtype.""" return {name: dtype for name, dtype in map(convert_schema_field, bq_schema)} diff --git a/bigframes/pandas/io/api.py b/bigframes/pandas/io/api.py index fade0558ac9..7296cd2b7f4 100644 --- a/bigframes/pandas/io/api.py +++ b/bigframes/pandas/io/api.py @@ -50,6 +50,7 @@ import bigframes._config as config import bigframes._importing +from bigframes.core import bq_data import bigframes.core.global_session as global_session import bigframes.core.indexes import bigframes.dataframe @@ -59,6 +60,7 @@ from bigframes.session import dry_runs import bigframes.session._io.bigquery import bigframes.session.clients +import bigframes.session.iceberg import bigframes.session.metrics # Note: the following methods are duplicated from Session. This duplication @@ -254,7 +256,7 @@ def _run_read_gbq_colab_sessionless_dry_run( pyformat_args=pyformat_args, dry_run=True, ) - bqclient = _get_bqclient() + bqclient, _ = _get_bqclient_and_project() job = _dry_run(query_formatted, bqclient) return dry_runs.get_query_stats_with_inferred_dtypes(job, (), ()) @@ -628,7 +630,7 @@ def from_glob_path( _default_location_lock = threading.Lock() -def _get_bqclient() -> bigquery.Client: +def _get_bqclient_and_project() -> Tuple[bigquery.Client, str]: # Address circular imports in doctest due to bigframes/session/__init__.py # containing a lot of logic and samples. from bigframes.session import clients @@ -643,7 +645,7 @@ def _get_bqclient() -> bigquery.Client: client_endpoints_override=config.options.bigquery.client_endpoints_override, requests_transport_adapters=config.options.bigquery.requests_transport_adapters, ) - return clients_provider.bqclient + return clients_provider.bqclient, clients_provider._project def _dry_run(query, bqclient) -> bigquery.QueryJob: @@ -688,7 +690,7 @@ def _set_default_session_location_if_possible_deferred_query(create_query): return query = create_query() - bqclient = _get_bqclient() + bqclient, default_project = _get_bqclient_and_project() if bigquery.is_query(query): # Intentionally run outside of the session so that we can detect the @@ -696,6 +698,13 @@ def _set_default_session_location_if_possible_deferred_query(create_query): # aren't necessary. job = _dry_run(query, bqclient) config.options.bigquery.location = job.location + elif bq_data.is_irc_table(query): + irc_table = bigframes.session.iceberg.get_table( + default_project, query, bqclient._credentials + ) + config.options.bigquery.location = bq_data.get_default_bq_region( + irc_table.metadata.location + ) else: table = bqclient.get_table(query) config.options.bigquery.location = table.location diff --git a/bigframes/session/_io/bigquery/read_gbq_table.py b/bigframes/session/_io/bigquery/read_gbq_table.py index e12fe502c0f..fe27fc3fc3c 100644 --- a/bigframes/session/_io/bigquery/read_gbq_table.py +++ b/bigframes/session/_io/bigquery/read_gbq_table.py @@ -20,15 +20,15 @@ import datetime import typing -from typing import Dict, Iterable, List, Optional, Sequence, Tuple +from typing import Dict, Iterable, Optional, Sequence, Tuple, Union import warnings import bigframes_vendored.constants as constants import google.api_core.exceptions import google.cloud.bigquery as bigquery -import google.cloud.bigquery.table import bigframes.core +from bigframes.core import bq_data import bigframes.core.events import bigframes.exceptions as bfe import bigframes.session._io.bigquery @@ -98,81 +98,6 @@ def get_information_schema_metadata( return table -def get_table_metadata( - bqclient: bigquery.Client, - *, - table_id: str, - default_project: Optional[str], - bq_time: datetime.datetime, - cache: Dict[str, Tuple[datetime.datetime, bigquery.Table]], - use_cache: bool = True, - publisher: bigframes.core.events.Publisher, -) -> Tuple[datetime.datetime, google.cloud.bigquery.table.Table]: - """Get the table metadata, either from cache or via REST API.""" - - cached_table = cache.get(table_id) - if use_cache and cached_table is not None: - snapshot_timestamp, table = cached_table - - if is_time_travel_eligible( - bqclient=bqclient, - table=table, - columns=None, - snapshot_time=snapshot_timestamp, - filter_str=None, - # Don't warn, because that will already have been taken care of. - should_warn=False, - should_dry_run=False, - publisher=publisher, - ): - # This warning should only happen if the cached snapshot_time will - # have any effect on bigframes (b/437090788). For example, with - # cached query results, such as after re-running a query, time - # travel won't be applied and thus this check is irrelevent. - # - # In other cases, such as an explicit read_gbq_table(), Cache hit - # could be unexpected. See internal issue 329545805. Raise a - # warning with more information about how to avoid the problems - # with the cache. - msg = bfe.format_message( - f"Reading cached table from {snapshot_timestamp} to avoid " - "incompatibilies with previous reads of this table. To read " - "the latest version, set `use_cache=False` or close the " - "current session with Session.close() or " - "bigframes.pandas.close_session()." - ) - # There are many layers before we get to (possibly) the user's code: - # pandas.read_gbq_table - # -> with_default_session - # -> Session.read_gbq_table - # -> _read_gbq_table - # -> _get_snapshot_sql_and_primary_key - # -> get_snapshot_datetime_and_table_metadata - warnings.warn(msg, category=bfe.TimeTravelCacheWarning, stacklevel=7) - - return cached_table - - if is_information_schema(table_id): - table = get_information_schema_metadata( - bqclient=bqclient, table_id=table_id, default_project=default_project - ) - else: - table_ref = google.cloud.bigquery.table.TableReference.from_string( - table_id, default_project=default_project - ) - table = bqclient.get_table(table_ref) - - # local time will lag a little bit do to network latency - # make sure it is at least table creation time. - # This is relevant if the table was created immediately before loading it here. - if (table.created is not None) and (table.created > bq_time): - bq_time = table.created - - cached_table = (bq_time, table) - cache[table_id] = cached_table - return cached_table - - def is_information_schema(table_id: str): table_id_casefold = table_id.casefold() # Include the "."s to ensure we don't have false positives for some user @@ -186,7 +111,7 @@ def is_information_schema(table_id: str): def is_time_travel_eligible( bqclient: bigquery.Client, - table: google.cloud.bigquery.table.Table, + table: Union[bq_data.GbqNativeTable, bq_data.BiglakeIcebergTable], columns: Optional[Sequence[str]], snapshot_time: datetime.datetime, filter_str: Optional[str] = None, @@ -220,43 +145,48 @@ def is_time_travel_eligible( # -> is_time_travel_eligible stacklevel = 7 - # Anonymous dataset, does not support snapshot ever - if table.dataset_id.startswith("_"): - return False + if isinstance(table, bq_data.GbqNativeTable): + # Anonymous dataset, does not support snapshot ever + if table.dataset_id.startswith("_"): + return False - # Only true tables support time travel - if table.table_id.endswith("*"): - if should_warn: - msg = bfe.format_message( - "Wildcard tables do not support FOR SYSTEM_TIME AS OF queries. " - "Attempting query without time travel. Be aware that " - "modifications to the underlying data may result in errors or " - "unexpected behavior." - ) - warnings.warn( - msg, category=bfe.TimeTravelDisabledWarning, stacklevel=stacklevel - ) - return False - elif table.table_type != "TABLE": - if table.table_type == "MATERIALIZED_VIEW": + # Only true tables support time travel + if table.table_id.endswith("*"): if should_warn: msg = bfe.format_message( - "Materialized views do not support FOR SYSTEM_TIME AS OF queries. " - "Attempting query without time travel. Be aware that as materialized views " - "are updated periodically, modifications to the underlying data in the view may " - "result in errors or unexpected behavior." + "Wildcard tables do not support FOR SYSTEM_TIME AS OF queries. " + "Attempting query without time travel. Be aware that " + "modifications to the underlying data may result in errors or " + "unexpected behavior." ) warnings.warn( msg, category=bfe.TimeTravelDisabledWarning, stacklevel=stacklevel ) return False - elif table.table_type == "VIEW": - return False + elif table.metadata.type != "TABLE": + if table.metadata.type == "MATERIALIZED_VIEW": + if should_warn: + msg = bfe.format_message( + "Materialized views do not support FOR SYSTEM_TIME AS OF queries. " + "Attempting query without time travel. Be aware that as materialized views " + "are updated periodically, modifications to the underlying data in the view may " + "result in errors or unexpected behavior." + ) + warnings.warn( + msg, + category=bfe.TimeTravelDisabledWarning, + stacklevel=stacklevel, + ) + return False + elif table.metadata.type == "VIEW": + return False # table might support time travel, lets do a dry-run query with time travel if should_dry_run: snapshot_sql = bigframes.session._io.bigquery.to_query( - query_or_table=f"{table.reference.project}.{table.reference.dataset_id}.{table.reference.table_id}", + query_or_table=table.get_full_id( + quoted=False + ), # to_query will quote for us columns=columns or (), sql_predicate=filter_str, time_travel_timestamp=snapshot_time, @@ -299,8 +229,8 @@ def is_time_travel_eligible( def infer_unique_columns( - table: google.cloud.bigquery.table.Table, - index_cols: List[str], + table: Union[bq_data.GbqNativeTable, bq_data.BiglakeIcebergTable], + index_cols: Sequence[str], ) -> Tuple[str, ...]: """Return a set of columns that can provide a unique row key or empty if none can be inferred. @@ -309,7 +239,7 @@ def infer_unique_columns( """ # If index_cols contain the primary_keys, the query engine assumes they are # provide a unique index. - primary_keys = tuple(_get_primary_keys(table)) + primary_keys = table.primary_key or () if (len(primary_keys) > 0) and frozenset(primary_keys) <= frozenset(index_cols): # Essentially, just reordering the primary key to match the index col order return tuple(index_col for index_col in index_cols if index_col in primary_keys) @@ -322,8 +252,8 @@ def infer_unique_columns( def check_if_index_columns_are_unique( bqclient: bigquery.Client, - table: google.cloud.bigquery.table.Table, - index_cols: List[str], + table: Union[bq_data.GbqNativeTable, bq_data.BiglakeIcebergTable], + index_cols: Sequence[str], *, publisher: bigframes.core.events.Publisher, ) -> Tuple[str, ...]: @@ -332,7 +262,9 @@ def check_if_index_columns_are_unique( # TODO(b/337925142): Avoid a "SELECT *" subquery here by ensuring # table_expression only selects just index_cols. - is_unique_sql = bigframes.core.sql.is_distinct_sql(index_cols, table.reference) + is_unique_sql = bigframes.core.sql.is_distinct_sql( + index_cols, table.get_table_ref() + ) job_config = bigquery.QueryJobConfig() results, _ = bigframes.session._io.bigquery.start_query_with_client( bq_client=bqclient, @@ -352,49 +284,8 @@ def check_if_index_columns_are_unique( return () -def _get_primary_keys( - table: google.cloud.bigquery.table.Table, -) -> List[str]: - """Get primary keys from table if they are set.""" - - primary_keys: List[str] = [] - if ( - (table_constraints := getattr(table, "table_constraints", None)) is not None - and (primary_key := table_constraints.primary_key) is not None - # This will be False for either None or empty list. - # We want primary_keys = None if no primary keys are set. - and (columns := primary_key.columns) - ): - primary_keys = columns if columns is not None else [] - - return primary_keys - - -def _is_table_clustered_or_partitioned( - table: google.cloud.bigquery.table.Table, -) -> bool: - """Returns True if the table is clustered or partitioned.""" - - # Could be None or an empty tuple if it's not clustered, both of which are - # falsey. - if table.clustering_fields: - return True - - if ( - time_partitioning := table.time_partitioning - ) is not None and time_partitioning.type_ is not None: - return True - - if ( - range_partitioning := table.range_partitioning - ) is not None and range_partitioning.field is not None: - return True - - return False - - def get_index_cols( - table: google.cloud.bigquery.table.Table, + table: Union[bq_data.GbqNativeTable, bq_data.BiglakeIcebergTable], index_col: Iterable[str] | str | Iterable[int] @@ -403,7 +294,7 @@ def get_index_cols( *, rename_to_schema: Optional[Dict[str, str]] = None, default_index_type: bigframes.enums.DefaultIndexKind = bigframes.enums.DefaultIndexKind.SEQUENTIAL_INT64, -) -> List[str]: +) -> Sequence[str]: """ If we can get a total ordering from the table, such as via primary key column(s), then return those too so that ordering generation can be @@ -411,9 +302,9 @@ def get_index_cols( """ # Transform index_col -> index_cols so we have a variable that is # always a list of column names (possibly empty). - schema_len = len(table.schema) + schema_len = len(table.physical_schema) - index_cols: List[str] = [] + index_cols = [] if isinstance(index_col, bigframes.enums.DefaultIndexKind): if index_col == bigframes.enums.DefaultIndexKind.SEQUENTIAL_INT64: # User has explicity asked for a default, sequential index. @@ -438,7 +329,7 @@ def get_index_cols( f"Integer index {index_col} is out of bounds " f"for table with {schema_len} columns (must be >= 0 and < {schema_len})." ) - index_cols = [table.schema[index_col].name] + index_cols = [table.physical_schema[index_col].name] elif isinstance(index_col, Iterable): for item in index_col: if isinstance(item, str): @@ -451,7 +342,7 @@ def get_index_cols( f"Integer index {item} is out of bounds " f"for table with {schema_len} columns (must be >= 0 and < {schema_len})." ) - index_cols.append(table.schema[item].name) + index_cols.append(table.physical_schema[item].name) else: raise TypeError( "If index_col is an iterable, it must contain either strings " @@ -466,19 +357,19 @@ def get_index_cols( # If the isn't an index selected, use the primary keys of the table as the # index. If there are no primary keys, we'll return an empty list. if len(index_cols) == 0: - primary_keys = _get_primary_keys(table) + primary_keys = table.primary_key or () # If table has clustering/partitioning, fail if we haven't been able to # find index_cols to use. This is to avoid unexpected performance and # resource utilization because of the default sequential index. See # internal issue 335727141. if ( - _is_table_clustered_or_partitioned(table) + (table.partition_col is not None or table.cluster_cols) and not primary_keys and default_index_type == bigframes.enums.DefaultIndexKind.SEQUENTIAL_INT64 ): msg = bfe.format_message( - f"Table '{str(table.reference)}' is clustered and/or " + f"Table '{str(table.get_full_id())}' is clustered and/or " "partitioned, but BigQuery DataFrames was not able to find a " "suitable index. To avoid this warning, set at least one of: " # TODO(b/338037499): Allow max_results to override this too, @@ -490,6 +381,6 @@ def get_index_cols( # If there are primary keys defined, the query engine assumes these # columns are unique, even if the constraint is not enforced. We make # the same assumption and use these columns as the total ordering keys. - index_cols = primary_keys + index_cols = list(primary_keys) return index_cols diff --git a/bigframes/session/bq_caching_executor.py b/bigframes/session/bq_caching_executor.py index 2f5ec035dc6..5ef91a4b6f2 100644 --- a/bigframes/session/bq_caching_executor.py +++ b/bigframes/session/bq_caching_executor.py @@ -683,13 +683,12 @@ def _execute_plan_gbq( result_bf_schema = _result_schema(og_schema, list(compiled.sql_schema)) dst = query_job.destination result_bq_data = bq_data.BigqueryDataSource( - table=bq_data.GbqTable( - dst.project, - dst.dataset_id, - dst.table_id, + table=bq_data.GbqNativeTable.from_ref_and_schema( + dst, tuple(compiled_schema), - is_physically_stored=True, cluster_cols=tuple(cluster_cols), + location=iterator.location or self.storage_manager.location, + table_type="TABLE", ), schema=result_bf_schema, ordering=compiled.row_order, diff --git a/bigframes/session/dry_runs.py b/bigframes/session/dry_runs.py index bd54bb65d7b..99ac2b360e3 100644 --- a/bigframes/session/dry_runs.py +++ b/bigframes/session/dry_runs.py @@ -14,16 +14,18 @@ from __future__ import annotations import copy -from typing import Any, Dict, List, Sequence +from typing import Any, Dict, List, Sequence, Union from google.cloud import bigquery import pandas from bigframes import dtypes -from bigframes.core import bigframe_node, nodes +from bigframes.core import bigframe_node, bq_data, nodes -def get_table_stats(table: bigquery.Table) -> pandas.Series: +def get_table_stats( + table: Union[bq_data.GbqNativeTable, bq_data.BiglakeIcebergTable] +) -> pandas.Series: values: List[Any] = [] index: List[Any] = [] @@ -32,7 +34,7 @@ def get_table_stats(table: bigquery.Table) -> pandas.Series: values.append(False) # Populate column and index types - col_dtypes = dtypes.bf_type_from_type_kind(table.schema) + col_dtypes = dtypes.bf_type_from_type_kind(table.physical_schema) index.append("columnCount") values.append(len(col_dtypes)) index.append("columnDtypes") @@ -40,17 +42,22 @@ def get_table_stats(table: bigquery.Table) -> pandas.Series: # Add raw BQ schema index.append("bigquerySchema") - values.append(table.schema) + values.append(table.physical_schema) - for key in ("numBytes", "numRows", "location", "type"): - index.append(key) - values.append(table._properties[key]) + index.append("numBytes") + values.append(table.metadata.numBytes) + index.append("numRows") + values.append(table.metadata.numRows) + index.append("location") + values.append(table.metadata.location) + index.append("type") + values.append(table.metadata.type) index.append("creationTime") - values.append(table.created) + values.append(table.metadata.created_time) index.append("lastModifiedTime") - values.append(table.modified) + values.append(table.metadata.modified_time) return pandas.Series(values, index=index) diff --git a/bigframes/session/iceberg.py b/bigframes/session/iceberg.py new file mode 100644 index 00000000000..acfce7b0bdc --- /dev/null +++ b/bigframes/session/iceberg.py @@ -0,0 +1,204 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import annotations + +import datetime +import json +from typing import List +import urllib.parse + +import google.auth.transport.requests +import google.cloud.bigquery as bq +import pyiceberg +from pyiceberg.catalog import load_catalog +import pyiceberg.schema +import pyiceberg.types +import requests + +from bigframes.core import bq_data + + +def get_table( + user_project_id: str, full_table_id: str, credentials +) -> bq_data.BiglakeIcebergTable: + table_parts = full_table_id.split(".") + if len(table_parts) != 4: + raise ValueError("Iceberg catalog table must contain exactly 4 parts") + + catalog_project_id, catalog_id, namespace, table = table_parts + + credentials.refresh(google.auth.transport.requests.Request()) + token = credentials.token + + base_uri = "https://biglake.googleapis.com/iceberg/v1/restcatalog" + + # Maybe can drop the pyiceberg dependency at some point, but parsing through raw schema json seems a bit painful + catalog = load_catalog( + f"{catalog_project_id}.{catalog_id}", + **{ + "uri": base_uri, + "header.x-goog-user-project": user_project_id, + "oauth2-server-uri": "https://oauth2.googleapis.com/token", + "token": token, + "warehouse": f"gs://{catalog_id}", + }, + ) + + response = requests.get( + f"{base_uri}/extensions/projects/{urllib.parse.quote(catalog_project_id, safe='')}/catalogs/{urllib.parse.quote(catalog_id, safe='')}", + headers={ + "Authorization": f"Bearer {credentials.token}", + "Content-Type": "application/json", + "header.x-goog-user-project": user_project_id, + }, + ) + response.raise_for_status() + location = _extract_location_from_catalog_extension_data(response) + + iceberg_table = catalog.load_table(f"{namespace}.{table}") + bq_schema = pyiceberg.schema.visit(iceberg_table.schema(), SchemaVisitor()) + # TODO: Handle physical layout to help optimize + # TODO: Use snapshot metadata to get row, byte counts + return bq_data.BiglakeIcebergTable( + catalog_project_id, + catalog_id, + namespace, + table, + physical_schema=bq_schema, # type: ignore + cluster_cols=(), + metadata=bq_data.TableMetadata( + location=location, + type="TABLE", + modified_time=datetime.datetime.fromtimestamp( + iceberg_table.metadata.last_updated_ms / 1000.0 + ), + ), + ) + + +def _extract_location_from_catalog_extension_data(data): + catalog_extension_metadata = json.loads(data.text) + storage_region = catalog_extension_metadata["storage-regions"][ + 0 + ] # assumption: exactly 1 region + replicas = tuple(item["region"] for item in catalog_extension_metadata["replicas"]) + return bq_data.GcsRegion(storage_region, replicas) + + +class SchemaVisitor(pyiceberg.schema.SchemaVisitorPerPrimitiveType[bq.SchemaField]): + def schema(self, schema: pyiceberg.schema.Schema, struct_result: bq.SchemaField) -> tuple[bq.SchemaField, ...]: # type: ignore + return tuple(f for f in struct_result.fields) + + def struct( + self, struct: pyiceberg.types.StructType, field_results: List[bq.SchemaField] + ) -> bq.SchemaField: + return bq.SchemaField("", "RECORD", fields=field_results) + + def field( + self, field: pyiceberg.types.NestedField, field_result: bq.SchemaField + ) -> bq.SchemaField: + return bq.SchemaField( + field.name, + field_result.field_type, + mode=field_result.mode or "NULLABLE", + fields=field_result.fields, + ) + + def map( + self, + map_type: pyiceberg.types.MapType, + key_result: bq.SchemaField, + value_result: bq.SchemaField, + ) -> bq.SchemaField: + return bq.SchemaField("", "UNKNOWN") + + def list( + self, list_type: pyiceberg.types.ListType, element_result: bq.SchemaField + ) -> bq.SchemaField: + return bq.SchemaField( + "", element_result.field_type, mode="REPEATED", fields=element_result.fields + ) + + def visit_fixed(self, fixed_type: pyiceberg.types.FixedType) -> bq.SchemaField: + return bq.SchemaField("", "UNKNOWN") + + def visit_decimal( + self, decimal_type: pyiceberg.types.DecimalType + ) -> bq.SchemaField: + # BIGNUMERIC not supported in iceberg tables yet, so just assume numeric + return bq.SchemaField("", "NUMERIC") + + def visit_boolean( + self, boolean_type: pyiceberg.types.BooleanType + ) -> bq.SchemaField: + return bq.SchemaField("", "NUMERIC") + + def visit_integer( + self, integer_type: pyiceberg.types.IntegerType + ) -> bq.SchemaField: + return bq.SchemaField("", "INTEGER") + + def visit_long(self, long_type: pyiceberg.types.LongType) -> bq.SchemaField: + return bq.SchemaField("", "INTEGER") + + def visit_float(self, float_type: pyiceberg.types.FloatType) -> bq.SchemaField: + # 32-bit IEEE 754 floating point + return bq.SchemaField("", "FLOAT") + + def visit_double(self, double_type: pyiceberg.types.DoubleType) -> bq.SchemaField: + # 64-bit IEEE 754 floating point + return bq.SchemaField("", "FLOAT") + + def visit_date(self, date_type: pyiceberg.types.DateType) -> bq.SchemaField: + # Date encoded as an int + return bq.SchemaField("", "DATE") + + def visit_time(self, time_type: pyiceberg.types.TimeType) -> bq.SchemaField: + return bq.SchemaField("", "TIME") + + def visit_timestamp( + self, timestamp_type: pyiceberg.types.TimestampType + ) -> bq.SchemaField: + return bq.SchemaField("", "DATETIME") + + def visit_timestamp_ns( + self, timestamp_type: pyiceberg.types.TimestampNanoType + ) -> bq.SchemaField: + return bq.SchemaField("", "UNKNOWN") + + def visit_timestamptz( + self, timestamptz_type: pyiceberg.types.TimestamptzType + ) -> bq.SchemaField: + return bq.SchemaField("", "TIMESTAMP") + + def visit_timestamptz_ns( + self, timestamptz_ns_type: pyiceberg.types.TimestamptzNanoType + ) -> bq.SchemaField: + return bq.SchemaField("", "UNKNOWN") + + def visit_string(self, string_type: pyiceberg.types.StringType) -> bq.SchemaField: + return bq.SchemaField("", "STRING") + + def visit_uuid(self, uuid_type: pyiceberg.types.UUIDType) -> bq.SchemaField: + return bq.SchemaField("", "UNKNOWN") + + def visit_unknown( + self, unknown_type: pyiceberg.types.UnknownType + ) -> bq.SchemaField: + """Type `UnknownType` can be promoted to any primitive type in V3+ tables per the Iceberg spec.""" + return bq.SchemaField("", "UNKNOWN") + + def visit_binary(self, binary_type: pyiceberg.types.BinaryType) -> bq.SchemaField: + return bq.SchemaField("", "BINARY") diff --git a/bigframes/session/loader.py b/bigframes/session/loader.py index 9c18d727c80..bfef5f809d9 100644 --- a/bigframes/session/loader.py +++ b/bigframes/session/loader.py @@ -39,7 +39,9 @@ Sequence, Tuple, TypeVar, + Union, ) +import warnings import bigframes_vendored.constants as constants import bigframes_vendored.pandas.io.gbq as third_party_pandas_gbq @@ -68,11 +70,13 @@ import bigframes.core.events import bigframes.core.schema as schemata import bigframes.dtypes +import bigframes.exceptions as bfe import bigframes.formatting_helpers as formatting_helpers from bigframes.session import dry_runs import bigframes.session._io.bigquery as bf_io_bigquery import bigframes.session._io.bigquery.read_gbq_query as bf_read_gbq_query import bigframes.session._io.bigquery.read_gbq_table as bf_read_gbq_table +import bigframes.session.iceberg import bigframes.session.metrics import bigframes.session.temporary_storage import bigframes.session.time as session_time @@ -98,6 +102,8 @@ bigframes.dtypes.TIMEDELTA_DTYPE: "INTEGER", } +TABLE_TYPE = Union[bq_data.GbqNativeTable, bq_data.BiglakeIcebergTable] + def _to_index_cols( index_col: Iterable[str] | str | bigframes.enums.DefaultIndexKind = (), @@ -287,7 +293,7 @@ def __init__( self._default_index_type = default_index_type self._scan_index_uniqueness = scan_index_uniqueness self._force_total_order = force_total_order - self._df_snapshot: Dict[str, Tuple[datetime.datetime, bigquery.Table]] = {} + self._df_snapshot: Dict[str, Tuple[datetime.datetime, TABLE_TYPE]] = {} self._metrics = metrics self._publisher = publisher # Unfortunate circular reference, but need to pass reference when constructing objects @@ -391,7 +397,7 @@ def load_data( # must get table metadata after load job for accurate metadata destination_table = self._bqclient.get_table(load_table_destination) return bq_data.BigqueryDataSource( - bq_data.GbqTable.from_table(destination_table), + bq_data.GbqNativeTable.from_table(destination_table), schema=schema_w_offsets, ordering=ordering.TotalOrdering.from_offset_col(offsets_col), n_rows=data.metadata.row_count, @@ -445,7 +451,7 @@ def stream_data( ) destination_table = self._bqclient.get_table(load_table_destination) return bq_data.BigqueryDataSource( - bq_data.GbqTable.from_table(destination_table), + bq_data.GbqNativeTable.from_table(destination_table), schema=schema_w_offsets, ordering=ordering.TotalOrdering.from_offset_col(offsets_col), n_rows=data.metadata.row_count, @@ -544,8 +550,12 @@ def request_generator(): for error in response.stream_errors: raise ValueError(f"Errors commiting stream {error}") - result_table = bq_data.GbqTable.from_ref_and_schema( - bq_table_ref, schema=bq_schema, cluster_cols=[offsets_col] + result_table = bq_data.GbqNativeTable.from_ref_and_schema( + bq_table_ref, + schema=bq_schema, + cluster_cols=[offsets_col], + location=self._storage_manager.location, + table_type="TABLE", ) return bq_data.BigqueryDataSource( result_table, @@ -716,33 +726,33 @@ def read_gbq_table( # Fetch table metadata and validate # --------------------------------- - time_travel_timestamp, table = bf_read_gbq_table.get_table_metadata( - self._bqclient, + time_travel_timestamp, table = self._get_table_metadata( table_id=table_id, default_project=self._bqclient.project, bq_time=self._clock.get_time(), - cache=self._df_snapshot, use_cache=use_cache, - publisher=self._publisher, ) - if table.location.casefold() != self._storage_manager.location.casefold(): + if not bq_data.is_compatible( + table.metadata.location, self._storage_manager.location + ): raise ValueError( - f"Current session is in {self._storage_manager.location} but dataset '{table.project}.{table.dataset_id}' is located in {table.location}" + f"Current session is in {self._storage_manager.location} but table '{table.get_full_id()}' is located in {table.metadata.location}" ) - table_column_names = [field.name for field in table.schema] + table_column_names = [field.name for field in table.physical_schema] rename_to_schema: Optional[Dict[str, str]] = None if names is not None: _check_names_param(names, index_col, columns, table_column_names) # Additional unnamed columns is going to set as index columns len_names = len(list(names)) - len_schema = len(table.schema) + len_schema = len(table.physical_schema) if len(columns) == 0 and len_names < len_schema: index_col = range(len_schema - len_names) names = [ - field.name for field in table.schema[: len_schema - len_names] + field.name + for field in table.physical_schema[: len_schema - len_names] ] + list(names) assert len_schema >= len_names @@ -799,7 +809,7 @@ def read_gbq_table( itertools.chain(index_cols, columns) if columns else () ) query = bf_io_bigquery.to_query( - f"{table.project}.{table.dataset_id}.{table.table_id}", + table.get_full_id(quoted=False), columns=all_columns, sql_predicate=bf_io_bigquery.compile_filters(filters) if filters @@ -884,7 +894,7 @@ def read_gbq_table( bigframes.core.events.ExecutionFinished(), ) - selected_cols = None if include_all_columns else index_cols + columns + selected_cols = None if include_all_columns else (*index_cols, *columns) array_value = core.ArrayValue.from_table( table, columns=selected_cols, @@ -959,6 +969,90 @@ def read_gbq_table( df.sort_index() return df + def _get_table_metadata( + self, + *, + table_id: str, + default_project: Optional[str], + bq_time: datetime.datetime, + use_cache: bool = True, + ) -> Tuple[ + datetime.datetime, Union[bq_data.GbqNativeTable, bq_data.BiglakeIcebergTable] + ]: + """Get the table metadata, either from cache or via REST API.""" + + cached_table = self._df_snapshot.get(table_id) + if use_cache and cached_table is not None: + snapshot_timestamp, table = cached_table + + if bf_read_gbq_table.is_time_travel_eligible( + bqclient=self._bqclient, + table=table, + columns=None, + snapshot_time=snapshot_timestamp, + filter_str=None, + # Don't warn, because that will already have been taken care of. + should_warn=False, + should_dry_run=False, + publisher=self._publisher, + ): + # This warning should only happen if the cached snapshot_time will + # have any effect on bigframes (b/437090788). For example, with + # cached query results, such as after re-running a query, time + # travel won't be applied and thus this check is irrelevent. + # + # In other cases, such as an explicit read_gbq_table(), Cache hit + # could be unexpected. See internal issue 329545805. Raise a + # warning with more information about how to avoid the problems + # with the cache. + msg = bfe.format_message( + f"Reading cached table from {snapshot_timestamp} to avoid " + "incompatibilies with previous reads of this table. To read " + "the latest version, set `use_cache=False` or close the " + "current session with Session.close() or " + "bigframes.pandas.close_session()." + ) + # There are many layers before we get to (possibly) the user's code: + # pandas.read_gbq_table + # -> with_default_session + # -> Session.read_gbq_table + # -> _read_gbq_table + # -> _get_snapshot_sql_and_primary_key + # -> get_snapshot_datetime_and_table_metadata + warnings.warn(msg, category=bfe.TimeTravelCacheWarning, stacklevel=7) + + return cached_table + + if bf_read_gbq_table.is_information_schema(table_id): + client_table = bf_read_gbq_table.get_information_schema_metadata( + bqclient=self._bqclient, + table_id=table_id, + default_project=default_project, + ) + table = bq_data.GbqNativeTable.from_table(client_table) + elif bq_data.is_irc_table(table_id): + table = bigframes.session.iceberg.get_table( + self._bqclient.project, table_id, self._bqclient._credentials + ) + else: + table_ref = google.cloud.bigquery.table.TableReference.from_string( + table_id, default_project=default_project + ) + client_table = self._bqclient.get_table(table_ref) + table = bq_data.GbqNativeTable.from_table(client_table) + + # local time will lag a little bit do to network latency + # make sure it is at least table creation time. + # This is relevant if the table was created immediately before loading it here. + if (table.metadata.created_time is not None) and ( + table.metadata.created_time > bq_time + ): + bq_time = table.metadata.created_time + + cached_table = (bq_time, table) + self._df_snapshot[table_id] = cached_table + return cached_table + def load_file( self, filepath_or_buffer: str | IO["bytes"], @@ -1359,6 +1453,7 @@ def _start_query_with_job( def _transform_read_gbq_configuration(configuration: Optional[dict]) -> dict: + """ For backwards-compatibility, convert any previously client-side only parameters such as timeoutMs to the property name expected by the REST API. diff --git a/bigframes/session/read_api_execution.py b/bigframes/session/read_api_execution.py index c7138f7b307..9f2d196ce8e 100644 --- a/bigframes/session/read_api_execution.py +++ b/bigframes/session/read_api_execution.py @@ -17,7 +17,7 @@ from google.cloud import bigquery_storage_v1 -from bigframes.core import bigframe_node, nodes, rewrite +from bigframes.core import bigframe_node, bq_data, nodes, rewrite from bigframes.session import executor, semi_executor @@ -47,6 +47,9 @@ def execute( if node.explicitly_ordered and ordered: return None + if not isinstance(node.source.table, bq_data.GbqNativeTable): + return None + if not node.source.table.is_physically_stored: return None diff --git a/bigframes/streaming/dataframe.py b/bigframes/streaming/dataframe.py index b7b67178cea..1dfd0529c7e 100644 --- a/bigframes/streaming/dataframe.py +++ b/bigframes/streaming/dataframe.py @@ -251,7 +251,7 @@ def _from_table_df(cls, df: dataframe.DataFrame) -> StreamingDataFrame: def _original_table(self): def traverse(node: nodes.BigFrameNode): if isinstance(node, nodes.ReadTableNode): - return f"{node.source.table.project_id}.{node.source.table.dataset_id}.{node.source.table.table_id}" + return node.source.table.get_full_id(quoted=False) for child in node.child_nodes: original_table = traverse(child) if original_table: diff --git a/setup.py b/setup.py index d393375d142..2314c73b784 100644 --- a/setup.py +++ b/setup.py @@ -58,6 +58,7 @@ "humanize >=4.6.0", "matplotlib >=3.7.1", "db-dtypes >=1.4.2", + "pyiceberg >= 0.7.1", # For vendored ibis-framework. "atpublic>=2.3,<6", "python-dateutil>=2.8.2,<3", diff --git a/testing/constraints-3.10.txt b/testing/constraints-3.10.txt index b74ff81063b..2414bc546b5 100644 --- a/testing/constraints-3.10.txt +++ b/testing/constraints-3.10.txt @@ -19,11 +19,11 @@ pandas==1.5.3 pandas-gbq==0.26.1 pyarrow==15.0.2 pydata-google-auth==1.8.2 +pyiceberg==0.7.1 requests==2.27.1 scikit-learn==1.2.2 shapely==1.8.5 tabulate==0.9 -ipywidgets==7.7.1 humanize==4.6.0 matplotlib==3.7.1 db-dtypes==1.4.2 @@ -32,8 +32,94 @@ atpublic==2.3 python-dateutil==2.8.2 pytz==2022.7 toolz==0.11 -typing-extensions==4.5.0 +typing-extensions==4.6.1 rich==12.4.4 # For anywidget mode anywidget>=0.9.18 traitlets==5.0.0 +# constrained dependencies to give pip a helping hand +aiohappyeyeballs==2.6.1 +aiohttp==3.13.3 +aiosignal==1.4.0 +anywidget==0.9.21 +asttokens==3.0.1 +async-timeout==5.0.1 +attrs==25.4.0 +cachetools==5.5.2 +certifi==2026.1.4 +charset-normalizer==2.0.12 +click==8.3.1 +click-plugins==1.1.1.2 +cligj==0.7.2 +comm==0.2.3 +commonmark==0.9.1 +contourpy==1.3.2 +coverage==7.13.3 +cycler==0.12.1 +db-dtypes==1.4.2 +decorator==5.2.1 +exceptiongroup==1.2.2 +executing==2.2.1 +fiona==1.10.1 +fonttools==4.61.1 +freezegun==1.5.5 +frozenlist==1.8.0 +google-api-core==2.29.0 +google-auth-oauthlib==1.2.4 +google-cloud-bigquery-storage==2.36.0 +google-cloud-core==2.5.0 +google-crc32c==1.8.0 +google-resumable-media==2.8.0 +googleapis-common-protos==1.72.0 +grpc-google-iam-v1==0.14.2 +grpcio==1.74.0 +grpcio-status==1.62.3 +idna==3.11 +iniconfig2.3.0 +ipython==8.21.0 +ipython-genutils==0.2.0 +ipywidgets==8.1.8 +jedi==0.19.2 +joblib==1.5.3 +jupyterlab_widgets==3.0.16 +kiwisolver==1.4.9 +matplotlib-inline==0.2.1 +mock==5.2.0 +moc==5.2.0 +multidict==6.7.1 +oauthlib==3.3.1 +packaging==26.0 +parso==0.8.5 +pexpect==4.9.0 +pillow==12.1.0 +pluggy==1.6.0 +prompt_toolkit==3.0.52 +propcache==0.4.1 +proto-plus==1.27.1 +protobuf==4.25.8 +psygnal==0.15.1 +ptyprocess==0.7.0 +pure_eval==0.2.3 +pyasn1==0.6.2 +pyasn1_modules==0.4.2 +Pygments==2.19.2 +pyparsing==3.3.2 +pyproj==3.7.1 +pytest==8.4.2 +pytest-cov==7.0.0 +pytest-snapshot==0.9.0 +pytest-timeout==2.4.0 +python-dateutil==2.8.2 +requests-oauthlib==2.0.0 +rsa==4.9.1 +scipy==1.15.3 +setuptools==80.9.0 +six==1.17.0 +stack-data==0.6.3 +threadpoolctl==3.6.0 +tomli==2.4.0 +urllib3==1.26.20 +wcwidth==0.6.0 +wheel==0.45.1 +widgetsnbextension==4.0.15 +yarl==1.22.0 diff --git a/tests/system/small/test_iceberg.py b/tests/system/small/test_iceberg.py new file mode 100644 index 00000000000..ea0acc6214e --- /dev/null +++ b/tests/system/small/test_iceberg.py @@ -0,0 +1,49 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import pytest + +import bigframes +import bigframes.pandas as bpd + + +@pytest.fixture() +def fresh_global_session(): + bpd.reset_session() + yield None + bpd.close_session() + # Undoes side effect of using ths global session to read table + bpd.options.bigquery.location = None + + +def test_read_iceberg_table_w_location(): + session = bigframes.Session(bigframes.BigQueryOptions(location="us-central1")) + df = session.read_gbq( + "bigquery-public-data.biglake-public-nyc-taxi-iceberg.public_data.nyc_taxicab_2021" + ) + assert df.shape == (30904427, 20) + + +def test_read_iceberg_table_w_wrong_location(): + session = bigframes.Session(bigframes.BigQueryOptions(location="europe-west1")) + with pytest.raises(ValueError, match="Current session is in europe-west1"): + session.read_gbq( + "bigquery-public-data.biglake-public-nyc-taxi-iceberg.public_data.nyc_taxicab_2021" + ) + + +def test_read_iceberg_table_wo_location(fresh_global_session): + df = bpd.read_gbq( + "bigquery-public-data.biglake-public-nyc-taxi-iceberg.public_data.nyc_taxicab_2021" + ) + assert df.shape == (30904427, 20) diff --git a/tests/unit/core/compile/sqlglot/test_compile_readtable.py b/tests/unit/core/compile/sqlglot/test_compile_readtable.py index dd776d9a8f1..c6ffa215f61 100644 --- a/tests/unit/core/compile/sqlglot/test_compile_readtable.py +++ b/tests/unit/core/compile/sqlglot/test_compile_readtable.py @@ -17,6 +17,7 @@ import google.cloud.bigquery as bigquery import pytest +from bigframes.core import bq_data import bigframes.pandas as bpd pytest.importorskip("pytest_snapshot") @@ -63,7 +64,7 @@ def test_compile_readtable_w_system_time( table._properties["location"] = compiler_session._location compiler_session._loader._df_snapshot[str(table_ref)] = ( datetime.datetime(2025, 11, 9, 3, 4, 5, 678901, tzinfo=datetime.timezone.utc), - table, + bq_data.GbqNativeTable.from_table(table), ) bf_df = compiler_session.read_gbq_table(str(table_ref)) snapshot.assert_match(bf_df.sql, "out.sql") diff --git a/tests/unit/core/rewrite/conftest.py b/tests/unit/core/rewrite/conftest.py index 8c7ee290ae6..6a63305806b 100644 --- a/tests/unit/core/rewrite/conftest.py +++ b/tests/unit/core/rewrite/conftest.py @@ -16,8 +16,9 @@ import google.cloud.bigquery import pytest +import bigframes +from bigframes.core import bq_data import bigframes.core as core -import bigframes.core.schema TABLE_REF = google.cloud.bigquery.TableReference.from_string("project.dataset.table") SCHEMA = ( @@ -71,7 +72,7 @@ def fake_session(): def leaf(fake_session, table): return core.ArrayValue.from_table( session=fake_session, - table=table, + table=bq_data.GbqNativeTable.from_table(table), ).node @@ -79,5 +80,5 @@ def leaf(fake_session, table): def leaf_too(fake_session, table_too): return core.ArrayValue.from_table( session=fake_session, - table=table_too, + table=bq_data.GbqNativeTable.from_table(table_too), ).node diff --git a/tests/unit/core/rewrite/test_identifiers.py b/tests/unit/core/rewrite/test_identifiers.py index 09904ac4ba2..9def077a894 100644 --- a/tests/unit/core/rewrite/test_identifiers.py +++ b/tests/unit/core/rewrite/test_identifiers.py @@ -13,6 +13,7 @@ # limitations under the License. import typing +from bigframes.core import bq_data import bigframes.core as core import bigframes.core.expression as ex import bigframes.core.identifiers as identifiers @@ -55,7 +56,7 @@ def test_remap_variables_nested_join_stability(leaf, fake_session, table): # Create two more distinct leaf nodes leaf2_uncached = core.ArrayValue.from_table( session=fake_session, - table=table, + table=bq_data.GbqNativeTable.from_table(table), ).node leaf2 = leaf2_uncached.remap_vars( { @@ -65,7 +66,7 @@ def test_remap_variables_nested_join_stability(leaf, fake_session, table): ) leaf3_uncached = core.ArrayValue.from_table( session=fake_session, - table=table, + table=bq_data.GbqNativeTable.from_table(table), ).node leaf3 = leaf3_uncached.remap_vars( { diff --git a/tests/unit/session/test_read_gbq_table.py b/tests/unit/session/test_read_gbq_table.py index ce9b587d6bd..12d44282a37 100644 --- a/tests/unit/session/test_read_gbq_table.py +++ b/tests/unit/session/test_read_gbq_table.py @@ -20,6 +20,7 @@ import google.cloud.bigquery import pytest +from bigframes.core import bq_data import bigframes.enums import bigframes.exceptions import bigframes.session._io.bigquery.read_gbq_table as bf_read_gbq_table @@ -81,7 +82,9 @@ def test_infer_unique_columns(index_cols, primary_keys, expected): }, } - result = bf_read_gbq_table.infer_unique_columns(table, index_cols) + result = bf_read_gbq_table.infer_unique_columns( + bq_data.GbqNativeTable.from_table(table), index_cols + ) assert result == expected @@ -140,7 +143,7 @@ def test_check_if_index_columns_are_unique(index_cols, values_distinct, expected result = bf_read_gbq_table.check_if_index_columns_are_unique( bqclient=bqclient, - table=table, + table=bq_data.GbqNativeTable.from_table(table), index_cols=index_cols, publisher=session._publisher, ) @@ -170,7 +173,7 @@ def test_get_index_cols_warns_if_clustered_but_sequential_index(): with pytest.warns(bigframes.exceptions.DefaultIndexWarning, match="is clustered"): bf_read_gbq_table.get_index_cols( - table, + bq_data.GbqNativeTable.from_table(table), index_col=(), default_index_type=bigframes.enums.DefaultIndexKind.SEQUENTIAL_INT64, ) @@ -182,7 +185,7 @@ def test_get_index_cols_warns_if_clustered_but_sequential_index(): "error", category=bigframes.exceptions.DefaultIndexWarning ) bf_read_gbq_table.get_index_cols( - table, + bq_data.GbqNativeTable.from_table(table), index_col=(), default_index_type=bigframes.enums.DefaultIndexKind.NULL, ) diff --git a/tests/unit/session/test_session.py b/tests/unit/session/test_session.py index fe73643b0c8..f64c08c4f8a 100644 --- a/tests/unit/session/test_session.py +++ b/tests/unit/session/test_session.py @@ -26,6 +26,7 @@ import bigframes from bigframes import version +from bigframes.core import bq_data import bigframes.enums import bigframes.exceptions from bigframes.testing import mocks @@ -243,7 +244,7 @@ def test_read_gbq_cached_table(): table._properties["type"] = "TABLE" session._loader._df_snapshot[str(table_ref)] = ( datetime.datetime(1999, 1, 2, 3, 4, 5, 678901, tzinfo=datetime.timezone.utc), - table, + bq_data.GbqNativeTable.from_table(table), ) session.bqclient._query_and_wait_bigframes = mock.MagicMock( @@ -274,7 +275,7 @@ def test_read_gbq_cached_table_doesnt_warn_for_anonymous_tables_and_doesnt_inclu table._properties["type"] = "TABLE" session._loader._df_snapshot[str(table_ref)] = ( datetime.datetime(1999, 1, 2, 3, 4, 5, 678901, tzinfo=datetime.timezone.utc), - table, + bq_data.GbqNativeTable.from_table(table), ) session.bqclient._query_and_wait_bigframes = mock.MagicMock( diff --git a/tests/unit/test_planner.py b/tests/unit/test_planner.py index 66d83f362dd..36a568a4165 100644 --- a/tests/unit/test_planner.py +++ b/tests/unit/test_planner.py @@ -19,9 +19,9 @@ import pandas as pd import bigframes.core as core +import bigframes.core.bq_data import bigframes.core.expression as ex import bigframes.core.identifiers as ids -import bigframes.core.schema import bigframes.operations as ops import bigframes.session.planner as planner @@ -38,7 +38,7 @@ type(FAKE_SESSION)._strictly_ordered = mock.PropertyMock(return_value=True) LEAF: core.ArrayValue = core.ArrayValue.from_table( session=FAKE_SESSION, - table=TABLE, + table=bigframes.core.bq_data.GbqNativeTable.from_table(TABLE), ) From 0434f267a398c433d7d80719e2e75109bea11752 Mon Sep 17 00:00:00 2001 From: Chelsea Lin Date: Wed, 11 Feb 2026 12:55:45 -0800 Subject: [PATCH 08/17] refactor: Enable `SELECT *` optimization in the sqlglot compiler (#2430) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes internal issue 481740136 🦕 --- bigframes/core/compile/sqlglot/compiler.py | 16 +++++++----- bigframes/core/compile/sqlglot/sqlglot_ir.py | 25 +++++++++++-------- bigframes/core/rewrite/select_pullup.py | 9 +++---- bigframes/core/sql_nodes.py | 4 +++ .../test_binary_compiler/test_corr/out.sql | 4 +-- .../test_binary_compiler/test_cov/out.sql | 4 +-- .../test_nullary_compiler/test_size/out.sql | 16 +----------- .../test_unary_compiler/test_mean/out.sql | 2 +- .../test_unary_compiler/test_std/out.sql | 2 +- .../test_compile_explode_dataframe/out.sql | 2 +- .../test_compile_explode_series/out.sql | 4 +-- .../out.sql | 4 +-- .../out.sql | 3 +-- .../out.sql | 16 +----------- 14 files changed, 45 insertions(+), 66 deletions(-) diff --git a/bigframes/core/compile/sqlglot/compiler.py b/bigframes/core/compile/sqlglot/compiler.py index 786c5a1ed1f..d74c1b38696 100644 --- a/bigframes/core/compile/sqlglot/compiler.py +++ b/bigframes/core/compile/sqlglot/compiler.py @@ -153,13 +153,17 @@ def compile_sql_select(node: sql_nodes.SqlSelectNode, child: ir.SQLGlotIR): for ordering in node.sorting ) - projected_cols: tuple[tuple[str, sge.Expression], ...] = tuple( - ( - cdef.id.sql, - expression_compiler.expression_compiler.compile_expression(cdef.expression), + projected_cols: tuple[tuple[str, sge.Expression], ...] = tuple() + if not node.is_star_selection: + projected_cols = tuple( + ( + cdef.id.sql, + expression_compiler.expression_compiler.compile_expression( + cdef.expression + ), + ) + for cdef in node.selections ) - for cdef in node.selections - ) sge_predicates = tuple( expression_compiler.expression_compiler.compile_expression(expression) diff --git a/bigframes/core/compile/sqlglot/sqlglot_ir.py b/bigframes/core/compile/sqlglot/sqlglot_ir.py index d0bd32697c4..efe5e09aff2 100644 --- a/bigframes/core/compile/sqlglot/sqlglot_ir.py +++ b/bigframes/core/compile/sqlglot/sqlglot_ir.py @@ -150,7 +150,7 @@ def from_table( if sql_predicate: select_expr = sge.Select().select(sge.Star()).from_(table_expr) select_expr = select_expr.where( - sg.parse_one(sql_predicate, dialect="bigquery"), append=False + sg.parse_one(sql_predicate, dialect=cls.dialect), append=False ) return cls(expr=select_expr, uid_gen=uid_gen) @@ -172,16 +172,19 @@ def select( if len(sorting) > 0: new_expr = new_expr.order_by(*sorting) - to_select = [ - sge.Alias( - this=expr, - alias=sge.to_identifier(id, quoted=self.quoted), - ) - if expr.alias_or_name != id - else expr - for id, expr in selections - ] - new_expr = new_expr.select(*to_select, append=False) + if len(selections) > 0: + to_select = [ + sge.Alias( + this=expr, + alias=sge.to_identifier(id, quoted=self.quoted), + ) + if expr.alias_or_name != id + else expr + for id, expr in selections + ] + new_expr = new_expr.select(*to_select, append=False) + else: + new_expr = new_expr.select(sge.Star(), append=False) if len(predicates) > 0: condition = _and(predicates) diff --git a/bigframes/core/rewrite/select_pullup.py b/bigframes/core/rewrite/select_pullup.py index 415182f8840..a15aba7663f 100644 --- a/bigframes/core/rewrite/select_pullup.py +++ b/bigframes/core/rewrite/select_pullup.py @@ -54,13 +54,12 @@ def pull_up_source_ids(node: nodes.ReadTableNode) -> nodes.BigFrameNode: if all(id.sql == source_id for id, source_id in node.scan_list.items): return node else: - source_ids = sorted( - set(scan_item.source_id for scan_item in node.scan_list.items) - ) new_scan_list = nodes.ScanList.from_items( [ - nodes.ScanItem(identifiers.ColumnId(source_id), source_id) - for source_id in source_ids + nodes.ScanItem( + identifiers.ColumnId(scan_item.source_id), scan_item.source_id + ) + for scan_item in node.scan_list.items ] ) new_source = dataclasses.replace(node, scan_list=new_scan_list) diff --git a/bigframes/core/sql_nodes.py b/bigframes/core/sql_nodes.py index a1624a10217..5d921de7aeb 100644 --- a/bigframes/core/sql_nodes.py +++ b/bigframes/core/sql_nodes.py @@ -142,6 +142,10 @@ def consumed_ids(self): def _node_expressions(self): raise NotImplementedError() + @property + def is_star_selection(self) -> bool: + return tuple(self.ids) == tuple(self.child.ids) + @functools.cache def get_id_mapping(self) -> dict[identifiers.ColumnId, ex.Expression]: return {cdef.id: cdef.expression for cdef in self.selections} 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 5c838f48827..08272882e6b 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,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT - `float64_col`, - `int64_col` + `int64_col`, + `float64_col` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` ), `bfcte_1` AS ( SELECT 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 eda082250a6..7f4463e3b8e 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,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT - `float64_col`, - `int64_col` + `int64_col`, + `float64_col` FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` ), `bfcte_1` AS ( SELECT 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 ed8e0c7619d..7a4393f8133 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,20 +1,6 @@ WITH `bfcte_0` AS ( SELECT - `bool_col`, - `bytes_col`, - `date_col`, - `datetime_col`, - `duration_col`, - `float64_col`, - `geography_col`, - `int64_col`, - `int64_too`, - `numeric_col`, - `rowindex`, - `rowindex_2`, - `string_col`, - `time_col`, - `timestamp_col` + * FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` ), `bfcte_1` AS ( SELECT 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 2f9d540776f..74319b646f2 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,8 +1,8 @@ WITH `bfcte_0` AS ( SELECT `bool_col`, - `duration_col`, `int64_col`, + `duration_col`, `int64_col` AS `bfcol_6`, `bool_col` AS `bfcol_7`, `duration_col` AS `bfcol_8` diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql index bc744258913..c57abdba4b5 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql @@ -1,8 +1,8 @@ WITH `bfcte_0` AS ( SELECT `bool_col`, - `duration_col`, `int64_col`, + `duration_col`, `int64_col` AS `bfcol_6`, `bool_col` AS `bfcol_7`, `duration_col` AS `bfcol_8` 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 5d9019439f2..4f05929e0c7 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,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT - `int_list_col`, `rowindex`, + `int_list_col`, `string_list_col` FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` ), `bfcte_1` AS ( 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 8ba4559da83..d5b42741d31 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,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT - `int_list_col`, - `rowindex` + `rowindex`, + `int_list_col` FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` ), `bfcte_1` AS ( SELECT diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_columns_filters/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_columns_filters/out.sql index c9a42b73f1a..2dae14b556e 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_columns_filters/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_columns_filters/out.sql @@ -6,7 +6,5 @@ WITH `bfcte_0` AS ( `rowindex` > 0 AND `string_col` IN ('Hello, World!') ) SELECT - `rowindex`, - `int64_col`, - `string_col` + * FROM `bfcte_0` \ 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 f65f3a10f0f..77a17ec893d 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,4 +1,3 @@ SELECT - `rowindex`, - `json_col` + * FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql index d188899e7c2..b579e3a6fed 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql @@ -1,17 +1,3 @@ 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 '2025-11-09T03:04:05.678901+00:00' \ No newline at end of file From fbaba0b47f49e4c69c87a8aaa1ee2addece482e7 Mon Sep 17 00:00:00 2001 From: Chelsea Lin Date: Wed, 11 Feb 2026 13:33:00 -0800 Subject: [PATCH 09/17] refactor: ensure only valid IDs are propagated in identifier remapping (#2448) --- bigframes/core/rewrite/identifiers.py | 20 +++------ tests/unit/core/rewrite/test_identifiers.py | 47 +++++++++++++++++++++ 2 files changed, 54 insertions(+), 13 deletions(-) diff --git a/bigframes/core/rewrite/identifiers.py b/bigframes/core/rewrite/identifiers.py index da43fdf8b93..8efcbb4a0b9 100644 --- a/bigframes/core/rewrite/identifiers.py +++ b/bigframes/core/rewrite/identifiers.py @@ -57,11 +57,6 @@ def remap_variables( new_root = root.transform_children(lambda node: remapped_children[node]) # Step 3: Transform the current node using the mappings from its children. - # "reversed" is required for InNode so that in case of a duplicate column ID, - # the left child's mapping is the one that's kept. - downstream_mappings: dict[identifiers.ColumnId, identifiers.ColumnId] = { - k: v for mapping in reversed(new_child_mappings) for k, v in mapping.items() - } if isinstance(new_root, nodes.InNode): new_root = typing.cast(nodes.InNode, new_root) new_root = dataclasses.replace( @@ -71,6 +66,9 @@ def remap_variables( ), ) else: + downstream_mappings: dict[identifiers.ColumnId, identifiers.ColumnId] = { + k: v for mapping in new_child_mappings for k, v in mapping.items() + } new_root = new_root.remap_refs(downstream_mappings) # Step 4: Create new IDs for columns defined by the current node. @@ -82,12 +80,8 @@ def remap_variables( new_root._validate() # Step 5: Determine which mappings to propagate up to the parent. - if root.defines_namespace: - # If a node defines a new namespace (e.g., a join), mappings from its - # children are not visible to its parents. - mappings_for_parent = node_defined_mappings - else: - # Otherwise, pass up the combined mappings from children and the current node. - mappings_for_parent = downstream_mappings | node_defined_mappings + propagated_mappings = { + old_id: new_id for old_id, new_id in zip(root.ids, new_root.ids) + } - return new_root, mappings_for_parent + return new_root, propagated_mappings diff --git a/tests/unit/core/rewrite/test_identifiers.py b/tests/unit/core/rewrite/test_identifiers.py index 9def077a894..54bcd85e3ea 100644 --- a/tests/unit/core/rewrite/test_identifiers.py +++ b/tests/unit/core/rewrite/test_identifiers.py @@ -15,10 +15,12 @@ from bigframes.core import bq_data import bigframes.core as core +import bigframes.core.agg_expressions as agg_ex import bigframes.core.expression as ex import bigframes.core.identifiers as identifiers import bigframes.core.nodes as nodes import bigframes.core.rewrite.identifiers as id_rewrite +import bigframes.operations.aggregations as agg_ops def test_remap_variables_single_node(leaf): @@ -52,6 +54,51 @@ def test_remap_variables_projection(leaf): assert set(mapping.values()) == {identifiers.ColumnId(f"id_{i}") for i in range(3)} +def test_remap_variables_aggregate(leaf): + # Aggregation: sum(col_a) AS sum_a + # Group by nothing + agg_op = agg_ex.UnaryAggregation( + op=agg_ops.sum_op, + arg=ex.DerefOp(leaf.fields[0].id), + ) + node = nodes.AggregateNode( + child=leaf, + aggregations=((agg_op, identifiers.ColumnId("sum_a")),), + by_column_ids=(), + ) + + id_generator = (identifiers.ColumnId(f"id_{i}") for i in range(100)) + _, mapping = id_rewrite.remap_variables(node, id_generator) + + # leaf has 2 columns: col_a, col_b + # AggregateNode defines 1 column: sum_a + # Output of AggregateNode should only be sum_a + assert len(mapping) == 1 + assert identifiers.ColumnId("sum_a") in mapping + + +def test_remap_variables_aggregate_with_grouping(leaf): + # Aggregation: sum(col_b) AS sum_b + # Group by col_a + agg_op = agg_ex.UnaryAggregation( + op=agg_ops.sum_op, + arg=ex.DerefOp(leaf.fields[1].id), + ) + node = nodes.AggregateNode( + child=leaf, + aggregations=((agg_op, identifiers.ColumnId("sum_b")),), + by_column_ids=(ex.DerefOp(leaf.fields[0].id),), + ) + + id_generator = (identifiers.ColumnId(f"id_{i}") for i in range(100)) + _, mapping = id_rewrite.remap_variables(node, id_generator) + + # Output should have 2 columns: col_a (grouping) and sum_b (agg) + assert len(mapping) == 2 + assert leaf.fields[0].id in mapping + assert identifiers.ColumnId("sum_b") in mapping + + def test_remap_variables_nested_join_stability(leaf, fake_session, table): # Create two more distinct leaf nodes leaf2_uncached = core.ArrayValue.from_table( From 078bd32ebd28af0d2cfba6bb874ba79e904183e2 Mon Sep 17 00:00:00 2001 From: Garrett Wu <6505921+GarrettWu@users.noreply.github.com> Date: Wed, 11 Feb 2026 16:41:57 -0800 Subject: [PATCH 10/17] docs: fix generate_text and generate_table input docs (#2455) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery-dataframes/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes # 🦕 --- bigframes/bigquery/_operations/ai.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bigframes/bigquery/_operations/ai.py b/bigframes/bigquery/_operations/ai.py index 7f9c3eb55f8..5fe9f306d55 100644 --- a/bigframes/bigquery/_operations/ai.py +++ b/bigframes/bigquery/_operations/ai.py @@ -522,10 +522,10 @@ def generate_text( model (bigframes.ml.base.BaseEstimator or str): The model to use for text generation. data (bigframes.pandas.DataFrame or bigframes.pandas.Series): - The data to generate embeddings for. If a Series is provided, it is - treated as the 'content' column. If a DataFrame is provided, it - must contain a 'content' column, or you must rename the column you - wish to embed to 'content'. + The data to generate text for. If a Series is provided, it is + treated as the 'prompt' column. If a DataFrame is provided, it + must contain a 'prompt' column, or you must rename the column you + wish to generate text to 'prompt'. temperature (float, optional): A FLOAT64 value that is used for sampling promiscuity. The value must be in the range ``[0.0, 1.0]``. A lower temperature works well @@ -638,10 +638,10 @@ def generate_table( model (bigframes.ml.base.BaseEstimator or str): The model to use for table generation. data (bigframes.pandas.DataFrame or bigframes.pandas.Series): - The data to generate embeddings for. If a Series is provided, it is - treated as the 'content' column. If a DataFrame is provided, it - must contain a 'content' column, or you must rename the column you - wish to embed to 'content'. + The data to generate table for. If a Series is provided, it is + treated as the 'prompt' column. If a DataFrame is provided, it + must contain a 'prompt' column, or you must rename the column you + wish to generate table to 'prompt'. output_schema (str): A string defining the output schema (e.g., "col1 STRING, col2 INT64"). temperature (float, optional): From 3409acd4e4177330bafa47452ed03b9e3a9d5b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a=20=28Swast=29?= Date: Thu, 12 Feb 2026 07:27:29 -0600 Subject: [PATCH 11/17] chore: librarian update image pull request: 20260210T185352Z (#2449) feat: update image to us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:1a2a85ab507aea26d787c06cc7979decb117164c81dd78a745982dfda80d4f68 --- .librarian/state.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.librarian/state.yaml b/.librarian/state.yaml index 70eb19713cd..8d933600672 100644 --- a/.librarian/state.yaml +++ b/.librarian/state.yaml @@ -1,4 +1,4 @@ -image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:e7cc6823efb073a8a26e7cefdd869f12ec228abfbd2a44aa9a7eacc284023677 +image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:1a2a85ab507aea26d787c06cc7979decb117164c81dd78a745982dfda80d4f68 libraries: - id: bigframes version: 2.35.0 From 543ce52c18269eab2a89886f226d1478dbabf9ba Mon Sep 17 00:00:00 2001 From: Shuowei Li Date: Thu, 12 Feb 2026 11:34:01 -0800 Subject: [PATCH 12/17] docs: use direct API for pdf chunk and pdf extract (#2452) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR updates `notebooks/multimodal/multimodal_dataframe.ipynb` to demonstrate PDF text extraction a chunking using custom BigQuery Python UDFs with the `pypdf` library. Fixes #<478952827> 🦕 --- .../multimodal/multimodal_dataframe.ipynb | 236 +++++++----------- 1 file changed, 97 insertions(+), 139 deletions(-) diff --git a/notebooks/multimodal/multimodal_dataframe.ipynb b/notebooks/multimodal/multimodal_dataframe.ipynb index b98a5e73378..3d3e2d0a6f8 100644 --- a/notebooks/multimodal/multimodal_dataframe.ipynb +++ b/notebooks/multimodal/multimodal_dataframe.ipynb @@ -1317,161 +1317,119 @@ "id": "iRUi8AjG7cIf" }, "source": [ - "### 5. PDF chunking function" + "### 5. PDF extraction and chunking function\n", + "\n", + "This section demonstrates how to extract text and chunk text from PDF files using custom BigQuery Python UDFs and the `pypdf` library." ] }, { "cell_type": "code", - "execution_count": 3, - "metadata": { - "id": "oDDuYtUm5Yiy" - }, + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ - "df_pdf = bpd.from_glob_path(\"gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/documents/*\", name=\"pdf\")" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "7jLpMYaj7nj8", - "outputId": "06d5456f-580f-4693-adff-2605104b056c" - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/core/log_adapter.py:182: FunctionAxisOnePreviewWarning: Blob Functions use bigframes DataFrame Managed function with axis=1 senario, which is a preview feature.\n", - " return method(*args, **kwargs)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:239: UserWarning: The `json_extract_string_array` is deprecated and will be removed in a\n", - "future version. Use `json_value_array` instead.\n", - " warnings.warn(bfe.format_message(msg), category=UserWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:239: UserWarning: The `json_extract_string_array` is deprecated and will be removed in a\n", - "future version. Use `json_value_array` instead.\n", - " warnings.warn(bfe.format_message(msg), category=UserWarning)\n" - ] - } - ], - "source": [ - "df_pdf[\"chunked\"] = df_pdf[\"pdf\"].blob.pdf_chunk(engine=\"pypdf\")" + "# Construct the canonical connection ID\n", + "FULL_CONNECTION_ID = f\"{PROJECT}.{LOCATION}.bigframes-default-connection\"\n", + "\n", + "@bpd.udf(\n", + " input_types=[str],\n", + " output_type=str,\n", + " dataset=DATASET_ID,\n", + " name=\"pdf_extract\",\n", + " bigquery_connection=FULL_CONNECTION_ID,\n", + " packages=[\"pypdf\", \"requests\", \"cryptography\"],\n", + ")\n", + "def pdf_extract(src_obj_ref_rt: str) -> str:\n", + " import io\n", + " import json\n", + " from pypdf import PdfReader\n", + " import requests\n", + " from requests import adapters\n", + " session = requests.Session()\n", + " session.mount(\"https://\", adapters.HTTPAdapter(max_retries=3))\n", + " src_obj_ref_rt_json = json.loads(src_obj_ref_rt)\n", + " src_url = src_obj_ref_rt_json[\"access_urls\"][\"read_url\"]\n", + " response = session.get(src_url, timeout=30, stream=True)\n", + " response.raise_for_status()\n", + " pdf_bytes = response.content\n", + " pdf_file = io.BytesIO(pdf_bytes)\n", + " reader = PdfReader(pdf_file, strict=False)\n", + " all_text = \"\"\n", + " for page in reader.pages:\n", + " page_extract_text = page.extract_text()\n", + " if page_extract_text:\n", + " all_text += page_extract_text\n", + " return all_text\n", + "\n", + "@bpd.udf(\n", + " input_types=[str, int, int],\n", + " output_type=list[str],\n", + " dataset=DATASET_ID,\n", + " name=\"pdf_chunk\",\n", + " bigquery_connection=FULL_CONNECTION_ID,\n", + " packages=[\"pypdf\", \"requests\", \"cryptography\"],\n", + ")\n", + "def pdf_chunk(src_obj_ref_rt: str, chunk_size: int, overlap_size: int) -> list[str]:\n", + " import io\n", + " import json\n", + " from pypdf import PdfReader\n", + " import requests\n", + " from requests import adapters\n", + " session = requests.Session()\n", + " session.mount(\"https://\", adapters.HTTPAdapter(max_retries=3))\n", + " src_obj_ref_rt_json = json.loads(src_obj_ref_rt)\n", + " src_url = src_obj_ref_rt_json[\"access_urls\"][\"read_url\"]\n", + " response = session.get(src_url, timeout=30, stream=True)\n", + " response.raise_for_status()\n", + " pdf_bytes = response.content\n", + " pdf_file = io.BytesIO(pdf_bytes)\n", + " reader = PdfReader(pdf_file, strict=False)\n", + " all_text_chunks = []\n", + " curr_chunk = \"\"\n", + " for page in reader.pages:\n", + " page_text = page.extract_text()\n", + " if page_text:\n", + " curr_chunk += page_text\n", + " while len(curr_chunk) >= chunk_size:\n", + " split_idx = curr_chunk.rfind(\" \", 0, chunk_size)\n", + " if split_idx == -1:\n", + " split_idx = chunk_size\n", + " actual_chunk = curr_chunk[:split_idx]\n", + " all_text_chunks.append(actual_chunk)\n", + " overlap = curr_chunk[split_idx + 1 : split_idx + 1 + overlap_size]\n", + " curr_chunk = overlap + curr_chunk[split_idx + 1 + overlap_size :]\n", + " if curr_chunk:\n", + " all_text_chunks.append(curr_chunk)\n", + " return all_text_chunks" ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/core/log_adapter.py:182: FunctionAxisOnePreviewWarning: Blob Functions use bigframes DataFrame Managed function with axis=1 senario, which is a preview feature.\n", - " return method(*args, **kwargs)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:239: UserWarning: The `json_extract_string_array` is deprecated and will be removed in a\n", - "future version. Use `json_value_array` instead.\n", - " warnings.warn(bfe.format_message(msg), category=UserWarning)\n" - ] - }, - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
chunked_verbose
0{'status': '', 'content': array([\"CritterCuisi...
\n", - "

1 rows × 1 columns

\n", - "
[1 rows x 1 columns in total]" - ], - "text/plain": [ - " chunked_verbose\n", - "0 {'status': '', 'content': array([\"CritterCuisi...\n", - "\n", - "[1 rows x 1 columns]" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ - "df_pdf[\"chunked_verbose\"] = df_pdf[\"pdf\"].blob.pdf_chunk(engine=\"pypdf\", verbose=True)\n", - "df_pdf[[\"chunked_verbose\"]]" + "df_pdf = bpd.from_glob_path(\"gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/documents/*\", name=\"pdf\")\n", + "\n", + "# Generate a JSON string containing the runtime information (including signed read URLs)\n", + "access_urls = get_runtime_json_str(df_pdf[\"pdf\"], mode=\"R\")\n", + "\n", + "# Apply PDF extraction\n", + "df_pdf[\"extracted_text\"] = access_urls.apply(pdf_extract)\n", + "\n", + "# Apply PDF chunking\n", + "df_pdf[\"chunked\"] = access_urls.apply(pdf_chunk, args=(2000, 200))\n", + "\n", + "df_pdf[[\"extracted_text\", \"chunked\"]]" ] }, { "cell_type": "code", - "execution_count": 20, - "metadata": { - "id": "kaPvJATN7zlw" - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n" - ] - }, - { - "data": { - "text/plain": [ - "0 CritterCuisine Pro 5000 - Automatic Pet Feeder...\n", - "0 on a level, stable surface to prevent tipping....\n", - "0 included)\\nto maintain the schedule during pow...\n", - "0 digits for Meal 1 will flash.\\n\u0000. Use the UP/D...\n", - "0 paperclip) for 5\\nseconds. This will reset all...\n", - "0 unit with a damp cloth. Do not immerse the bas...\n", - "0 continues,\\ncontact customer support.\\nE2: Foo...\n", - "Name: chunked, dtype: string" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ + "# Explode the chunks to see each chunk as a separate row\n", "chunked = df_pdf[\"chunked\"].explode()\n", "chunked" ] @@ -1674,7 +1632,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.0" + "version": "3.10.15" } }, "nbformat": 4, From 342fa723c4631d371364a87ae0ddd6fa03360a4b Mon Sep 17 00:00:00 2001 From: Shuowei Li Date: Thu, 12 Feb 2026 20:39:35 -0800 Subject: [PATCH 13/17] docs: update multimodal dataframe notebook to use public APIs (#2456) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updates the multimodal_dataframe.ipynb notebook to remove dependencies on the internal .blob accessor. Fixes #<478952827> 🦕 --- .../multimodal/multimodal_dataframe.ipynb | 188 +++++++++--------- 1 file changed, 89 insertions(+), 99 deletions(-) diff --git a/notebooks/multimodal/multimodal_dataframe.ipynb b/notebooks/multimodal/multimodal_dataframe.ipynb index 3d3e2d0a6f8..a578910b658 100644 --- a/notebooks/multimodal/multimodal_dataframe.ipynb +++ b/notebooks/multimodal/multimodal_dataframe.ipynb @@ -83,7 +83,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -92,7 +92,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -130,7 +130,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -157,7 +157,51 @@ " runtime = bbq.obj.get_access_url(s, mode=mode)\n", " \n", " # 3. Convert the runtime object to a JSON string\n", - " return bbq.to_json_string(runtime)" + " return bbq.to_json_string(runtime)\n", + "\n", + "def get_metadata(series):\n", + " # Fetch metadata and extract GCS metadata from the details JSON field\n", + " metadata_obj = bbq.obj.fetch_metadata(series)\n", + " return bbq.json_query(metadata_obj.struct.field(\"details\"), \"$.gcs_metadata\")\n", + "\n", + "def get_content_type(series):\n", + " return bbq.json_value(get_metadata(series), \"$.content_type\")\n", + "\n", + "def get_size(series):\n", + " return bbq.json_value(get_metadata(series), \"$.size\").astype(\"Int64\")\n", + "\n", + "def get_updated(series):\n", + " return bpd.to_datetime(bbq.json_value(get_metadata(series), \"$.updated\").astype(\"Int64\"), unit=\"us\", utc=True)\n", + "\n", + "def display_blob(series, n=3):\n", + " import IPython.display as ipy_display\n", + " import pandas as pd\n", + " import requests\n", + " \n", + " # Retrieve access URLs and content types\n", + " runtime_json = bbq.to_json_string(bbq.obj.get_access_url(series, mode=\"R\"))\n", + " read_url = bbq.json_value(runtime_json, \"$.access_urls.read_url\")\n", + " content_type = get_content_type(series)\n", + " \n", + " # Pull to pandas to display\n", + " pdf = bpd.DataFrame({\"read_url\": read_url, \"content_type\": content_type}).head(n).to_pandas()\n", + " \n", + " width = bigframes.options.display.blob_display_width\n", + " height = bigframes.options.display.blob_display_height\n", + " \n", + " for _, row in pdf.iterrows():\n", + " if pd.isna(row[\"read_url\"]):\n", + " ipy_display.display(\"\")\n", + " elif pd.isna(row[\"content_type\"]):\n", + " ipy_display.display(requests.get(row[\"read_url\"]).content)\n", + " elif row[\"content_type\"].casefold().startswith(\"image\"):\n", + " ipy_display.display(ipy_display.Image(url=row[\"read_url\"], width=width, height=height))\n", + " elif row[\"content_type\"].casefold().startswith(\"audio\"):\n", + " ipy_display.display(ipy_display.Audio(requests.get(row[\"read_url\"]).content))\n", + " elif row[\"content_type\"].casefold().startswith(\"video\"):\n", + " ipy_display.display(ipy_display.Video(row[\"read_url\"], width=width, height=height))\n", + " else:\n", + " ipy_display.display(requests.get(row[\"read_url\"]).content)" ] }, { @@ -172,7 +216,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -180,20 +224,7 @@ "id": "fx6YcZJbeYru", "outputId": "d707954a-0dd0-4c50-b7bf-36b140cf76cf" }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/core/global_session.py:113: DefaultLocationWarning: No explicit location is set, so using location US for the session.\n", - " _global_session = bigframes.session.connect(\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n" - ] - } - ], + "outputs": [], "source": [ "# Create blob columns from wildcard path.\n", "df_image = bpd.from_glob_path(\n", @@ -209,7 +240,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": { "colab": { "base_uri": "https://localhost:8080/", @@ -223,10 +254,12 @@ "name": "stderr", "output_type": "stream", "text": [ - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", + "/usr/local/google/home/shuowei/src/python-bigquery-dataframes/bigframes/dtypes.py:987: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", "instead of using `db_dtypes` in the future when available in pandas\n", "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n" + " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n", + "/usr/local/google/home/shuowei/src/python-bigquery-dataframes/bigframes/core/logging/log_adapter.py:229: ApiDeprecationWarning: The blob accessor is deprecated and will be removed in a future release. Use bigframes.bigquery.obj functions instead.\n", + " return prop(*args, **kwargs)\n" ] }, { @@ -256,23 +289,23 @@ " \n", " \n", " 0\n", - " \n", + " \n", " \n", " \n", " 1\n", - " \n", + " \n", " \n", " \n", " 2\n", - " \n", + " \n", " \n", " \n", " 3\n", - " \n", + " \n", " \n", " \n", " 4\n", - " \n", + " \n", " \n", " \n", "\n", @@ -281,16 +314,16 @@ ], "text/plain": [ " image\n", - "0 {'uri': 'gs://cloud-samples-data/bigquery/tuto...\n", - "1 {'uri': 'gs://cloud-samples-data/bigquery/tuto...\n", - "2 {'uri': 'gs://cloud-samples-data/bigquery/tuto...\n", - "3 {'uri': 'gs://cloud-samples-data/bigquery/tuto...\n", - "4 {'uri': 'gs://cloud-samples-data/bigquery/tuto...\n", + "0 {\"access_urls\":{\"expiry_time\":\"2026-02-13T01:5...\n", + "1 {\"access_urls\":{\"expiry_time\":\"2026-02-13T01:5...\n", + "2 {\"access_urls\":{\"expiry_time\":\"2026-02-13T01:5...\n", + "3 {\"access_urls\":{\"expiry_time\":\"2026-02-13T01:5...\n", + "4 {\"access_urls\":{\"expiry_time\":\"2026-02-13T01:5...\n", "\n", "[5 rows x 1 columns]" ] }, - "execution_count": 5, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -321,7 +354,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": { "id": "YYYVn7NDH0Me" }, @@ -330,35 +363,12 @@ "name": "stderr", "output_type": "stream", "text": [ - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:121: UserWarning: The `json_extract` is deprecated and will be removed in a future\n", - "version. Use `json_query` instead.\n", - " warnings.warn(bfe.format_message(msg), category=UserWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:121: UserWarning: The `json_extract` is deprecated and will be removed in a future\n", - "version. Use `json_query` instead.\n", - " warnings.warn(bfe.format_message(msg), category=UserWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", + "/usr/local/google/home/shuowei/src/python-bigquery-dataframes/bigframes/dtypes.py:987: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", "instead of using `db_dtypes` in the future when available in pandas\n", "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:121: UserWarning: The `json_extract` is deprecated and will be removed in a future\n", - "version. Use `json_query` instead.\n", - " warnings.warn(bfe.format_message(msg), category=UserWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n" + "/usr/local/google/home/shuowei/src/python-bigquery-dataframes/bigframes/core/logging/log_adapter.py:229: ApiDeprecationWarning: The blob accessor is deprecated and will be removed in a future release. Use bigframes.bigquery.obj functions instead.\n", + " return prop(*args, **kwargs)\n" ] }, { @@ -392,7 +402,7 @@ " \n", " \n", " 0\n", - " \n", + " \n", " alice\n", " image/png\n", " 1591240\n", @@ -400,7 +410,7 @@ " \n", " \n", " 1\n", - " \n", + " \n", " bob\n", " image/png\n", " 1182951\n", @@ -408,7 +418,7 @@ " \n", " \n", " 2\n", - " \n", + " \n", " bob\n", " image/png\n", " 1520884\n", @@ -416,7 +426,7 @@ " \n", " \n", " 3\n", - " \n", + " \n", " alice\n", " image/png\n", " 1235401\n", @@ -424,7 +434,7 @@ " \n", " \n", " 4\n", - " \n", + " \n", " bob\n", " image/png\n", " 1591923\n", @@ -437,11 +447,11 @@ ], "text/plain": [ " image author content_type \\\n", - "0 {'uri': 'gs://cloud-samples-data/bigquery/tuto... alice image/png \n", - "1 {'uri': 'gs://cloud-samples-data/bigquery/tuto... bob image/png \n", - "2 {'uri': 'gs://cloud-samples-data/bigquery/tuto... bob image/png \n", - "3 {'uri': 'gs://cloud-samples-data/bigquery/tuto... alice image/png \n", - "4 {'uri': 'gs://cloud-samples-data/bigquery/tuto... bob image/png \n", + "0 {\"access_urls\":{\"expiry_time\":\"2026-02-13T01:5... alice image/png \n", + "1 {\"access_urls\":{\"expiry_time\":\"2026-02-13T01:5... bob image/png \n", + "2 {\"access_urls\":{\"expiry_time\":\"2026-02-13T01:5... bob image/png \n", + "3 {\"access_urls\":{\"expiry_time\":\"2026-02-13T01:5... alice image/png \n", + "4 {\"access_urls\":{\"expiry_time\":\"2026-02-13T01:5... bob image/png \n", "\n", " size updated \n", "0 1591240 2025-03-20 17:45:04+00:00 \n", @@ -453,17 +463,18 @@ "[5 rows x 5 columns]" ] }, - "execution_count": 6, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Combine unstructured data with structured data\n", + "df_image = df_image.head(5)\n", "df_image[\"author\"] = [\"alice\", \"bob\", \"bob\", \"alice\", \"bob\"] # type: ignore\n", - "df_image[\"content_type\"] = df_image[\"image\"].blob.content_type()\n", - "df_image[\"size\"] = df_image[\"image\"].blob.size()\n", - "df_image[\"updated\"] = df_image[\"image\"].blob.updated()\n", + "df_image[\"content_type\"] = get_content_type(df_image[\"image\"])\n", + "df_image[\"size\"] = get_size(df_image[\"image\"])\n", + "df_image[\"updated\"] = get_updated(df_image[\"image\"])\n", "df_image" ] }, @@ -478,7 +489,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": { "colab": { "base_uri": "https://localhost:8080/", @@ -488,31 +499,10 @@ "outputId": "73feb33d-4a05-48fb-96e5-3c48c2a456f3" }, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", - "instead of using `db_dtypes` in the future when available in pandas\n", - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n", - "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:121: UserWarning: The `json_extract` is deprecated and will be removed in a future\n", - "version. Use `json_query` instead.\n", - " warnings.warn(bfe.format_message(msg), category=UserWarning)\n" - ] - }, { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -524,7 +514,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -536,7 +526,7 @@ ], "source": [ "# filter images and display, you can also display audio and video types\n", - "df_image[df_image[\"author\"] == \"alice\"][\"image\"].blob.display()" + "display_blob(df_image[df_image[\"author\"] == \"alice\"][\"image\"])" ] }, { From 36261f511d600a482fadfe31ad2443400823ddbc Mon Sep 17 00:00:00 2001 From: Chelsea Lin Date: Fri, 13 Feb 2026 12:49:42 -0800 Subject: [PATCH 14/17] refactor: migrate compile_random_sample for sqlglot (#2454) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes internal issue 427767336 🦕 --- bigframes/core/compile/sqlglot/compiler.py | 19 ++ bigframes/core/compile/sqlglot/sqlglot_ir.py | 41 +++++ .../test_compile_fromrange/out.sql | 165 ++++++++++++++++++ .../compile/sqlglot/test_compile_fromrange.py | 35 ++++ 4 files changed, 260 insertions(+) create mode 100644 tests/unit/core/compile/sqlglot/snapshots/test_compile_fromrange/test_compile_fromrange/out.sql create mode 100644 tests/unit/core/compile/sqlglot/test_compile_fromrange.py diff --git a/bigframes/core/compile/sqlglot/compiler.py b/bigframes/core/compile/sqlglot/compiler.py index d74c1b38696..6b90b94067e 100644 --- a/bigframes/core/compile/sqlglot/compiler.py +++ b/bigframes/core/compile/sqlglot/compiler.py @@ -19,6 +19,7 @@ import bigframes_vendored.sqlglot.expressions as sge +from bigframes import dtypes from bigframes.core import ( expression, guid, @@ -277,6 +278,24 @@ def compile_explode(node: nodes.ExplodeNode, child: ir.SQLGlotIR) -> ir.SQLGlotI return child.explode(columns, offsets_col) +@_compile_node.register +def compile_fromrange( + node: nodes.FromRangeNode, start: ir.SQLGlotIR, end: ir.SQLGlotIR +) -> ir.SQLGlotIR: + start_col_id = node.start.fields[0].id + end_col_id = node.end.fields[0].id + + start_expr = expression_compiler.expression_compiler.compile_expression( + expression.DerefOp(start_col_id) + ) + end_expr = expression_compiler.expression_compiler.compile_expression( + expression.DerefOp(end_col_id) + ) + step_expr = ir._literal(node.step, dtypes.INT_DTYPE) + + return start.resample(end, node.output_id.sql, start_expr, end_expr, step_expr) + + @_compile_node.register def compile_random_sample( node: nodes.RandomSampleNode, child: ir.SQLGlotIR diff --git a/bigframes/core/compile/sqlglot/sqlglot_ir.py b/bigframes/core/compile/sqlglot/sqlglot_ir.py index efe5e09aff2..3cedd04dc57 100644 --- a/bigframes/core/compile/sqlglot/sqlglot_ir.py +++ b/bigframes/core/compile/sqlglot/sqlglot_ir.py @@ -410,6 +410,47 @@ def aggregate( new_expr = new_expr.where(condition, append=False) return SQLGlotIR(expr=new_expr, uid_gen=self.uid_gen) + def resample( + self, + right: SQLGlotIR, + array_col_name: str, + start_expr: sge.Expression, + stop_expr: sge.Expression, + step_expr: sge.Expression, + ) -> SQLGlotIR: + # Get identifier for left and right by pushing them to CTEs + left_select, left_id = self._select_to_cte() + right_select, right_id = right._select_to_cte() + + # Extract all CTEs from the returned select expressions + _, left_ctes = _pop_query_ctes(left_select) + _, right_ctes = _pop_query_ctes(right_select) + merged_ctes = _merge_ctes(left_ctes, right_ctes) + + generate_array = sge.func("GENERATE_ARRAY", start_expr, stop_expr, step_expr) + + unnested_column_alias = sge.to_identifier( + next(self.uid_gen.get_uid_stream("bfcol_")), quoted=self.quoted + ) + unnest_expr = sge.Unnest( + expressions=[generate_array], + alias=sge.TableAlias(columns=[unnested_column_alias]), + ) + + final_col_id = sge.to_identifier(array_col_name, quoted=self.quoted) + + # Build final expression by joining everything directly in a single SELECT + new_expr = ( + sge.Select() + .select(unnested_column_alias.as_(final_col_id)) + .from_(sge.Table(this=left_id)) + .join(sge.Table(this=right_id), join_type="cross") + .join(unnest_expr, join_type="cross") + ) + new_expr = _set_query_ctes(new_expr, merged_ctes) + + return SQLGlotIR(expr=new_expr, uid_gen=self.uid_gen) + def insert( self, destination: bigquery.TableReference, diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_fromrange/test_compile_fromrange/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_fromrange/test_compile_fromrange/out.sql new file mode 100644 index 00000000000..47455a292b8 --- /dev/null +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_fromrange/test_compile_fromrange/out.sql @@ -0,0 +1,165 @@ +WITH `bfcte_6` AS ( + SELECT + * + FROM UNNEST(ARRAY>[STRUCT(CAST('2021-01-01T13:00:00' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:01' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:02' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:03' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:04' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:05' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:06' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:07' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:08' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:09' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:10' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:11' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:12' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:13' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:14' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:15' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:16' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:17' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:18' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:19' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:20' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:21' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:22' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:23' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:24' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:25' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:26' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:27' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:28' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:29' AS DATETIME))]) +), `bfcte_15` AS ( + SELECT + `bfcol_0` AS `bfcol_1` + FROM `bfcte_6` +), `bfcte_5` AS ( + SELECT + * + FROM UNNEST(ARRAY>[STRUCT(CAST('2021-01-01T13:00:00' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:01' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:02' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:03' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:04' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:05' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:06' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:07' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:08' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:09' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:10' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:11' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:12' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:13' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:14' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:15' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:16' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:17' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:18' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:19' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:20' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:21' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:22' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:23' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:24' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:25' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:26' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:27' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:28' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:29' AS DATETIME))]) +), `bfcte_10` AS ( + SELECT + MIN(`bfcol_2`) AS `bfcol_4` + FROM `bfcte_5` +), `bfcte_16` AS ( + SELECT + * + FROM `bfcte_10` +), `bfcte_19` AS ( + SELECT + * + FROM `bfcte_15` + CROSS JOIN `bfcte_16` +), `bfcte_21` AS ( + SELECT + `bfcol_1`, + `bfcol_4`, + CAST(FLOOR( + IEEE_DIVIDE( + UNIX_MICROS(CAST(`bfcol_1` AS TIMESTAMP)) - UNIX_MICROS(CAST(CAST(`bfcol_4` AS DATE) AS TIMESTAMP)), + 7000000 + ) + ) AS INT64) AS `bfcol_5` + FROM `bfcte_19` +), `bfcte_23` AS ( + SELECT + MIN(`bfcol_5`) AS `bfcol_7` + FROM `bfcte_21` +), `bfcte_24` AS ( + SELECT + * + FROM `bfcte_23` +), `bfcte_4` AS ( + SELECT + * + FROM UNNEST(ARRAY>[STRUCT(CAST('2021-01-01T13:00:00' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:01' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:02' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:03' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:04' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:05' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:06' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:07' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:08' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:09' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:10' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:11' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:12' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:13' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:14' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:15' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:16' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:17' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:18' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:19' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:20' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:21' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:22' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:23' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:24' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:25' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:26' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:27' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:28' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:29' AS DATETIME))]) +), `bfcte_13` AS ( + SELECT + `bfcol_8` AS `bfcol_9` + FROM `bfcte_4` +), `bfcte_3` AS ( + SELECT + * + FROM UNNEST(ARRAY>[STRUCT(0, CAST('2021-01-01T13:00:00' AS DATETIME), 0, 10), STRUCT(1, CAST('2021-01-01T13:00:01' AS DATETIME), 1, 11), STRUCT(2, CAST('2021-01-01T13:00:02' AS DATETIME), 2, 12), STRUCT(3, CAST('2021-01-01T13:00:03' AS DATETIME), 3, 13), STRUCT(4, CAST('2021-01-01T13:00:04' AS DATETIME), 4, 14), STRUCT(5, CAST('2021-01-01T13:00:05' AS DATETIME), 5, 15), STRUCT(6, CAST('2021-01-01T13:00:06' AS DATETIME), 6, 16), STRUCT(7, CAST('2021-01-01T13:00:07' AS DATETIME), 7, 17), STRUCT(8, CAST('2021-01-01T13:00:08' AS DATETIME), 8, 18), STRUCT(9, CAST('2021-01-01T13:00:09' AS DATETIME), 9, 19), STRUCT(10, CAST('2021-01-01T13:00:10' AS DATETIME), 10, 20), STRUCT(11, CAST('2021-01-01T13:00:11' AS DATETIME), 11, 21), STRUCT(12, CAST('2021-01-01T13:00:12' AS DATETIME), 12, 22), STRUCT(13, CAST('2021-01-01T13:00:13' AS DATETIME), 13, 23), STRUCT(14, CAST('2021-01-01T13:00:14' AS DATETIME), 14, 24), STRUCT(15, CAST('2021-01-01T13:00:15' AS DATETIME), 15, 25), STRUCT(16, CAST('2021-01-01T13:00:16' AS DATETIME), 16, 26), STRUCT(17, CAST('2021-01-01T13:00:17' AS DATETIME), 17, 27), STRUCT(18, CAST('2021-01-01T13:00:18' AS DATETIME), 18, 28), STRUCT(19, CAST('2021-01-01T13:00:19' AS DATETIME), 19, 29), STRUCT(20, CAST('2021-01-01T13:00:20' AS DATETIME), 20, 30), STRUCT(21, CAST('2021-01-01T13:00:21' AS DATETIME), 21, 31), STRUCT(22, CAST('2021-01-01T13:00:22' AS DATETIME), 22, 32), STRUCT(23, CAST('2021-01-01T13:00:23' AS DATETIME), 23, 33), STRUCT(24, CAST('2021-01-01T13:00:24' AS DATETIME), 24, 34), STRUCT(25, CAST('2021-01-01T13:00:25' AS DATETIME), 25, 35), STRUCT(26, CAST('2021-01-01T13:00:26' AS DATETIME), 26, 36), STRUCT(27, CAST('2021-01-01T13:00:27' AS DATETIME), 27, 37), STRUCT(28, CAST('2021-01-01T13:00:28' AS DATETIME), 28, 38), STRUCT(29, CAST('2021-01-01T13:00:29' AS DATETIME), 29, 39)]) +), `bfcte_9` AS ( + SELECT + MIN(`bfcol_11`) AS `bfcol_37` + FROM `bfcte_3` +), `bfcte_14` AS ( + SELECT + * + FROM `bfcte_9` +), `bfcte_18` AS ( + SELECT + * + FROM `bfcte_13` + CROSS JOIN `bfcte_14` +), `bfcte_20` AS ( + SELECT + `bfcol_9`, + `bfcol_37`, + CAST(FLOOR( + IEEE_DIVIDE( + UNIX_MICROS(CAST(`bfcol_9` AS TIMESTAMP)) - UNIX_MICROS(CAST(CAST(`bfcol_37` AS DATE) AS TIMESTAMP)), + 7000000 + ) + ) AS INT64) AS `bfcol_38` + FROM `bfcte_18` +), `bfcte_22` AS ( + SELECT + MAX(`bfcol_38`) AS `bfcol_40` + FROM `bfcte_20` +), `bfcte_25` AS ( + SELECT + * + FROM `bfcte_22` +), `bfcte_26` AS ( + SELECT + `bfcol_67` AS `bfcol_41` + FROM `bfcte_24` + CROSS JOIN `bfcte_25` + CROSS JOIN UNNEST(GENERATE_ARRAY(`bfcol_7`, `bfcol_40`, 1)) AS `bfcol_67` +), `bfcte_2` AS ( + SELECT + * + FROM UNNEST(ARRAY>[STRUCT(CAST('2021-01-01T13:00:00' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:01' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:02' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:03' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:04' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:05' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:06' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:07' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:08' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:09' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:10' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:11' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:12' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:13' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:14' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:15' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:16' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:17' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:18' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:19' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:20' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:21' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:22' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:23' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:24' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:25' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:26' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:27' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:28' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:29' AS DATETIME))]) +), `bfcte_8` AS ( + SELECT + MIN(`bfcol_42`) AS `bfcol_44` + FROM `bfcte_2` +), `bfcte_27` AS ( + SELECT + * + FROM `bfcte_8` +), `bfcte_28` AS ( + SELECT + * + FROM `bfcte_26` + CROSS JOIN `bfcte_27` +), `bfcte_1` AS ( + SELECT + * + FROM UNNEST(ARRAY>[STRUCT(CAST('2021-01-01T13:00:00' AS DATETIME), 0, 10), STRUCT(CAST('2021-01-01T13:00:01' AS DATETIME), 1, 11), STRUCT(CAST('2021-01-01T13:00:02' AS DATETIME), 2, 12), STRUCT(CAST('2021-01-01T13:00:03' AS DATETIME), 3, 13), STRUCT(CAST('2021-01-01T13:00:04' AS DATETIME), 4, 14), STRUCT(CAST('2021-01-01T13:00:05' AS DATETIME), 5, 15), STRUCT(CAST('2021-01-01T13:00:06' AS DATETIME), 6, 16), STRUCT(CAST('2021-01-01T13:00:07' AS DATETIME), 7, 17), STRUCT(CAST('2021-01-01T13:00:08' AS DATETIME), 8, 18), STRUCT(CAST('2021-01-01T13:00:09' AS DATETIME), 9, 19), STRUCT(CAST('2021-01-01T13:00:10' AS DATETIME), 10, 20), STRUCT(CAST('2021-01-01T13:00:11' AS DATETIME), 11, 21), STRUCT(CAST('2021-01-01T13:00:12' AS DATETIME), 12, 22), STRUCT(CAST('2021-01-01T13:00:13' AS DATETIME), 13, 23), STRUCT(CAST('2021-01-01T13:00:14' AS DATETIME), 14, 24), STRUCT(CAST('2021-01-01T13:00:15' AS DATETIME), 15, 25), STRUCT(CAST('2021-01-01T13:00:16' AS DATETIME), 16, 26), STRUCT(CAST('2021-01-01T13:00:17' AS DATETIME), 17, 27), STRUCT(CAST('2021-01-01T13:00:18' AS DATETIME), 18, 28), STRUCT(CAST('2021-01-01T13:00:19' AS DATETIME), 19, 29), STRUCT(CAST('2021-01-01T13:00:20' AS DATETIME), 20, 30), STRUCT(CAST('2021-01-01T13:00:21' AS DATETIME), 21, 31), STRUCT(CAST('2021-01-01T13:00:22' AS DATETIME), 22, 32), STRUCT(CAST('2021-01-01T13:00:23' AS DATETIME), 23, 33), STRUCT(CAST('2021-01-01T13:00:24' AS DATETIME), 24, 34), STRUCT(CAST('2021-01-01T13:00:25' AS DATETIME), 25, 35), STRUCT(CAST('2021-01-01T13:00:26' AS DATETIME), 26, 36), STRUCT(CAST('2021-01-01T13:00:27' AS DATETIME), 27, 37), STRUCT(CAST('2021-01-01T13:00:28' AS DATETIME), 28, 38), STRUCT(CAST('2021-01-01T13:00:29' AS DATETIME), 29, 39)]) +), `bfcte_11` AS ( + SELECT + `bfcol_45` AS `bfcol_48`, + `bfcol_46` AS `bfcol_49`, + `bfcol_47` AS `bfcol_50` + FROM `bfcte_1` +), `bfcte_0` AS ( + SELECT + * + FROM UNNEST(ARRAY>[STRUCT(CAST('2021-01-01T13:00:00' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:01' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:02' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:03' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:04' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:05' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:06' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:07' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:08' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:09' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:10' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:11' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:12' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:13' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:14' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:15' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:16' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:17' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:18' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:19' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:20' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:21' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:22' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:23' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:24' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:25' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:26' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:27' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:28' AS DATETIME)), STRUCT(CAST('2021-01-01T13:00:29' AS DATETIME))]) +), `bfcte_7` AS ( + SELECT + MIN(`bfcol_51`) AS `bfcol_53` + FROM `bfcte_0` +), `bfcte_12` AS ( + SELECT + * + FROM `bfcte_7` +), `bfcte_17` AS ( + SELECT + * + FROM `bfcte_11` + CROSS JOIN `bfcte_12` +), `bfcte_29` AS ( + SELECT + `bfcol_49` AS `bfcol_55`, + `bfcol_50` AS `bfcol_56`, + CAST(FLOOR( + IEEE_DIVIDE( + UNIX_MICROS(CAST(`bfcol_48` AS TIMESTAMP)) - UNIX_MICROS(CAST(CAST(`bfcol_53` AS DATE) AS TIMESTAMP)), + 7000000 + ) + ) AS INT64) AS `bfcol_57` + FROM `bfcte_17` +), `bfcte_30` AS ( + SELECT + * + FROM `bfcte_28` + LEFT JOIN `bfcte_29` + ON `bfcol_41` = `bfcol_57` +) +SELECT + CAST(TIMESTAMP_MICROS( + CAST(CAST(`bfcol_41` AS BIGNUMERIC) * 7000000 + CAST(UNIX_MICROS(CAST(CAST(`bfcol_44` AS DATE) AS TIMESTAMP)) AS BIGNUMERIC) AS INT64) + ) AS DATETIME) AS `bigframes_unnamed_index`, + `bfcol_55` AS `int64_col`, + `bfcol_56` AS `int64_too` +FROM `bfcte_30` +ORDER BY + `bfcol_41` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/test_compile_fromrange.py b/tests/unit/core/compile/sqlglot/test_compile_fromrange.py new file mode 100644 index 00000000000..ba2e2075517 --- /dev/null +++ b/tests/unit/core/compile/sqlglot/test_compile_fromrange.py @@ -0,0 +1,35 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pandas as pd +import pytest + +import bigframes.pandas as bpd + +pytest.importorskip("pytest_snapshot") + + +def test_compile_fromrange(compiler_session, snapshot): + data = { + "timestamp_col": pd.date_range( + start="2021-01-01 13:00:00", periods=30, freq="1s" + ), + "int64_col": range(30), + "int64_too": range(10, 40), + } + df = bpd.DataFrame(data, session=compiler_session).set_index("timestamp_col") + sql, _, _ = df.resample(rule="7s")._block.to_sql_query( + include_index=True, enable_cache=False + ) + snapshot.assert_match(sql, "out.sql") From 53428d0ea4bfe078a6f7a67f91fabc2de4859c56 Mon Sep 17 00:00:00 2001 From: TrevorBergeron Date: Tue, 17 Feb 2026 13:34:39 -0800 Subject: [PATCH 15/17] chore: Update project links for pypi (#2459) --- setup.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2314c73b784..32fa628458b 100644 --- a/setup.py +++ b/setup.py @@ -122,12 +122,18 @@ name=name, version=version_id, description=description, + download_url="https://github.com/googleapis/python-bigquery-dataframes/releases", long_description=readme, long_description_content_type="text/x-rst", author="Google LLC", author_email="bigframes-feedback@google.com", license="Apache 2.0", - url="https://github.com/googleapis/python-bigquery-dataframes", + url="https://dataframes.bigquery.dev", + project_urls={ + "Source": "https://github.com/googleapis/python-bigquery-dataframes", + "Changelog": "https://dataframes.bigquery.dev/changelog.html", + "Issues": "https://github.com/googleapis/python-bigquery-dataframes/issues", + }, classifiers=[ release_status, "Intended Audience :: Developers", From a5a1bc1cbfec5b974b067e115ba0f543e6742ab6 Mon Sep 17 00:00:00 2001 From: Chelsea Lin Date: Tue, 17 Feb 2026 14:12:18 -0800 Subject: [PATCH 16/17] refactor: add table aliases to prevent ambiguity in SQLGlotIR (#2458) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change fixes the`test_read_gbq_w_ambigous_name` failures in #2248 Fixes internal issue 417774347 🦕 --- bigframes/core/compile/sqlglot/sqlglot_ir.py | 6 ++++-- .../snapshots/test_binary_compiler/test_corr/out.sql | 2 +- .../snapshots/test_binary_compiler/test_cov/out.sql | 2 +- .../test_nullary_compiler/test_row_number/out.sql | 2 +- .../test_row_number_with_window/out.sql | 2 +- .../snapshots/test_nullary_compiler/test_size/out.sql | 2 +- .../test_ordered_unary_compiler/test_array_agg/out.sql | 2 +- .../test_string_agg/out.sql | 2 +- .../snapshots/test_unary_compiler/test_all/out.sql | 2 +- .../test_unary_compiler/test_all_w_window/out.sql | 2 +- .../snapshots/test_unary_compiler/test_any/out.sql | 2 +- .../test_unary_compiler/test_any_value/out.sql | 2 +- .../test_unary_compiler/test_any_value/window_out.sql | 2 +- .../test_any_value/window_partition_out.sql | 2 +- .../test_unary_compiler/test_any_w_window/out.sql | 2 +- .../test_unary_compiler/test_approx_quartiles/out.sql | 2 +- .../test_unary_compiler/test_approx_top_count/out.sql | 2 +- .../snapshots/test_unary_compiler/test_count/out.sql | 2 +- .../test_unary_compiler/test_count/window_out.sql | 2 +- .../test_count/window_partition_out.sql | 2 +- .../test_unary_compiler/test_cut/int_bins.sql | 2 +- .../test_unary_compiler/test_cut/int_bins_labels.sql | 2 +- .../test_unary_compiler/test_cut/interval_bins.sql | 2 +- .../test_cut/interval_bins_labels.sql | 2 +- .../test_unary_compiler/test_dense_rank/out.sql | 2 +- .../test_unary_compiler/test_diff_w_bool/out.sql | 2 +- .../test_unary_compiler/test_diff_w_date/out.sql | 2 +- .../test_unary_compiler/test_diff_w_datetime/out.sql | 2 +- .../test_unary_compiler/test_diff_w_int/out.sql | 2 +- .../test_unary_compiler/test_diff_w_timestamp/out.sql | 2 +- .../snapshots/test_unary_compiler/test_first/out.sql | 2 +- .../test_unary_compiler/test_first_non_null/out.sql | 2 +- .../snapshots/test_unary_compiler/test_last/out.sql | 2 +- .../test_unary_compiler/test_last_non_null/out.sql | 2 +- .../snapshots/test_unary_compiler/test_max/out.sql | 2 +- .../test_unary_compiler/test_max/window_out.sql | 2 +- .../test_max/window_partition_out.sql | 2 +- .../snapshots/test_unary_compiler/test_mean/out.sql | 2 +- .../test_unary_compiler/test_mean/window_out.sql | 2 +- .../test_mean/window_partition_out.sql | 2 +- .../snapshots/test_unary_compiler/test_median/out.sql | 2 +- .../snapshots/test_unary_compiler/test_min/out.sql | 2 +- .../test_unary_compiler/test_min/window_out.sql | 2 +- .../test_min/window_partition_out.sql | 2 +- .../snapshots/test_unary_compiler/test_nunique/out.sql | 2 +- .../snapshots/test_unary_compiler/test_pop_var/out.sql | 2 +- .../test_unary_compiler/test_pop_var/window_out.sql | 2 +- .../snapshots/test_unary_compiler/test_product/out.sql | 2 +- .../test_product/window_partition_out.sql | 2 +- .../snapshots/test_unary_compiler/test_qcut/out.sql | 2 +- .../test_unary_compiler/test_quantile/out.sql | 2 +- .../snapshots/test_unary_compiler/test_rank/out.sql | 2 +- .../snapshots/test_unary_compiler/test_shift/lag.sql | 2 +- .../snapshots/test_unary_compiler/test_shift/lead.sql | 2 +- .../snapshots/test_unary_compiler/test_shift/noop.sql | 2 +- .../snapshots/test_unary_compiler/test_std/out.sql | 2 +- .../test_unary_compiler/test_std/window_out.sql | 2 +- .../snapshots/test_unary_compiler/test_sum/out.sql | 2 +- .../test_unary_compiler/test_sum/window_out.sql | 2 +- .../test_sum/window_partition_out.sql | 2 +- .../snapshots/test_unary_compiler/test_var/out.sql | 2 +- .../test_unary_compiler/test_var/window_out.sql | 2 +- .../snapshots/test_ai_ops/test_ai_classify/out.sql | 2 +- .../snapshots/test_ai_ops/test_ai_generate/out.sql | 2 +- .../test_ai_ops/test_ai_generate_bool/out.sql | 2 +- .../test_ai_generate_bool_with_connection_id/out.sql | 2 +- .../test_ai_generate_bool_with_model_param/out.sql | 2 +- .../test_ai_ops/test_ai_generate_double/out.sql | 2 +- .../test_ai_generate_double_with_connection_id/out.sql | 2 +- .../test_ai_generate_double_with_model_param/out.sql | 2 +- .../snapshots/test_ai_ops/test_ai_generate_int/out.sql | 2 +- .../test_ai_generate_int_with_connection_id/out.sql | 2 +- .../test_ai_generate_int_with_model_param/out.sql | 2 +- .../test_ai_generate_with_connection_id/out.sql | 2 +- .../test_ai_generate_with_model_param/out.sql | 2 +- .../test_ai_generate_with_output_schema/out.sql | 2 +- .../snapshots/test_ai_ops/test_ai_if/out.sql | 2 +- .../snapshots/test_ai_ops/test_ai_score/out.sql | 2 +- .../snapshots/test_array_ops/test_array_index/out.sql | 2 +- .../test_array_ops/test_array_reduce_op/out.sql | 2 +- .../test_array_slice_with_only_start/out.sql | 2 +- .../test_array_slice_with_start_and_stop/out.sql | 2 +- .../test_array_ops/test_array_to_string/out.sql | 2 +- .../snapshots/test_array_ops/test_to_array_op/out.sql | 2 +- .../test_blob_ops/test_obj_fetch_metadata/out.sql | 2 +- .../test_blob_ops/test_obj_get_access_url/out.sql | 2 +- .../snapshots/test_blob_ops/test_obj_make_ref/out.sql | 2 +- .../snapshots/test_bool_ops/test_and_op/out.sql | 2 +- .../snapshots/test_bool_ops/test_or_op/out.sql | 2 +- .../snapshots/test_bool_ops/test_xor_op/out.sql | 2 +- .../test_comparison_ops/test_eq_null_match/out.sql | 2 +- .../test_comparison_ops/test_eq_numeric/out.sql | 2 +- .../test_comparison_ops/test_ge_numeric/out.sql | 2 +- .../test_comparison_ops/test_gt_numeric/out.sql | 2 +- .../snapshots/test_comparison_ops/test_is_in/out.sql | 2 +- .../test_comparison_ops/test_le_numeric/out.sql | 2 +- .../test_comparison_ops/test_lt_numeric/out.sql | 2 +- .../test_comparison_ops/test_maximum_op/out.sql | 2 +- .../test_comparison_ops/test_minimum_op/out.sql | 2 +- .../test_comparison_ops/test_ne_numeric/out.sql | 2 +- .../test_datetime_ops/test_add_timedelta/out.sql | 2 +- .../snapshots/test_datetime_ops/test_date/out.sql | 2 +- .../test_datetime_to_integer_label/out.sql | 2 +- .../snapshots/test_datetime_ops/test_day/out.sql | 2 +- .../snapshots/test_datetime_ops/test_dayofweek/out.sql | 2 +- .../snapshots/test_datetime_ops/test_dayofyear/out.sql | 2 +- .../snapshots/test_datetime_ops/test_floor_dt/out.sql | 2 +- .../snapshots/test_datetime_ops/test_hour/out.sql | 2 +- .../test_integer_label_to_datetime_fixed/out.sql | 2 +- .../test_integer_label_to_datetime_month/out.sql | 2 +- .../test_integer_label_to_datetime_quarter/out.sql | 2 +- .../test_integer_label_to_datetime_week/out.sql | 2 +- .../test_integer_label_to_datetime_year/out.sql | 2 +- .../snapshots/test_datetime_ops/test_iso_day/out.sql | 2 +- .../snapshots/test_datetime_ops/test_iso_week/out.sql | 2 +- .../snapshots/test_datetime_ops/test_iso_year/out.sql | 2 +- .../snapshots/test_datetime_ops/test_minute/out.sql | 2 +- .../snapshots/test_datetime_ops/test_month/out.sql | 2 +- .../snapshots/test_datetime_ops/test_normalize/out.sql | 2 +- .../snapshots/test_datetime_ops/test_quarter/out.sql | 2 +- .../snapshots/test_datetime_ops/test_second/out.sql | 2 +- .../snapshots/test_datetime_ops/test_strftime/out.sql | 2 +- .../test_datetime_ops/test_sub_timedelta/out.sql | 2 +- .../snapshots/test_datetime_ops/test_time/out.sql | 2 +- .../test_datetime_ops/test_to_datetime/out.sql | 2 +- .../test_datetime_ops/test_to_timestamp/out.sql | 2 +- .../test_datetime_ops/test_unix_micros/out.sql | 2 +- .../test_datetime_ops/test_unix_millis/out.sql | 2 +- .../test_datetime_ops/test_unix_seconds/out.sql | 2 +- .../snapshots/test_datetime_ops/test_year/out.sql | 2 +- .../test_generic_ops/test_astype_bool/out.sql | 2 +- .../test_generic_ops/test_astype_float/out.sql | 2 +- .../test_generic_ops/test_astype_from_json/out.sql | 2 +- .../snapshots/test_generic_ops/test_astype_int/out.sql | 2 +- .../test_generic_ops/test_astype_json/out.sql | 2 +- .../test_generic_ops/test_astype_string/out.sql | 2 +- .../test_generic_ops/test_astype_time_like/out.sql | 2 +- .../test_binary_remote_function_op/out.sql | 2 +- .../test_generic_ops/test_case_when_op/out.sql | 2 +- .../snapshots/test_generic_ops/test_clip/out.sql | 2 +- .../snapshots/test_generic_ops/test_coalesce/out.sql | 2 +- .../snapshots/test_generic_ops/test_fillna/out.sql | 2 +- .../snapshots/test_generic_ops/test_hash/out.sql | 2 +- .../snapshots/test_generic_ops/test_invert/out.sql | 2 +- .../snapshots/test_generic_ops/test_isnull/out.sql | 2 +- .../snapshots/test_generic_ops/test_map/out.sql | 2 +- .../test_nary_remote_function_op/out.sql | 2 +- .../snapshots/test_generic_ops/test_notnull/out.sql | 2 +- .../test_generic_ops/test_remote_function_op/out.sql | 2 +- .../snapshots/test_generic_ops/test_row_key/out.sql | 2 +- .../test_generic_ops/test_sql_scalar_op/out.sql | 2 +- .../snapshots/test_generic_ops/test_where/out.sql | 2 +- .../snapshots/test_geo_ops/test_geo_area/out.sql | 2 +- .../snapshots/test_geo_ops/test_geo_st_astext/out.sql | 2 +- .../test_geo_ops/test_geo_st_boundary/out.sql | 2 +- .../snapshots/test_geo_ops/test_geo_st_buffer/out.sql | 2 +- .../test_geo_ops/test_geo_st_centroid/out.sql | 2 +- .../test_geo_ops/test_geo_st_convexhull/out.sql | 2 +- .../test_geo_ops/test_geo_st_difference/out.sql | 2 +- .../test_geo_ops/test_geo_st_distance/out.sql | 2 +- .../test_geo_ops/test_geo_st_geogfromtext/out.sql | 2 +- .../test_geo_ops/test_geo_st_geogpoint/out.sql | 2 +- .../test_geo_ops/test_geo_st_intersection/out.sql | 2 +- .../test_geo_ops/test_geo_st_isclosed/out.sql | 2 +- .../snapshots/test_geo_ops/test_geo_st_length/out.sql | 2 +- .../snapshots/test_geo_ops/test_geo_x/out.sql | 2 +- .../snapshots/test_geo_ops/test_geo_y/out.sql | 2 +- .../snapshots/test_json_ops/test_json_extract/out.sql | 2 +- .../test_json_ops/test_json_extract_array/out.sql | 2 +- .../test_json_extract_string_array/out.sql | 2 +- .../snapshots/test_json_ops/test_json_keys/out.sql | 2 +- .../snapshots/test_json_ops/test_json_query/out.sql | 2 +- .../test_json_ops/test_json_query_array/out.sql | 2 +- .../snapshots/test_json_ops/test_json_set/out.sql | 2 +- .../snapshots/test_json_ops/test_json_value/out.sql | 2 +- .../snapshots/test_json_ops/test_parse_json/out.sql | 2 +- .../snapshots/test_json_ops/test_to_json/out.sql | 2 +- .../test_json_ops/test_to_json_string/out.sql | 2 +- .../snapshots/test_numeric_ops/test_abs/out.sql | 2 +- .../test_numeric_ops/test_add_numeric/out.sql | 2 +- .../snapshots/test_numeric_ops/test_add_string/out.sql | 2 +- .../test_numeric_ops/test_add_timedelta/out.sql | 2 +- .../snapshots/test_numeric_ops/test_arccos/out.sql | 2 +- .../snapshots/test_numeric_ops/test_arccosh/out.sql | 2 +- .../snapshots/test_numeric_ops/test_arcsin/out.sql | 2 +- .../snapshots/test_numeric_ops/test_arcsinh/out.sql | 2 +- .../snapshots/test_numeric_ops/test_arctan/out.sql | 2 +- .../snapshots/test_numeric_ops/test_arctan2/out.sql | 2 +- .../snapshots/test_numeric_ops/test_arctanh/out.sql | 2 +- .../snapshots/test_numeric_ops/test_ceil/out.sql | 2 +- .../snapshots/test_numeric_ops/test_cos/out.sql | 2 +- .../snapshots/test_numeric_ops/test_cosh/out.sql | 2 +- .../test_numeric_ops/test_cosine_distance/out.sql | 2 +- .../test_numeric_ops/test_div_numeric/out.sql | 2 +- .../test_numeric_ops/test_div_timedelta/out.sql | 2 +- .../test_numeric_ops/test_euclidean_distance/out.sql | 2 +- .../snapshots/test_numeric_ops/test_exp/out.sql | 2 +- .../snapshots/test_numeric_ops/test_expm1/out.sql | 2 +- .../snapshots/test_numeric_ops/test_floor/out.sql | 2 +- .../test_numeric_ops/test_floordiv_timedelta/out.sql | 2 +- .../snapshots/test_numeric_ops/test_isfinite/out.sql | 2 +- .../snapshots/test_numeric_ops/test_ln/out.sql | 2 +- .../snapshots/test_numeric_ops/test_log10/out.sql | 2 +- .../snapshots/test_numeric_ops/test_log1p/out.sql | 2 +- .../test_numeric_ops/test_manhattan_distance/out.sql | 2 +- .../test_numeric_ops/test_mod_numeric/out.sql | 2 +- .../test_numeric_ops/test_mul_numeric/out.sql | 2 +- .../test_numeric_ops/test_mul_timedelta/out.sql | 2 +- .../snapshots/test_numeric_ops/test_neg/out.sql | 2 +- .../snapshots/test_numeric_ops/test_pos/out.sql | 2 +- .../snapshots/test_numeric_ops/test_pow/out.sql | 2 +- .../snapshots/test_numeric_ops/test_round/out.sql | 2 +- .../snapshots/test_numeric_ops/test_sin/out.sql | 2 +- .../snapshots/test_numeric_ops/test_sinh/out.sql | 2 +- .../snapshots/test_numeric_ops/test_sqrt/out.sql | 2 +- .../test_numeric_ops/test_sub_numeric/out.sql | 2 +- .../test_numeric_ops/test_sub_timedelta/out.sql | 2 +- .../snapshots/test_numeric_ops/test_tan/out.sql | 2 +- .../snapshots/test_numeric_ops/test_tanh/out.sql | 2 +- .../test_numeric_ops/test_unsafe_pow_op/out.sql | 2 +- .../snapshots/test_string_ops/test_add_string/out.sql | 2 +- .../snapshots/test_string_ops/test_capitalize/out.sql | 2 +- .../snapshots/test_string_ops/test_endswith/out.sql | 2 +- .../snapshots/test_string_ops/test_isalnum/out.sql | 2 +- .../snapshots/test_string_ops/test_isalpha/out.sql | 2 +- .../snapshots/test_string_ops/test_isdecimal/out.sql | 2 +- .../snapshots/test_string_ops/test_isdigit/out.sql | 2 +- .../snapshots/test_string_ops/test_islower/out.sql | 2 +- .../snapshots/test_string_ops/test_isnumeric/out.sql | 2 +- .../snapshots/test_string_ops/test_isspace/out.sql | 2 +- .../snapshots/test_string_ops/test_isupper/out.sql | 2 +- .../snapshots/test_string_ops/test_len/out.sql | 2 +- .../snapshots/test_string_ops/test_len_w_array/out.sql | 2 +- .../snapshots/test_string_ops/test_lower/out.sql | 2 +- .../snapshots/test_string_ops/test_lstrip/out.sql | 2 +- .../test_string_ops/test_regex_replace_str/out.sql | 2 +- .../snapshots/test_string_ops/test_replace_str/out.sql | 2 +- .../snapshots/test_string_ops/test_reverse/out.sql | 2 +- .../snapshots/test_string_ops/test_rstrip/out.sql | 2 +- .../snapshots/test_string_ops/test_startswith/out.sql | 2 +- .../test_string_ops/test_str_contains/out.sql | 2 +- .../test_string_ops/test_str_contains_regex/out.sql | 2 +- .../snapshots/test_string_ops/test_str_extract/out.sql | 2 +- .../snapshots/test_string_ops/test_str_find/out.sql | 2 +- .../snapshots/test_string_ops/test_str_get/out.sql | 2 +- .../snapshots/test_string_ops/test_str_pad/out.sql | 2 +- .../snapshots/test_string_ops/test_str_repeat/out.sql | 2 +- .../snapshots/test_string_ops/test_str_slice/out.sql | 2 +- .../snapshots/test_string_ops/test_strconcat/out.sql | 2 +- .../test_string_ops/test_string_split/out.sql | 2 +- .../snapshots/test_string_ops/test_strip/out.sql | 2 +- .../snapshots/test_string_ops/test_upper/out.sql | 2 +- .../snapshots/test_string_ops/test_zfill/out.sql | 2 +- .../test_struct_ops/test_struct_field/out.sql | 2 +- .../snapshots/test_struct_ops/test_struct_op/out.sql | 2 +- .../test_timedelta_ops/test_timedelta_floor/out.sql | 2 +- .../test_timedelta_ops/test_to_timedelta/out.sql | 2 +- .../test_compile_aggregate/out.sql | 2 +- .../test_compile_aggregate_wo_dropna/out.sql | 2 +- .../test_compile_concat/test_compile_concat/out.sql | 4 ++-- .../test_compile_concat_filter_sorted/out.sql | 8 ++++---- .../test_compile_explode_dataframe/out.sql | 2 +- .../test_compile_explode_series/out.sql | 2 +- .../test_compile_filter/test_compile_filter/out.sql | 2 +- .../test_compile_isin/test_compile_isin/out.sql | 10 +++++----- .../test_compile_isin_not_nullable/out.sql | 4 ++-- .../test_compile_join/test_compile_join/out.sql | 4 ++-- .../test_compile_join_w_on/bool_col/out.sql | 4 ++-- .../test_compile_join_w_on/float64_col/out.sql | 4 ++-- .../test_compile_join_w_on/int64_col/out.sql | 4 ++-- .../test_compile_join_w_on/numeric_col/out.sql | 4 ++-- .../test_compile_join_w_on/string_col/out.sql | 4 ++-- .../test_compile_join_w_on/time_col/out.sql | 4 ++-- .../test_compile_readtable/out.sql | 2 +- .../test_compile_readtable_w_columns_filters/out.sql | 2 +- .../test_compile_readtable_w_json_types/out.sql | 2 +- .../test_compile_readtable_w_limit/out.sql | 2 +- .../out.sql | 2 +- .../test_compile_readtable_w_ordering/out.sql | 2 +- .../test_compile_readtable_w_repeated_types/out.sql | 2 +- .../test_compile_readtable_w_system_time/out.sql | 2 +- .../test_compile_window_w_groupby_rolling/out.sql | 2 +- .../test_compile_window_w_skips_nulls_op/out.sql | 2 +- .../test_compile_window_wo_skips_nulls_op/out.sql | 2 +- third_party/bigframes_vendored/sqlglot/generator.py | 3 ++- 285 files changed, 305 insertions(+), 302 deletions(-) diff --git a/bigframes/core/compile/sqlglot/sqlglot_ir.py b/bigframes/core/compile/sqlglot/sqlglot_ir.py index 3cedd04dc57..88d01c2a9e6 100644 --- a/bigframes/core/compile/sqlglot/sqlglot_ir.py +++ b/bigframes/core/compile/sqlglot/sqlglot_ir.py @@ -134,18 +134,20 @@ def from_table( """ version = ( sge.Version( - this="TIMESTAMP", - expression=sge.Literal(this=system_time.isoformat(), is_string=True), + this=sge.Identifier(this="SYSTEM_TIME", quoted=False), + expression=sge.Literal.string(system_time.isoformat()), kind="AS OF", ) if system_time else None ) + table_alias = next(uid_gen.get_uid_stream("bft_")) table_expr = sge.Table( this=sg.to_identifier(table_id, quoted=cls.quoted), db=sg.to_identifier(dataset_id, quoted=cls.quoted), catalog=sg.to_identifier(project_id, quoted=cls.quoted), version=version, + alias=sge.Identifier(this=table_alias, quoted=cls.quoted), ) if sql_predicate: select_expr = sge.Select().select(sge.Star()).from_(table_expr) 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 08272882e6b..fb930323dbd 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 @@ -2,7 +2,7 @@ WITH `bfcte_0` AS ( SELECT `int64_col`, `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT CORR(`int64_col`, `float64_col`) AS `bfcol_2` 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 7f4463e3b8e..92b8ea4d3ab 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 @@ -2,7 +2,7 @@ WITH `bfcte_0` AS ( SELECT `int64_col`, `float64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT COVAR_SAMP(`int64_col`, `float64_col`) AS `bfcol_2` 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 e2b5c841046..7056c8b0af3 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,3 +1,3 @@ SELECT ROW_NUMBER() OVER () - 1 AS `row_number` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 5301ba76fd3..8efea4b51bc 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,3 +1,3 @@ SELECT ROW_NUMBER() OVER (ORDER BY `int64_col` ASC NULLS LAST) - 1 AS `row_number` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 7a4393f8133..4d67203ecc6 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,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT * - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT COUNT(1) AS `bfcol_32` diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_array_agg/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_array_agg/out.sql index eafbc39daf8..f929970a227 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_array_agg/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_array_agg/out.sql @@ -1,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT ARRAY_AGG(`int64_col` IGNORE NULLS ORDER BY `int64_col` IS NULL ASC, `int64_col` ASC) AS `bfcol_1` diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_string_agg/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_string_agg/out.sql index 321341d4a0a..7e697719b36 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_string_agg/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_ordered_unary_compiler/test_string_agg/out.sql @@ -1,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT COALESCE( diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/out.sql index 0be2fea80b2..dc1f6fb4f79 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all/out.sql @@ -2,7 +2,7 @@ WITH `bfcte_0` AS ( SELECT `bool_col`, `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT COALESCE(LOGICAL_AND(`bool_col`), TRUE) AS `bfcol_2`, diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all_w_window/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all_w_window/out.sql index b05158ef22f..7e4c9d6c3c9 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all_w_window/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_all_w_window/out.sql @@ -1,3 +1,3 @@ SELECT COALESCE(LOGICAL_AND(`bool_col`) OVER (), TRUE) AS `agg_bool` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any/out.sql index ae62e22e36d..8ae589fb09f 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any/out.sql @@ -2,7 +2,7 @@ WITH `bfcte_0` AS ( SELECT `bool_col`, `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT COALESCE(LOGICAL_OR(`bool_col`), FALSE) AS `bfcol_2`, diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/out.sql index 4a13901f1c4..e8556018852 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/out.sql @@ -1,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT ANY_VALUE(`int64_col`) AS `bfcol_1` diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_out.sql index 15e30775712..020d7603b98 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_out.sql @@ -1,3 +1,3 @@ SELECT ANY_VALUE(`int64_col`) OVER () AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_partition_out.sql index d6b97b9b690..577c5929b91 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_value/window_partition_out.sql @@ -1,3 +1,3 @@ SELECT ANY_VALUE(`int64_col`) OVER (PARTITION BY `string_col`) AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_w_window/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_w_window/out.sql index ae7a1d92fa6..33045c4b70d 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_w_window/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_any_w_window/out.sql @@ -1,3 +1,3 @@ SELECT COALESCE(LOGICAL_OR(`bool_col`) OVER (), FALSE) AS `agg_bool` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 9eabb2d88a7..e2a119499f2 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,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT APPROX_QUANTILES(`int64_col`, 4)[OFFSET(1)] AS `bfcol_1`, 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 b5e6275381b..1c391c6691f 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,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT APPROX_TOP_COUNT(`int64_col`, 10) AS `bfcol_1` 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 9d18367cf61..61f073b7dc8 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,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT COUNT(`int64_col`) AS `bfcol_1` diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_out.sql index 7be9980fc23..e46b49e7e48 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_out.sql @@ -1,3 +1,3 @@ SELECT COUNT(`int64_col`) OVER () AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_partition_out.sql index 7f2066d98ea..98088d97dfc 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_count/window_partition_out.sql @@ -1,3 +1,3 @@ SELECT COUNT(`int64_col`) OVER (PARTITION BY `string_col`) AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins.sql index 0a4aa961ab8..ac5525fe63f 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins.sql @@ -44,4 +44,4 @@ SELECT ) + 0 AS `right_inclusive` ) END AS `int_bins` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins_labels.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins_labels.sql index b1042288360..94e9f57b28e 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins_labels.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/int_bins_labels.sql @@ -13,4 +13,4 @@ SELECT ) IS NOT NULL THEN 'c' END AS `int_bins_labels` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins.sql index 3365500e0bd..10f9778f55e 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins.sql @@ -5,4 +5,4 @@ SELECT WHEN `int64_col` > 1 AND `int64_col` <= 2 THEN STRUCT(1 AS `left_exclusive`, 2 AS `right_inclusive`) END AS `interval_bins` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins_labels.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins_labels.sql index 2cc91765c84..247c71a6349 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins_labels.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_cut/interval_bins_labels.sql @@ -5,4 +5,4 @@ SELECT WHEN `int64_col` > 1 AND `int64_col` <= 2 THEN 1 END AS `interval_bins_labels` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 d8f8e26ddcb..95f53752c34 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,3 +1,3 @@ SELECT DENSE_RANK() OVER (ORDER BY `int64_col` DESC) AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_bool/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_bool/out.sql index 18da6d95fbf..592f3e240a4 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_bool/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_bool/out.sql @@ -1,3 +1,3 @@ SELECT `bool_col` <> LAG(`bool_col`, 1) OVER (ORDER BY `bool_col` DESC) AS `diff_bool` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_date/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_date/out.sql index d5a548f9207..4b41355d948 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_date/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_date/out.sql @@ -2,4 +2,4 @@ SELECT CAST(FLOOR( DATE_DIFF(`date_col`, LAG(`date_col`, 1) OVER (ORDER BY `date_col` ASC NULLS LAST), DAY) * 86400000000 ) AS INT64) AS `diff_date` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_datetime/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_datetime/out.sql index c997025ad2a..866f49b1ed4 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_datetime/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_datetime/out.sql @@ -4,4 +4,4 @@ SELECT LAG(`datetime_col`, 1) OVER (ORDER BY `datetime_col` ASC NULLS LAST), MICROSECOND ) AS `diff_datetime` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_int/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_int/out.sql index 37acf8896ef..4c8a0880f3b 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_int/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_int/out.sql @@ -1,3 +1,3 @@ SELECT `int64_col` - LAG(`int64_col`, 1) OVER (ORDER BY `int64_col` ASC NULLS LAST) AS `diff_int` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_timestamp/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_timestamp/out.sql index 5ed7e83ae5c..364f6b69d84 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_timestamp/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_diff_w_timestamp/out.sql @@ -4,4 +4,4 @@ SELECT LAG(`timestamp_col`, 1) OVER (ORDER BY `timestamp_col` DESC), MICROSECOND ) AS `diff_timestamp` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first/out.sql index 29de93c80c9..86aedff91d1 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first/out.sql @@ -3,4 +3,4 @@ SELECT ORDER BY `int64_col` DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first_non_null/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first_non_null/out.sql index 4d53d126104..b7851a350ed 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first_non_null/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_first_non_null/out.sql @@ -3,4 +3,4 @@ SELECT ORDER BY `int64_col` ASC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last/out.sql index 8e41cbd8b69..d0bb802c333 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last/out.sql @@ -3,4 +3,4 @@ SELECT ORDER BY `int64_col` DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last_non_null/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last_non_null/out.sql index a563eeb52ad..39d063a3c99 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last_non_null/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_last_non_null/out.sql @@ -3,4 +3,4 @@ SELECT ORDER BY `int64_col` ASC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 1537d735ead..7e01c2c7187 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,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT MAX(`int64_col`) AS `bfcol_1` diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_out.sql index 75fdbcdc217..d6dec51cdb4 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_out.sql @@ -1,3 +1,3 @@ SELECT MAX(`int64_col`) OVER () AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_partition_out.sql index 48630c48e38..a35a64a8e5f 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_max/window_partition_out.sql @@ -1,3 +1,3 @@ SELECT MAX(`int64_col`) OVER (PARTITION BY `string_col`) AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 74319b646f2..94287fc432b 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 @@ -6,7 +6,7 @@ WITH `bfcte_0` AS ( `int64_col` AS `bfcol_6`, `bool_col` AS `bfcol_7`, `duration_col` AS `bfcol_8` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT AVG(`bfcol_6`) AS `bfcol_12`, diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_out.sql index 13a595b85e0..3443cd2a680 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_out.sql @@ -1,3 +1,3 @@ SELECT AVG(`int64_col`) OVER () AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_partition_out.sql index c1bfa7d10b3..b94b84ddb81 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/window_partition_out.sql @@ -1,3 +1,3 @@ SELECT AVG(`int64_col`) OVER (PARTITION BY `string_col`) AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 bfe94622b31..7d1215163f8 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 @@ -3,7 +3,7 @@ WITH `bfcte_0` AS ( `date_col`, `int64_col`, `string_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT APPROX_QUANTILES(`int64_col`, 2)[OFFSET(1)] AS `bfcol_3`, 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 0848313456e..144c07d7010 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,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT MIN(`int64_col`) AS `bfcol_1` diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_out.sql index ab5c4c21f97..031c19eff16 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_out.sql @@ -1,3 +1,3 @@ SELECT MIN(`int64_col`) OVER () AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_partition_out.sql index 2233ebe38dd..2de5bd5f717 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_min/window_partition_out.sql @@ -1,3 +1,3 @@ SELECT MIN(`int64_col`) OVER (PARTITION BY `string_col`) AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_nunique/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_nunique/out.sql index f0b54934b45..e0cc1a2eac5 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_nunique/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_nunique/out.sql @@ -1,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT COUNT(DISTINCT `int64_col`) AS `bfcol_1` diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/out.sql index 2d38311f45a..b855c791182 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/out.sql @@ -2,7 +2,7 @@ WITH `bfcte_0` AS ( SELECT `bool_col`, `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT VAR_POP(`int64_col`) AS `bfcol_4`, diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/window_out.sql index c3971c61b54..3bfaedd3953 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_pop_var/window_out.sql @@ -1,3 +1,3 @@ SELECT VAR_POP(`int64_col`) OVER () AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_product/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_product/out.sql index 94ca21988e9..33204f2ff56 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_product/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_product/out.sql @@ -1,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT CASE diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_product/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_product/window_partition_out.sql index 335bfcd17c2..532349d3599 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_product/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_product/window_partition_out.sql @@ -13,4 +13,4 @@ SELECT ) ) END AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_qcut/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_qcut/out.sql index 35a95c5367e..cb1541d083b 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_qcut/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_qcut/out.sql @@ -48,4 +48,4 @@ SELECT END, NULL ) AS `qcut_w_list` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 e337356d965..656d01ea2e5 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 @@ -2,7 +2,7 @@ WITH `bfcte_0` AS ( SELECT `bool_col`, `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT PERCENTILE_CONT(`int64_col`, 0.5) OVER () AS `bfcol_4`, 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 cdba69fe68d..2170d6cdcf7 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,3 +1,3 @@ SELECT RANK() OVER (ORDER BY `int64_col` DESC NULLS FIRST) AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lag.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lag.sql index 674c59fb1e2..2bea343497f 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lag.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lag.sql @@ -1,3 +1,3 @@ SELECT LAG(`int64_col`, 1) OVER (ORDER BY `int64_col` ASC) AS `lag` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lead.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lead.sql index eff56dd81d8..5055f443718 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lead.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/lead.sql @@ -1,3 +1,3 @@ SELECT LEAD(`int64_col`, 1) OVER (ORDER BY `int64_col` ASC) AS `lead` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/noop.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/noop.sql index ec2e9d11a06..65af6af7c79 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/noop.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_shift/noop.sql @@ -1,3 +1,3 @@ SELECT `int64_col` AS `noop` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql index c57abdba4b5..e3c3d7b5253 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql @@ -6,7 +6,7 @@ WITH `bfcte_0` AS ( `int64_col` AS `bfcol_6`, `bool_col` AS `bfcol_7`, `duration_col` AS `bfcol_8` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT STDDEV(`bfcol_6`) AS `bfcol_12`, diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/window_out.sql index 7f8da195e96..225dd5acf66 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/window_out.sql @@ -1,3 +1,3 @@ SELECT STDDEV(`int64_col`) OVER () AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 2bf6c26cd4b..c67eef9da34 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 @@ -2,7 +2,7 @@ WITH `bfcte_0` AS ( SELECT `bool_col`, `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT COALESCE(SUM(`int64_col`), 0) AS `bfcol_4`, diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_out.sql index 0a5ad499321..ea5a12edfb5 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_out.sql @@ -1,3 +1,3 @@ SELECT COALESCE(SUM(`int64_col`) OVER (), 0) AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_partition_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_partition_out.sql index ccf39df0f77..ec6083b1a9d 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_partition_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/window_partition_out.sql @@ -1,3 +1,3 @@ SELECT COALESCE(SUM(`int64_col`) OVER (PARTITION BY `string_col`), 0) AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/out.sql index 733a22438ce..b35d67c1ce1 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/out.sql @@ -2,7 +2,7 @@ WITH `bfcte_0` AS ( SELECT `bool_col`, `int64_col` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT VARIANCE(`int64_col`) AS `bfcol_4`, diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/window_out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/window_out.sql index c82ca3324d7..e33797d02fb 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/window_out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_var/window_out.sql @@ -1,3 +1,3 @@ SELECT VARIANCE(`int64_col`) OVER () AS `agg_int64` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_classify/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_classify/out.sql index 65098ca9e2a..63c31d94566 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_classify/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_classify/out.sql @@ -4,4 +4,4 @@ SELECT categories => ['greeting', 'rejection'], connection_id => 'bigframes-dev.us.bigframes-default-connection' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate/out.sql index 0d79dfd0f0f..9593347238f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate/out.sql @@ -4,4 +4,4 @@ SELECT endpoint => 'gemini-2.5-flash', request_type => 'SHARED' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 7a4260ed8d5..1c259eae673 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 @@ -4,4 +4,4 @@ SELECT endpoint => 'gemini-2.5-flash', request_type => 'SHARED' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool_with_connection_id/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool_with_connection_id/out.sql index ebbe4c0847d..27545685509 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool_with_connection_id/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_bool_with_connection_id/out.sql @@ -5,4 +5,4 @@ SELECT endpoint => 'gemini-2.5-flash', request_type => 'SHARED' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 2556208610c..aee8ca8ace0 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 @@ -4,4 +4,4 @@ SELECT request_type => 'SHARED', model_params => JSON '{}' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 2712af87752..124234fb06b 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 @@ -4,4 +4,4 @@ SELECT endpoint => 'gemini-2.5-flash', request_type => 'SHARED' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double_with_connection_id/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double_with_connection_id/out.sql index a1671c300df..1826c8a6ee2 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double_with_connection_id/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_double_with_connection_id/out.sql @@ -5,4 +5,4 @@ SELECT endpoint => 'gemini-2.5-flash', request_type => 'SHARED' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 4f6ada7eee3..330f32d7c8f 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 @@ -4,4 +4,4 @@ SELECT request_type => 'SHARED', model_params => JSON '{}' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 42fad82bcf5..19d1340f858 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 @@ -4,4 +4,4 @@ SELECT endpoint => 'gemini-2.5-flash', request_type => 'SHARED' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int_with_connection_id/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int_with_connection_id/out.sql index 0c565df519f..870cb4463a2 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int_with_connection_id/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_int_with_connection_id/out.sql @@ -5,4 +5,4 @@ SELECT endpoint => 'gemini-2.5-flash', request_type => 'SHARED' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 360ca346987..7fd8abe79e7 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 @@ -4,4 +4,4 @@ SELECT request_type => 'SHARED', model_params => JSON '{}' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_connection_id/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_connection_id/out.sql index 5e289430d98..67d670c4a8d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_connection_id/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_connection_id/out.sql @@ -5,4 +5,4 @@ SELECT endpoint => 'gemini-2.5-flash', request_type => 'SHARED' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_model_param/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_model_param/out.sql index 1706cf8f308..444d5753038 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_model_param/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_model_param/out.sql @@ -4,4 +4,4 @@ SELECT request_type => 'SHARED', model_params => JSON '{}' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_output_schema/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_output_schema/out.sql index c94637dc707..79ff4a79d39 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_output_schema/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_generate_with_output_schema/out.sql @@ -5,4 +5,4 @@ SELECT request_type => 'SHARED', output_schema => 'x INT64, y FLOAT64' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_if/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_if/out.sql index 8ad4457475d..698523d2e0b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_if/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_if/out.sql @@ -3,4 +3,4 @@ SELECT prompt => (`string_col`, ' is the same as ', `string_col`), connection_id => 'bigframes-dev.us.bigframes-default-connection' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_score/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_score/out.sql index 709dfd11c09..92de7cdcdc6 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_score/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_ai_ops/test_ai_score/out.sql @@ -3,4 +3,4 @@ SELECT prompt => (`string_col`, ' is the same as ', `string_col`), connection_id => 'bigframes-dev.us.bigframes-default-connection' ) AS `result` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 0198d92697e..4200470b655 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,3 +1,3 @@ SELECT `string_list_col`[SAFE_OFFSET(1)] AS `string_list_col` -FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_reduce_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_reduce_op/out.sql index 7c955a273aa..26fc32f68dc 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_reduce_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_array_reduce_op/out.sql @@ -19,4 +19,4 @@ SELECT COALESCE(LOGICAL_OR(bf_arr_reduce_uid), FALSE) FROM UNNEST(`bool_list_col`) AS bf_arr_reduce_uid ) AS `any_bool` -FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` AS `bft_0` \ 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 2fb104cdf40..c37e27b2cf4 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 @@ -6,4 +6,4 @@ SELECT WHERE slice_idx >= 1 ) AS `string_list_col` -FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` AS `bft_0` \ 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 e6bcf4f1e27..70417daf5c8 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 @@ -6,4 +6,4 @@ SELECT WHERE slice_idx >= 1 AND slice_idx < 5 ) AS `string_list_col` -FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` AS `bft_0` \ 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 435249cbe9c..27587771506 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,3 +1,3 @@ SELECT ARRAY_TO_STRING(`string_list_col`, '.') AS `string_list_col` -FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_to_array_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_to_array_op/out.sql index a243c37d4fe..f7d8d748b4a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_to_array_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_array_ops/test_to_array_op/out.sql @@ -7,4 +7,4 @@ SELECT CAST(COALESCE(`bool_col`, FALSE) AS INT64), COALESCE(`float64_col`, 0.0) ] AS `numeric_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 5efae7637a0..ca6f5842df1 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 @@ -3,4 +3,4 @@ SELECT OBJ.FETCH_METADATA( OBJ.MAKE_REF(`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') ).`version` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 675f19af69b..6d612ee6b87 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 @@ -7,4 +7,4 @@ SELECT ), '$.access_urls.read_url' ) AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 89e891c0825..74ca601cd5d 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,4 +1,4 @@ SELECT `rowindex`, OBJ.MAKE_REF(`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 074a291883a..7afe926ab41 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 @@ -5,4 +5,4 @@ SELECT `int64_col` & `int64_col` AS `int_and_int`, `bool_col` AND `bool_col` AS `bool_and_bool`, IF(`bool_col` = FALSE, `bool_col`, NULL) AS `bool_and_null` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 7ebb3f77fe4..89a80b05a8a 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 @@ -5,4 +5,4 @@ SELECT `int64_col` | `int64_col` AS `int_and_int`, `bool_col` OR `bool_col` AS `bool_and_bool`, IF(`bool_col` = TRUE, `bool_col`, NULL) AS `bool_and_null` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 5f90436ead7..74a8e810817 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 @@ -14,4 +14,4 @@ SELECT OR ( NOT `bool_col` AND CAST(NULL AS BOOLEAN) ) AS `bool_and_null` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 17ac7379815..3d23b8576ec 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,3 +1,3 @@ SELECT COALESCE(CAST(`int64_col` AS STRING), '$NULL_SENTINEL$') = COALESCE(CAST(CAST(`bool_col` AS INT64) AS STRING), '$NULL_SENTINEL$') AS `int64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 391311df073..37554c77e06 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 @@ -7,4 +7,4 @@ SELECT `int64_col` IS NULL AS `int_eq_null`, `int64_col` = CAST(`bool_col` AS INT64) AS `int_eq_bool`, CAST(`bool_col` AS INT64) = `int64_col` AS `bool_eq_int` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 aaab4f4e391..f66e8435ebf 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 @@ -6,4 +6,4 @@ SELECT `int64_col` >= 1 AS `int_ge_1`, `int64_col` >= CAST(`bool_col` AS INT64) AS `int_ge_bool`, CAST(`bool_col` AS INT64) >= `int64_col` AS `bool_ge_int` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 f83c4e87e00..d97f9d1d423 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 @@ -6,4 +6,4 @@ SELECT `int64_col` > 1 AS `int_gt_1`, `int64_col` > CAST(`bool_col` AS INT64) AS `int_gt_bool`, CAST(`bool_col` AS INT64) > `int64_col` AS `bool_gt_int` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 f5b60baee32..d1af7c57ae9 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 @@ -11,4 +11,4 @@ SELECT ( `float64_col` IS NULL ) OR `float64_col` IN (1, 2, 3) AS `float_in_ints` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 09ce08d2f0b..e4e542d1c58 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 @@ -6,4 +6,4 @@ SELECT `int64_col` <= 1 AS `int_le_1`, `int64_col` <= CAST(`bool_col` AS INT64) AS `int_le_bool`, CAST(`bool_col` AS INT64) <= `int64_col` AS `bool_le_int` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 bdeb6aee7e7..d616aecc8c2 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 @@ -6,4 +6,4 @@ SELECT `int64_col` < 1 AS `int_lt_1`, `int64_col` < CAST(`bool_col` AS INT64) AS `int_lt_bool`, CAST(`bool_col` AS INT64) < `int64_col` AS `bool_lt_int` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_maximum_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_maximum_op/out.sql index 1d710112c02..a469fa47cf1 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_maximum_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_maximum_op/out.sql @@ -1,3 +1,3 @@ SELECT GREATEST(`int64_col`, `float64_col`) AS `int64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_minimum_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_minimum_op/out.sql index 9372f1b5200..ea82af979a3 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_minimum_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_comparison_ops/test_minimum_op/out.sql @@ -1,3 +1,3 @@ SELECT LEAST(`int64_col`, `float64_col`) AS `int64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 d362f9820c7..abef6f93d62 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 @@ -9,4 +9,4 @@ SELECT ) IS NOT NULL AS `int_ne_null`, `int64_col` <> CAST(`bool_col` AS INT64) AS `int_ne_bool`, CAST(`bool_col` AS INT64) <> `int64_col` AS `bool_ne_int` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 f5a3b94c0bb..b1ccf096cfa 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 @@ -7,4 +7,4 @@ SELECT TIMESTAMP_ADD(CAST(`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_date`, TIMESTAMP_ADD(`timestamp_col`, INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_timestamp`, 172800000000 AS `timedelta_add_timedelta` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 90c29c6c7df..eb0d2f11049 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,3 +1,3 @@ SELECT DATE(`timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_datetime_to_integer_label/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_datetime_to_integer_label/out.sql index e29494a33df..8654f942707 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_datetime_to_integer_label/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_datetime_to_integer_label/out.sql @@ -23,4 +23,4 @@ SELECT ) ) AS INT64) + 1 END AS `non_fixed_freq_weekly` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 4f8f3637d57..b9c030cb53e 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,3 +1,3 @@ SELECT EXTRACT(DAY FROM `timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 4bd0cd4fd67..a25d520d804 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 @@ -2,4 +2,4 @@ SELECT CAST(MOD(EXTRACT(DAYOFWEEK FROM `datetime_col`) + 5, 7) AS INT64) AS `datetime_col`, CAST(MOD(EXTRACT(DAYOFWEEK FROM `timestamp_col`) + 5, 7) AS INT64) AS `timestamp_col`, CAST(MOD(EXTRACT(DAYOFWEEK FROM `date_col`) + 5, 7) AS INT64) AS `date_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 d8b919586ed..87a410911b5 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,3 +1,3 @@ SELECT EXTRACT(DAYOFYEAR FROM `timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 a40a726b4ed..49fb8fe5749 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 @@ -11,4 +11,4 @@ SELECT TIMESTAMP_TRUNC(`timestamp_col`, YEAR) AS `timestamp_col_Y`, TIMESTAMP_TRUNC(`datetime_col`, MICROSECOND) AS `datetime_col_q`, TIMESTAMP_TRUNC(`datetime_col`, MICROSECOND) AS `datetime_col_us` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 7b3189f3a67..e971057f527 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,3 +1,3 @@ SELECT EXTRACT(HOUR FROM `timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_fixed/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_fixed/out.sql index b4e23ed8772..244bd88deb7 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_fixed/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_fixed/out.sql @@ -2,4 +2,4 @@ SELECT CAST(TIMESTAMP_MICROS( CAST(CAST(`rowindex` AS BIGNUMERIC) * 86400000000 + CAST(UNIX_MICROS(CAST(`timestamp_col` AS TIMESTAMP)) AS BIGNUMERIC) AS INT64) ) AS TIMESTAMP) AS `fixed_freq` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_month/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_month/out.sql index 5d20e2c1d16..1ece688b91f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_month/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_month/out.sql @@ -36,4 +36,4 @@ SELECT 0 ) ) - INTERVAL 1 DAY AS TIMESTAMP) AS `non_fixed_freq_monthly` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_quarter/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_quarter/out.sql index ba2311dee6f..683b26be91b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_quarter/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_quarter/out.sql @@ -40,4 +40,4 @@ SELECT 0, 0 ) - INTERVAL 1 DAY AS TIMESTAMP) AS `non_fixed_freq` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_week/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_week/out.sql index 26960cbc290..6196e6976b0 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_week/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_week/out.sql @@ -4,4 +4,4 @@ SELECT TIMESTAMP_TRUNC(CAST(`timestamp_col` AS TIMESTAMP), WEEK(MONDAY)) + INTERVAL 6 DAY ) AS BIGNUMERIC) AS INT64) ) AS TIMESTAMP) AS `non_fixed_freq_weekly` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_year/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_year/out.sql index e4bed8e69fc..e0d05ec5b4b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_year/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_integer_label_to_datetime_year/out.sql @@ -1,3 +1,3 @@ SELECT CAST(TIMESTAMP(DATETIME(`rowindex` * 1 + EXTRACT(YEAR FROM `timestamp_col`) + 1, 1, 1, 0, 0, 0)) - INTERVAL 1 DAY AS TIMESTAMP) AS `non_fixed_freq_yearly` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 2277875a21c..bf7dfea7378 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,3 +1,3 @@ SELECT CAST(MOD(EXTRACT(DAYOFWEEK FROM `timestamp_col`) + 5, 7) AS INT64) + 1 AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 0c7ec5a8717..ce231592164 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,3 +1,3 @@ SELECT EXTRACT(ISOWEEK FROM `timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 6e0b7f264a2..aea4bec4371 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,3 +1,3 @@ SELECT EXTRACT(ISOYEAR FROM `timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 ed1842262cb..ed1ffcee104 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,3 +1,3 @@ SELECT EXTRACT(MINUTE FROM `timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 1f122f03929..8defb0312e9 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,3 +1,3 @@ SELECT EXTRACT(MONTH FROM `timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 0fc59582f78..0ae08c77ad0 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,3 +1,3 @@ SELECT TIMESTAMP_TRUNC(`timestamp_col`, DAY) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 6738427f768..9426f685855 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,3 +1,3 @@ SELECT EXTRACT(QUARTER FROM `timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 740eb3234b3..953a0ff762a 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,3 +1,3 @@ SELECT EXTRACT(SECOND FROM `timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 ac523e0da5a..308c040640d 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 @@ -3,4 +3,4 @@ SELECT FORMAT_DATETIME('%Y-%m-%d', `datetime_col`) AS `datetime_col`, FORMAT_TIME('%Y-%m-%d', `time_col`) AS `time_col`, FORMAT_TIMESTAMP('%Y-%m-%d', `timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 8c53679af1d..5c8b130d59d 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 @@ -8,4 +8,4 @@ SELECT TIMESTAMP_DIFF(CAST(`date_col` AS DATETIME), CAST(`date_col` AS DATETIME), MICROSECOND) AS `timestamp_sub_date`, TIMESTAMP_DIFF(`timestamp_col`, `timestamp_col`, MICROSECOND) AS `date_sub_timestamp`, `duration_col` - `duration_col` AS `timedelta_sub_timedelta` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 52125d4b831..e46ca373909 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,3 +1,3 @@ SELECT TIME(`timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 430ee6ef8be..5cbfa3dbe77 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 @@ -2,4 +2,4 @@ SELECT CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col` * 0.001) AS INT64)) AS DATETIME) AS `int64_col`, SAFE_CAST(`string_col` AS DATETIME), CAST(TIMESTAMP_MICROS(CAST(TRUNC(`float64_col` * 0.001) AS INT64)) AS DATETIME) AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 84c8660c885..eb829c05804 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 @@ -5,4 +5,4 @@ SELECT CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col` * 1000) AS INT64)) AS TIMESTAMP) AS `int64_col_ms`, CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col`) AS INT64)) AS TIMESTAMP) AS `int64_col_us`, CAST(TIMESTAMP_MICROS(CAST(TRUNC(`int64_col` * 0.001) AS INT64)) AS TIMESTAMP) AS `int64_col_ns` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 55d199f02d4..a212164e6ce 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,3 +1,3 @@ SELECT UNIX_MICROS(`timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 39c4bf42154..8df5ad956a3 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,3 +1,3 @@ SELECT UNIX_MILLIS(`timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 a4da6182c13..7344ca82949 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,3 +1,3 @@ SELECT UNIX_SECONDS(`timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 8e60460ce69..f1a1d7085ef 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,3 +1,3 @@ SELECT EXTRACT(YEAR FROM `timestamp_col`) AS `timestamp_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 1a347f5a9af..2f75cf4cf7f 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 @@ -2,4 +2,4 @@ SELECT `bool_col`, `float64_col` <> 0 AS `float64_col`, `float64_col` <> 0 AS `float64_w_safe` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 840436d1515..3d48001e77a 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 @@ -2,4 +2,4 @@ SELECT CAST(CAST(`bool_col` AS INT64) AS FLOAT64), CAST('1.34235e4' AS FLOAT64) AS `str_const`, SAFE_CAST(SAFE_CAST(`bool_col` AS INT64) AS FLOAT64) AS `bool_w_safe` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 882c7bc6f02..4603f503b5e 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 @@ -4,4 +4,4 @@ SELECT BOOL(`json_col`) AS `bool_col`, STRING(`json_col`) AS `string_col`, SAFE.INT64(`json_col`) AS `int64_w_safe` -FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`json_types` AS `bft_0` \ 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 37e544db6b5..8d44c674dc9 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 @@ -8,4 +8,4 @@ SELECT CAST(TRUNC(`float64_col`) AS INT64) AS `float64_col`, SAFE_CAST(TRUNC(`float64_col`) AS INT64) AS `float64_w_safe`, CAST('100' AS INT64) AS `str_const` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 f3293d2f87f..b62cee83a91 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 @@ -5,4 +5,4 @@ SELECT PARSE_JSON(`string_col`) AS `string_col`, PARSE_JSON(CAST(`bool_col` AS STRING)) AS `bool_w_safe`, SAFE.PARSE_JSON(`string_col`) AS `string_w_safe` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 aabdb6a40d1..3ea2299cc4f 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 @@ -2,4 +2,4 @@ SELECT CAST(`int64_col` AS STRING), INITCAP(CAST(`bool_col` AS STRING)) AS `bool_col`, INITCAP(SAFE_CAST(`bool_col` AS STRING)) AS `bool_w_safe` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 36d8ec09630..f50505592bb 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 @@ -3,4 +3,4 @@ SELECT CAST(TIMESTAMP_MICROS(`int64_col`) AS TIME) AS `int64_to_time`, CAST(TIMESTAMP_MICROS(`int64_col`) AS TIMESTAMP) AS `int64_to_timestamp`, SAFE_CAST(TIMESTAMP_MICROS(`int64_col`) AS TIME) AS `int64_to_time_safe` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_binary_remote_function_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_binary_remote_function_op/out.sql index 93dc413d80c..29f9d69cb25 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_binary_remote_function_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_binary_remote_function_op/out.sql @@ -1,3 +1,3 @@ SELECT `my_project`.`my_dataset`.`my_routine`(`int64_col`, `float64_col`) AS `int64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_case_when_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_case_when_op/out.sql index 9bd61690932..58e901fecc0 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_case_when_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_case_when_op/out.sql @@ -10,4 +10,4 @@ SELECT WHEN `bool_col` THEN `float64_col` END AS `mixed_types_cast` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_clip/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_clip/out.sql index 9106faf6c8b..bbfeb304181 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_clip/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_clip/out.sql @@ -1,3 +1,3 @@ SELECT GREATEST(LEAST(`rowindex`, `int64_too`), `int64_col`) AS `result_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_coalesce/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_coalesce/out.sql index 96fa1244029..4f88ec71d88 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_coalesce/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_coalesce/out.sql @@ -1,4 +1,4 @@ SELECT `int64_col`, COALESCE(`int64_too`, `int64_col`) AS `int64_too` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_fillna/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_fillna/out.sql index 52594023e9d..ae6f975da5a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_fillna/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_fillna/out.sql @@ -1,3 +1,3 @@ SELECT COALESCE(`int64_col`, `float64_col`) AS `int64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 52d0758ae4f..b1afe9db39b 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,3 +1,3 @@ SELECT FARM_FINGERPRINT(`string_col`) AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_invert/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_invert/out.sql index f16f4232de3..5cd1b15a776 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_invert/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_invert/out.sql @@ -8,4 +8,4 @@ SELECT NOT ( `bool_col` ) AS `bool_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 40c799a4e4d..cfe38ae3600 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 @@ -2,4 +2,4 @@ SELECT ( `float64_col` ) IS NULL AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 c217a632f38..3b1d0446b3b 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 @@ -6,4 +6,4 @@ SELECT THEN 'UNKNOWN' ELSE `string_col` END AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_nary_remote_function_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_nary_remote_function_op/out.sql index c330d2b0e68..a1977d809f7 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_nary_remote_function_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_nary_remote_function_op/out.sql @@ -1,3 +1,3 @@ SELECT `my_project`.`my_dataset`.`my_routine`(`int64_col`, `float64_col`, `string_col`) AS `int64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 c65fda76eb3..97b9f54f429 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 @@ -2,4 +2,4 @@ SELECT ( `float64_col` ) IS NOT NULL AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_remote_function_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_remote_function_op/out.sql index 4f83586edf1..1854c025882 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_remote_function_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_remote_function_op/out.sql @@ -5,4 +5,4 @@ SELECT `int64_col`, `my_project`.`my_dataset`.`my_routine`(`int64_col`) ) AS `apply_on_null_false` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_row_key/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_row_key/out.sql index d0646c18c18..f5bf9b3b6ee 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_row_key/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_row_key/out.sql @@ -43,4 +43,4 @@ SELECT ) AS STRING), CAST(RAND() AS STRING) ) AS `row_key` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_sql_scalar_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_sql_scalar_op/out.sql index 64a6e907028..8f50ff28ca4 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_sql_scalar_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_sql_scalar_op/out.sql @@ -1,3 +1,3 @@ SELECT CAST(`bool_col` AS INT64) + BYTE_LENGTH(`bytes_col`) AS `bool_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_where/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_where/out.sql index 651f24ffc7f..1ca3b009898 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_where/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_where/out.sql @@ -1,3 +1,3 @@ SELECT IF(`bool_col`, `int64_col`, `float64_col`) AS `result_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 d6de4f45769..78c786b036e 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,3 +1,3 @@ SELECT ST_AREA(`geography_col`) AS `geography_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 39eccc28459..526c0c37d7e 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,3 +1,3 @@ SELECT ST_ASTEXT(`geography_col`) AS `geography_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 4ae9288c59f..4bf43469cf5 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,3 +1,3 @@ SELECT ST_BOUNDARY(`geography_col`) AS `geography_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 d9273e11e89..40669569fbb 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,3 +1,3 @@ SELECT ST_BUFFER(`geography_col`, 1.0, 8.0, FALSE) AS `geography_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 375caae748f..accd33bd627 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,3 +1,3 @@ SELECT ST_CENTROID(`geography_col`) AS `geography_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 36e4daa6879..e4a718d42a9 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,3 +1,3 @@ SELECT ST_CONVEXHULL(`geography_col`) AS `geography_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_difference/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_difference/out.sql index 81e1cd09953..2a17ef1c7c8 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_difference/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_difference/out.sql @@ -1,3 +1,3 @@ SELECT ST_DIFFERENCE(`geography_col`, `geography_col`) AS `geography_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_distance/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_distance/out.sql index 24eab471096..4c55ddd0824 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_distance/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_distance/out.sql @@ -1,4 +1,4 @@ SELECT ST_DISTANCE(`geography_col`, `geography_col`, TRUE) AS `spheroid`, ST_DISTANCE(`geography_col`, `geography_col`, FALSE) AS `no_spheroid` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 2554b1a017e..db62766d4c9 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,3 +1,3 @@ SELECT SAFE.ST_GEOGFROMTEXT(`string_col`) AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogpoint/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogpoint/out.sql index eddd11cc3d0..3299ef0bd2d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogpoint/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogpoint/out.sql @@ -1,3 +1,3 @@ SELECT ST_GEOGPOINT(`rowindex`, `rowindex_2`) AS `rowindex` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_intersection/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_intersection/out.sql index b60b7248d93..a615ddf042e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_intersection/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_intersection/out.sql @@ -1,3 +1,3 @@ SELECT ST_INTERSECTION(`geography_col`, `geography_col`) AS `geography_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 32189c1bb90..4f04e70b569 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,3 +1,3 @@ SELECT ST_ISCLOSED(`geography_col`) AS `geography_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 18701e4d990..ee64b20ca46 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,3 +1,3 @@ SELECT ST_LENGTH(`geography_col`) AS `geography_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 bb44db105f2..c1ab623d9a1 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,3 +1,3 @@ SELECT ST_X(`geography_col`) AS `geography_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 e41be63567e..e7575606e6e 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,3 +1,3 @@ SELECT ST_Y(`geography_col`) AS `geography_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 95930efe79c..7a7ad2f394d 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,3 +1,3 @@ SELECT JSON_EXTRACT(`json_col`, '$') AS `json_col` -FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`json_types` AS `bft_0` \ 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 013bb32fef0..f2c4cd72985 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,3 +1,3 @@ SELECT JSON_EXTRACT_ARRAY(`json_col`, '$') AS `json_col` -FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`json_types` AS `bft_0` \ 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 3a0a623659e..61e8bae8a32 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,3 +1,3 @@ SELECT JSON_EXTRACT_STRING_ARRAY(`json_col`, '$') AS `json_col` -FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`json_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_keys/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_keys/out.sql index 4ae4786c190..78004c1180c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_keys/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_json_keys/out.sql @@ -1,4 +1,4 @@ SELECT JSON_KEYS(`json_col`, NULL) AS `json_keys`, JSON_KEYS(`json_col`, 2) AS `json_keys_w_max_depth` -FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`json_types` AS `bft_0` \ 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 d37a9db1bf8..8aa312e9d75 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,3 +1,3 @@ SELECT JSON_QUERY(`json_col`, '$') AS `json_col` -FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`json_types` AS `bft_0` \ 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 26e40b21d93..898068fe595 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,3 +1,3 @@ SELECT JSON_QUERY_ARRAY(`json_col`, '$') AS `json_col` -FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`json_types` AS `bft_0` \ 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 8e9de92fa52..e515d5fdc3b 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,3 +1,3 @@ SELECT JSON_SET(`json_col`, '$.a', 100) AS `json_col` -FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`json_types` AS `bft_0` \ 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 0bb8d89c33e..c9a73ae1942 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,3 +1,3 @@ SELECT JSON_VALUE(`json_col`, '$') AS `json_col` -FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`json_types` AS `bft_0` \ 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 e8be6759627..55a195edf20 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,3 +1,3 @@ SELECT PARSE_JSON(`string_col`) AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_to_json/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_to_json/out.sql index 2f7c6cbe086..ef89efa653b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_to_json/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_json_ops/test_to_json/out.sql @@ -1,3 +1,3 @@ SELECT TO_JSON(`string_col`) AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 fd4d74162af..62886c26ed9 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,3 +1,3 @@ SELECT TO_JSON_STRING(`json_col`) AS `json_col` -FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`json_types` AS `bft_0` \ 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 971a1492530..bc53c60895a 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,3 +1,3 @@ SELECT ABS(`float64_col`) AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 5243fcbd2d0..111684acd0c 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 @@ -6,4 +6,4 @@ SELECT `int64_col` + 1 AS `int_add_1`, `int64_col` + CAST(`bool_col` AS INT64) AS `int_add_bool`, CAST(`bool_col` AS INT64) + `int64_col` AS `bool_add_int` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_string/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_string/out.sql index 0031882bc70..cf4051464b7 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_string/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_string/out.sql @@ -1,3 +1,3 @@ SELECT CONCAT(`string_col`, 'a') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_timedelta/out.sql index f5a3b94c0bb..b1ccf096cfa 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_add_timedelta/out.sql @@ -7,4 +7,4 @@ SELECT TIMESTAMP_ADD(CAST(`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_date`, TIMESTAMP_ADD(`timestamp_col`, INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_timestamp`, 172800000000 AS `timedelta_add_timedelta` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 6469c88421c..d00086dfde8 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 @@ -4,4 +4,4 @@ SELECT THEN CAST('NaN' AS FLOAT64) ELSE ACOS(`float64_col`) END AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 13fd28298db..f1a04757a0a 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 @@ -4,4 +4,4 @@ SELECT THEN CAST('NaN' AS FLOAT64) ELSE ACOSH(`float64_col`) END AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 48ba4a9fdbd..eff8f1f5007 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 @@ -4,4 +4,4 @@ SELECT THEN CAST('NaN' AS FLOAT64) ELSE ASIN(`float64_col`) END AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 c6409c13734..557407f09ee 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,3 +1,3 @@ SELECT ASINH(`float64_col`) AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 70025441dba..d99b62f2cdb 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,3 +1,3 @@ SELECT ATAN(`float64_col`) AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan2/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan2/out.sql index 044c0a01511..463896e981f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan2/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_arctan2/out.sql @@ -1,4 +1,4 @@ SELECT ATAN2(`int64_col`, `float64_col`) AS `int64_col`, ATAN2(CAST(`bool_col` AS INT64), `float64_col`) AS `bool_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 218cd7f4908..9b016071480 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 @@ -6,4 +6,4 @@ SELECT THEN CAST('NaN' AS FLOAT64) ELSE CAST('Infinity' AS FLOAT64) * `float64_col` END AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 b202cc874d3..f69ae7f2760 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,3 +1,3 @@ SELECT CEIL(`float64_col`) AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 bd57e61deab..427dfbb9a93 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,3 +1,3 @@ SELECT COS(`float64_col`) AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 4666fc9443c..0f119c254f0 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 @@ -4,4 +4,4 @@ SELECT THEN CAST('Infinity' AS FLOAT64) ELSE COSH(`float64_col`) END AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosine_distance/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosine_distance/out.sql index e80dd7d91b6..1c482fc8a78 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosine_distance/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_cosine_distance/out.sql @@ -1,4 +1,4 @@ SELECT ML.DISTANCE(`int_list_col`, `int_list_col`, 'COSINE') AS `int_list_col`, ML.DISTANCE(`float_list_col`, `float_list_col`, 'COSINE') AS `float_list_col` -FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` AS `bft_0` \ 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 42928d83a45..1b8166684cf 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 @@ -11,4 +11,4 @@ SELECT IEEE_DIVIDE(`float64_col`, 0.0) AS `float_div_0`, IEEE_DIVIDE(`int64_col`, CAST(`bool_col` AS INT64)) AS `int_div_bool`, IEEE_DIVIDE(CAST(`bool_col` AS INT64), `int64_col`) AS `bool_div_int` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 f8eaf06e5f2..52bec0921ab 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 @@ -3,4 +3,4 @@ SELECT `timestamp_col`, `int64_col`, CAST(FLOOR(IEEE_DIVIDE(86400000000, `int64_col`)) AS INT64) AS `timedelta_div_numeric` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_euclidean_distance/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_euclidean_distance/out.sql index 18bbd3d412d..349d78584a9 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_euclidean_distance/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_euclidean_distance/out.sql @@ -1,4 +1,4 @@ SELECT ML.DISTANCE(`int_list_col`, `int_list_col`, 'EUCLIDEAN') AS `int_list_col`, ML.DISTANCE(`numeric_list_col`, `numeric_list_col`, 'EUCLIDEAN') AS `numeric_list_col` -FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` AS `bft_0` \ 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 b854008e1ee..178282ca087 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 @@ -4,4 +4,4 @@ SELECT THEN CAST('Infinity' AS FLOAT64) ELSE EXP(`float64_col`) END AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 86ab545c1da..6c896448f24 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,3 +1,3 @@ SELECT IF(`float64_col` > 709.78, CAST('Infinity' AS FLOAT64), EXP(`float64_col`) - 1) AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 c53e2143138..31b715623cb 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,3 +1,3 @@ SELECT FLOOR(`float64_col`) AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 bbcc43d1fc3..4d978991eb5 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 @@ -3,4 +3,4 @@ SELECT `timestamp_col`, `date_col`, 43200000000 AS `timedelta_div_numeric` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_isfinite/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_isfinite/out.sql index 500d6a6769f..54cbe2dd689 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_isfinite/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_isfinite/out.sql @@ -1,3 +1,3 @@ SELECT NOT IS_INF(`float64_col`) OR IS_NAN(`float64_col`) AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 4d28ba6c771..53ab88b7fc3 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 @@ -8,4 +8,4 @@ SELECT THEN CAST('NaN' AS FLOAT64) ELSE CAST('-Infinity' AS FLOAT64) END AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 509ca0a2f33..2037649332f 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 @@ -8,4 +8,4 @@ SELECT THEN CAST('NaN' AS FLOAT64) ELSE CAST('-Infinity' AS FLOAT64) END AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 4e63205a287..f7ddf4c223f 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 @@ -8,4 +8,4 @@ SELECT THEN CAST('NaN' AS FLOAT64) ELSE CAST('-Infinity' AS FLOAT64) END AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_manhattan_distance/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_manhattan_distance/out.sql index 35e53e1ee29..b6132a9fd6e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_manhattan_distance/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_manhattan_distance/out.sql @@ -1,4 +1,4 @@ SELECT ML.DISTANCE(`float_list_col`, `float_list_col`, 'MANHATTAN') AS `float_list_col`, ML.DISTANCE(`numeric_list_col`, `numeric_list_col`, 'MANHATTAN') AS `numeric_list_col` -FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mod_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mod_numeric/out.sql index fdd6f3f305a..2a79820635c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mod_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mod_numeric/out.sql @@ -190,4 +190,4 @@ SELECT ) ELSE MOD(CAST(`float64_col` AS BIGNUMERIC), CAST(0 AS BIGNUMERIC)) END AS `float_mod_0` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 00c4d64fb4d..57aff081589 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 @@ -6,4 +6,4 @@ SELECT `int64_col` * 1 AS `int_mul_1`, `int64_col` * CAST(`bool_col` AS INT64) AS `int_mul_bool`, CAST(`bool_col` AS INT64) * `int64_col` AS `bool_mul_int` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_timedelta/out.sql index 30ca104e614..46a9640df36 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_mul_timedelta/out.sql @@ -5,4 +5,4 @@ SELECT `duration_col`, CAST(FLOOR(`duration_col` * `int64_col`) AS INT64) AS `timedelta_mul_numeric`, CAST(FLOOR(`int64_col` * `duration_col`) AS INT64) AS `numeric_mul_timedelta` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 a2141579ca2..13a9f3f6734 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 @@ -2,4 +2,4 @@ SELECT -( `float64_col` ) AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 9174e063743..1890218bdd9 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,3 +1,3 @@ SELECT `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pow/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pow/out.sql index 8455e4a66fb..8f72522262c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pow/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_pow/out.sql @@ -242,4 +242,4 @@ SELECT END ) END AS `float_pow_1` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_round/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_round/out.sql index 2301645eb72..9ac8e1065b5 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_round/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_round/out.sql @@ -8,4 +8,4 @@ SELECT ROUND(`float64_col`, 0) AS `float_round_0`, ROUND(`float64_col`, 1) AS `float_round_1`, ROUND(`float64_col`, -1) AS `float_round_m1` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 04489505d1b..ddc7cfab6ce 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,3 +1,3 @@ SELECT SIN(`float64_col`) AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 add574e772d..a1d71a7a065 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 @@ -4,4 +4,4 @@ SELECT THEN SIGN(`float64_col`) * CAST('Infinity' AS FLOAT64) ELSE SINH(`float64_col`) END AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 e6d18871f92..6162a69d571 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,3 +1,3 @@ SELECT CASE WHEN `float64_col` < 0 THEN CAST('NaN' AS FLOAT64) ELSE SQRT(`float64_col`) END AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 dc95e3a28b1..e1ca93d1363 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 @@ -6,4 +6,4 @@ SELECT `int64_col` - 1 AS `int_add_1`, `int64_col` - CAST(`bool_col` AS INT64) AS `int_add_bool`, CAST(`bool_col` AS INT64) - `int64_col` AS `bool_add_int` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_timedelta/out.sql index 8c53679af1d..5c8b130d59d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_sub_timedelta/out.sql @@ -8,4 +8,4 @@ SELECT TIMESTAMP_DIFF(CAST(`date_col` AS DATETIME), CAST(`date_col` AS DATETIME), MICROSECOND) AS `timestamp_sub_date`, TIMESTAMP_DIFF(`timestamp_col`, `timestamp_col`, MICROSECOND) AS `date_sub_timestamp`, `duration_col` - `duration_col` AS `timedelta_sub_timedelta` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 d00c5cb791f..138b5f84a3b 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,3 +1,3 @@ SELECT TAN(`float64_col`) AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 5d25fc32589..c5db31c9579 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,3 +1,3 @@ SELECT TANH(`float64_col`) AS `float64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_unsafe_pow_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_unsafe_pow_op/out.sql index ab1e9663ced..0795b64a209 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_unsafe_pow_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_numeric_ops/test_unsafe_pow_op/out.sql @@ -5,7 +5,7 @@ SELECT POWER(`float64_col`, `float64_col`) AS `float_pow_float`, POWER(`int64_col`, CAST(`bool_col` AS INT64)) AS `int_pow_bool`, POWER(CAST(`bool_col` AS INT64), `int64_col`) AS `bool_pow_int` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` WHERE ( `int64_col` >= 0 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 0031882bc70..cf4051464b7 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,3 +1,3 @@ SELECT CONCAT(`string_col`, 'a') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 97c694aaa25..d11ce9b9934 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,3 +1,3 @@ SELECT INITCAP(`string_col`, '') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 0653a3fdc48..0295af27992 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 @@ -2,4 +2,4 @@ SELECT ENDS_WITH(`string_col`, 'ab') AS `single`, ENDS_WITH(`string_col`, 'ab') OR ENDS_WITH(`string_col`, 'cd') AS `double`, FALSE AS `empty` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 530888a7e00..7654299c79e 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,3 +1,3 @@ SELECT REGEXP_CONTAINS(`string_col`, '^(\\p{N}|\\p{L})+$') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 0e48876157c..33a08ff054d 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,3 +1,3 @@ SELECT REGEXP_CONTAINS(`string_col`, '^\\p{L}+$') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 fa47e342bb1..7f266cbf604 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,3 +1,3 @@ SELECT REGEXP_CONTAINS(`string_col`, '^(\\p{Nd})+$') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 66a2f8175a7..9134d035153 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 @@ -3,4 +3,4 @@ SELECT `string_col`, '^[\\p{Nd}\\x{00B9}\\x{00B2}\\x{00B3}\\x{2070}\\x{2074}-\\x{2079}\\x{2080}-\\x{2089}]+$' ) AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 861687a301b..bce92035e5c 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,3 +1,3 @@ SELECT LOWER(`string_col`) = `string_col` AND UPPER(`string_col`) <> `string_col` AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 c23fb577bac..82baa081f54 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,3 +1,3 @@ SELECT REGEXP_CONTAINS(`string_col`, '^\\pN+$') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 f38be0bfbc4..2b44a592d93 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,3 +1,3 @@ SELECT REGEXP_CONTAINS(`string_col`, '^\\s+$') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 d08f2550529..17ac14ac53f 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,3 +1,3 @@ SELECT UPPER(`string_col`) = `string_col` AND LOWER(`string_col`) <> `string_col` AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 0f5bb072d77..cff109d09dc 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,3 +1,3 @@ SELECT LENGTH(`string_col`) AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len_w_array/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len_w_array/out.sql index bbef05c6737..1862deb6015 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len_w_array/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_len_w_array/out.sql @@ -1,3 +1,3 @@ SELECT ARRAY_LENGTH(`int_list_col`) AS `int_list_col` -FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` AS `bft_0` \ 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 80b7fd8a589..851de35ecb0 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,3 +1,3 @@ SELECT LOWER(`string_col`) AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 d76f4dee73d..4023605f8c9 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,3 +1,3 @@ SELECT LTRIM(`string_col`, ' ') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 0146ddf4c4a..4728c961ab3 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,3 +1,3 @@ SELECT REGEXP_REPLACE(`string_col`, 'e', 'a') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 c3851a294fd..154af44b500 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,3 +1,3 @@ SELECT REPLACE(`string_col`, 'e', 'a') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 6c919b52e07..97bf57f79e1 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,3 +1,3 @@ SELECT REVERSE(`string_col`) AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 67c6030b416..c3d25b56e24 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,3 +1,3 @@ SELECT RTRIM(`string_col`, ' ') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 b0e1f77ad00..760d3db7745 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 @@ -2,4 +2,4 @@ SELECT STARTS_WITH(`string_col`, 'ab') AS `single`, STARTS_WITH(`string_col`, 'ab') OR STARTS_WITH(`string_col`, 'cd') AS `double`, FALSE AS `empty` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 c8a5d766ef6..9071a252bc1 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,3 +1,3 @@ SELECT `string_col` LIKE '%e%' AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 e32010f9e4b..958f9af6f39 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,3 +1,3 @@ SELECT REGEXP_CONTAINS(`string_col`, 'e') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 96552cc7326..a87f5d9836d 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 @@ -9,4 +9,4 @@ SELECT REGEXP_REPLACE(`string_col`, CONCAT('.*?', '([a-z]*)', '.*'), '\\1'), NULL ) AS `one` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_find/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_find/out.sql index 79a5f7c6388..cf21fb8234a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_find/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_str_find/out.sql @@ -3,4 +3,4 @@ SELECT INSTR(`string_col`, 'e', 3) - 1 AS `start_none`, INSTR(SUBSTRING(`string_col`, 1, 5), 'e') - 1 AS `none_end`, INSTR(SUBSTRING(`string_col`, 3, 3), 'e') - 1 AS `start_end` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 f2717ede36b..b4c7c504fc9 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,3 +1,3 @@ SELECT IF(SUBSTRING(`string_col`, 2, 1) <> '', SUBSTRING(`string_col`, 2, 1), NULL) AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 12ea103743a..29766cca6c1 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 @@ -10,4 +10,4 @@ SELECT GREATEST(LENGTH(`string_col`), 10), '-' ) AS `both` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 9ad03238efa..ed3d06ed35a 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,3 +1,3 @@ SELECT REPEAT(`string_col`, 2) AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 c0d5886a940..df4dc689f70 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,3 +1,3 @@ SELECT SUBSTRING(`string_col`, 2, 2) AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strconcat/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strconcat/out.sql index 0031882bc70..cf4051464b7 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strconcat/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_string_ops/test_strconcat/out.sql @@ -1,3 +1,3 @@ SELECT CONCAT(`string_col`, 'a') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 ca8c4f1d61b..5145d6686a8 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,3 +1,3 @@ SELECT SPLIT(`string_col`, ',') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 5bf171c0ba0..e07185292bb 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,3 +1,3 @@ SELECT TRIM(`string_col`, ' ') AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 8e6b2ba657a..88bd78bd095 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,3 +1,3 @@ SELECT UPPER(`string_col`) AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 0cfd70950e4..818d2907add 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 @@ -4,4 +4,4 @@ SELECT THEN CONCAT('-', LPAD(SUBSTRING(`string_col`, 2), GREATEST(LENGTH(`string_col`), 10) - 1, '0')) ELSE LPAD(`string_col`, GREATEST(LENGTH(`string_col`), 10), '0') END AS `string_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 de60033454b..6c3760aa36e 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,4 +1,4 @@ SELECT `people`.`name` AS `string`, `people`.`name` AS `int` -FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_op/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_op/out.sql index 56024b50fc9..3549149609a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_op/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_struct_ops/test_struct_op/out.sql @@ -5,4 +5,4 @@ SELECT `float64_col` AS float64_col, `string_col` AS string_col ) AS `result_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 362a958b62e..6eb6f8e989d 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,3 +1,3 @@ SELECT FLOOR(`int64_col`) AS `int64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 109f72f0dc1..59aa3d9b0b3 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 @@ -6,4 +6,4 @@ SELECT CAST(FLOOR(`float64_col` * 1000000) AS INT64) AS `duration_s`, `int64_col` * 3600000000 AS `duration_w`, `int64_col` AS `duration_on_duration` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ 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 153ff1e03a4..cfd9c7c87f0 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 @@ -4,7 +4,7 @@ WITH `bfcte_0` AS ( `int64_too`, `int64_too` AS `bfcol_2`, `bool_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT `bfcol_3`, 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 4a9fd5374d3..e71099d82e6 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 @@ -4,7 +4,7 @@ WITH `bfcte_0` AS ( `int64_too`, `int64_too` AS `bfcol_2`, `bool_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT `bfcol_3`, 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 efa7c6cbe95..3b0f9f0633d 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 @@ -15,7 +15,7 @@ WITH `bfcte_0` AS ( `string_col` AS `bfcol_12`, 0 AS `bfcol_13`, ROW_NUMBER() OVER () - 1 AS `bfcol_14` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ) UNION ALL ( @@ -26,7 +26,7 @@ WITH `bfcte_0` AS ( `string_col` AS `bfcol_27`, 1 AS `bfcol_28`, ROW_NUMBER() OVER () - 1 AS `bfcol_29` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ) ) ) diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat_filter_sorted/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat_filter_sorted/out.sql index 82534292032..a18d6998d43 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat_filter_sorted/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat_filter_sorted/out.sql @@ -11,7 +11,7 @@ WITH `bfcte_0` AS ( `int64_col` AS `bfcol_7`, 0 AS `bfcol_8`, ROW_NUMBER() OVER (ORDER BY `int64_col` ASC NULLS LAST) - 1 AS `bfcol_9` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ) UNION ALL ( @@ -20,7 +20,7 @@ WITH `bfcte_0` AS ( `int64_too` AS `bfcol_18`, 1 AS `bfcol_19`, ROW_NUMBER() OVER () - 1 AS `bfcol_20` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` WHERE `bool_col` ) @@ -31,7 +31,7 @@ WITH `bfcte_0` AS ( `int64_col` AS `bfcol_28`, 2 AS `bfcol_29`, ROW_NUMBER() OVER (ORDER BY `int64_col` ASC NULLS LAST) - 1 AS `bfcol_30` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ) UNION ALL ( @@ -40,7 +40,7 @@ WITH `bfcte_0` AS ( `int64_too` AS `bfcol_39`, 3 AS `bfcol_40`, ROW_NUMBER() OVER () - 1 AS `bfcol_41` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` WHERE `bool_col` ) 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 4f05929e0c7..e2a80e201bb 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 @@ -3,7 +3,7 @@ WITH `bfcte_0` AS ( `rowindex`, `int_list_col`, `string_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` + FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` AS `bft_0` ), `bfcte_1` AS ( SELECT * 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 d5b42741d31..03ac4d0e03a 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 @@ -2,7 +2,7 @@ WITH `bfcte_0` AS ( SELECT `rowindex`, `int_list_col` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` + FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` AS `bft_0` ), `bfcte_1` AS ( SELECT * 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 062e02c24c5..3e367c1e1e2 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 @@ -2,6 +2,6 @@ SELECT `rowindex`, `rowindex` AS `rowindex_1`, `int64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` WHERE `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 410b400f920..d80febf41ca 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 @@ -2,11 +2,11 @@ WITH `bfcte_2` AS ( SELECT `rowindex` AS `bfcol_2`, `int64_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_0` AS ( SELECT `int64_too` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT `int64_too` @@ -23,10 +23,10 @@ WITH `bfcte_2` AS ( SELECT `int64_too` AS `bfcol_4` FROM `bfcte_1` - ) AS `bft_0` + ) AS `bft_1` 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) + COALESCE(`bfcte_2`.`bfcol_3`, 0) = COALESCE(`bft_1`.`bfcol_4`, 0) + AND COALESCE(`bfcte_2`.`bfcol_3`, 1) = COALESCE(`bft_1`.`bfcol_4`, 1) ) AS `bfcol_5` FROM `bfcte_2` ) 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 61d4185a0d1..2b2735b1637 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 @@ -2,11 +2,11 @@ WITH `bfcte_2` AS ( SELECT `rowindex` AS `bfcol_2`, `rowindex_2` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_0` AS ( SELECT `rowindex_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT `rowindex_2` 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 baddb66b09d..dfc40840271 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 @@ -2,12 +2,12 @@ WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_2`, `int64_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT `int64_col` AS `bfcol_6`, `int64_too` AS `bfcol_7` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_2` AS ( SELECT * 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 8f55e7a6ef8..b3a2b456737 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 @@ -2,12 +2,12 @@ WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_2`, `bool_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT `rowindex` AS `bfcol_6`, `bool_col` AS `bfcol_7` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_2` AS ( SELECT * 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 1bf5912bce6..4abc6aa4a75 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 @@ -2,12 +2,12 @@ WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_2`, `float64_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT `rowindex` AS `bfcol_6`, `float64_col` AS `bfcol_7` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_2` AS ( SELECT * 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 3e0f105a7be..b841ac1325c 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 @@ -2,12 +2,12 @@ WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_2`, `int64_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT `rowindex` AS `bfcol_6`, `int64_col` AS `bfcol_7` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_2` AS ( SELECT * 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 b2481e07ace..af2aaa69dc4 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 @@ -2,12 +2,12 @@ WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_2`, `numeric_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT `rowindex` AS `bfcol_6`, `numeric_col` AS `bfcol_7` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_2` AS ( SELECT * 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 f804b0d1f87..dfde2efb868 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 @@ -2,12 +2,12 @@ WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_0`, `string_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT `rowindex` AS `bfcol_4`, `string_col` AS `bfcol_5` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_2` AS ( SELECT * 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 8fc9e135eee..5a858124416 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 @@ -2,12 +2,12 @@ WITH `bfcte_0` AS ( SELECT `rowindex` AS `bfcol_0`, `time_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_1` AS ( SELECT `rowindex` AS `bfcol_4`, `time_col` AS `bfcol_5` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ), `bfcte_2` AS ( SELECT * 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 e0f6e7f3d2e..626ef80d518 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 @@ -15,4 +15,4 @@ SELECT `time_col`, `timestamp_col`, `duration_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_columns_filters/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_columns_filters/out.sql index 2dae14b556e..512d3ca6bdd 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_columns_filters/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_columns_filters/out.sql @@ -1,7 +1,7 @@ WITH `bfcte_0` AS ( SELECT * - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` WHERE `rowindex` > 0 AND `string_col` IN ('Hello, World!') ) 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 77a17ec893d..054e850fd36 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,3 +1,3 @@ SELECT * -FROM `bigframes-dev`.`sqlglot_test`.`json_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`json_types` AS `bft_0` \ 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 90ad5b0186f..ff4f0656b12 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,7 +1,7 @@ SELECT `rowindex`, `int64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` 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 678b3b694f0..f75fa6f722c 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 @@ -2,4 +2,4 @@ SELECT `id`, `id` AS `id_1`, `people` -FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` AS `bft_0` \ 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 fb114c50e81..7e6ddfd568f 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,6 +1,6 @@ SELECT `rowindex`, `int64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` 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 41f0d13d4fd..34b02b5209b 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 @@ -8,4 +8,4 @@ SELECT `date_time_list_col`, `numeric_list_col`, `string_list_col` -FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` AS `bft_0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql index b579e3a6fed..dcd40d78485 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_system_time/out.sql @@ -1,3 +1,3 @@ SELECT * -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` FOR SYSTEM_TIME AS OF '2025-11-09T03:04:05.678901+00:00' \ No newline at end of file +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` FOR SYSTEM_TIME AS OF '2025-11-09T03:04:05.678901+00:00' \ 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 b91aafcbee5..1051a0fb4c1 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 @@ -45,7 +45,7 @@ SELECT 0 ) END AS `int64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` WHERE ( `bool_col` 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 8a8bf6445a1..21bb8d5f088 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 @@ -14,6 +14,6 @@ SELECT 0 ) END AS `int64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` 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 cf14f1cd055..6ae1fffab7a 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 @@ -8,6 +8,6 @@ SELECT WHEN TRUE THEN COUNT(`int64_col`) OVER (ORDER BY `rowindex` ASC NULLS LAST ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) END AS `int64_col` -FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` ORDER BY `rowindex` ASC NULLS LAST \ No newline at end of file diff --git a/third_party/bigframes_vendored/sqlglot/generator.py b/third_party/bigframes_vendored/sqlglot/generator.py index 1084d5de899..02ce3110813 100644 --- a/third_party/bigframes_vendored/sqlglot/generator.py +++ b/third_party/bigframes_vendored/sqlglot/generator.py @@ -2254,7 +2254,8 @@ def table_sql(self, expression: exp.Table, sep: str = " AS ") -> str: else: indexed = "" - return f"{only}{table}{changes}{partition}{version}{file_format}{sample_pre_alias}{alias}{indexed}{hints}{pivots}{sample_post_alias}{joins}{laterals}{ordinality}" + # Workaround https://github.com/tobymao/sqlglot/issues/7073 + return f"{only}{table}{changes}{alias}{partition}{version}{file_format}{sample_pre_alias}{indexed}{hints}{pivots}{sample_post_alias}{joins}{laterals}{ordinality}" def tablefromrows_sql(self, expression: exp.TableFromRows) -> str: table = self.func("TABLE", expression.this) From 5c91fb6766e7e625a7c39ed4ce7bb020f4b39ce0 Mon Sep 17 00:00:00 2001 From: Shenyang Cai Date: Wed, 18 Feb 2026 07:34:46 -0800 Subject: [PATCH 17/17] chore: librarian release pull request: 20260217T233413Z (#2461) PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: v0.7.0 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:1a2a85ab507aea26d787c06cc7979decb117164c81dd78a745982dfda80d4f68
bigframes: 2.36.0 ## [2.36.0](https://github.com/googleapis/python-bigquery-dataframes/compare/v2.35.0...v2.36.0) (2026-02-17) ### Features * Initial support for biglake iceberg tables (#2409) ([ae35a989](https://github.com/googleapis/python-bigquery-dataframes/commit/ae35a989)) * add bigquery.ai.generate_table function (#2453) ([b925aa24](https://github.com/googleapis/python-bigquery-dataframes/commit/b925aa24)) ### Documentation * fix generate_text and generate_table input docs (#2455) ([078bd32e](https://github.com/googleapis/python-bigquery-dataframes/commit/078bd32e)) * update multimodal dataframe notebook to use public APIs (#2456) ([342fa723](https://github.com/googleapis/python-bigquery-dataframes/commit/342fa723)) * use direct API for pdf chunk and pdf extract (#2452) ([543ce52c](https://github.com/googleapis/python-bigquery-dataframes/commit/543ce52c)) * use direct API for audio transcription (#2447) ([59cbc5db](https://github.com/googleapis/python-bigquery-dataframes/commit/59cbc5db)) * Add EXIF metadata extraction example to multimodal notebook (#2429) ([84c6f883](https://github.com/googleapis/python-bigquery-dataframes/commit/84c6f883)) * Update multimodal notebook to use public runtime helpers (#2451) ([e36dd8b4](https://github.com/googleapis/python-bigquery-dataframes/commit/e36dd8b4))
--- .librarian/state.yaml | 2 +- CHANGELOG.md | 18 ++++++++++++++++++ bigframes/version.py | 4 ++-- third_party/bigframes_vendored/version.py | 4 ++-- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.librarian/state.yaml b/.librarian/state.yaml index 8d933600672..73bd5d0bc6c 100644 --- a/.librarian/state.yaml +++ b/.librarian/state.yaml @@ -1,7 +1,7 @@ image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:1a2a85ab507aea26d787c06cc7979decb117164c81dd78a745982dfda80d4f68 libraries: - id: bigframes - version: 2.35.0 + version: 2.36.0 last_generated_commit: "" apis: [] source_roots: diff --git a/CHANGELOG.md b/CHANGELOG.md index 874fcb0d04b..ebc8c5598ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,24 @@ [1]: https://pypi.org/project/bigframes/#history +## [2.36.0](https://github.com/googleapis/python-bigquery-dataframes/compare/v2.35.0...v2.36.0) (2026-02-17) + + +### Documentation + +* update multimodal dataframe notebook to use public APIs (#2456) ([342fa723c4631d371364a87ae0ddd6fa03360a4b](https://github.com/googleapis/python-bigquery-dataframes/commit/342fa723c4631d371364a87ae0ddd6fa03360a4b)) +* use direct API for pdf chunk and pdf extract (#2452) ([543ce52c18269eab2a89886f226d1478dbabf9ba](https://github.com/googleapis/python-bigquery-dataframes/commit/543ce52c18269eab2a89886f226d1478dbabf9ba)) +* fix generate_text and generate_table input docs (#2455) ([078bd32ebd28af0d2cfba6bb874ba79e904183e2](https://github.com/googleapis/python-bigquery-dataframes/commit/078bd32ebd28af0d2cfba6bb874ba79e904183e2)) +* Update multimodal notebook to use public runtime helpers (#2451) ([e36dd8b492fd7ab433fa4cac732b31774c1e428b](https://github.com/googleapis/python-bigquery-dataframes/commit/e36dd8b492fd7ab433fa4cac732b31774c1e428b)) +* use direct API for audio transcription (#2447) ([59cbc5db66fd178ecce03bf4b8b4a504d7ef3e9f](https://github.com/googleapis/python-bigquery-dataframes/commit/59cbc5db66fd178ecce03bf4b8b4a504d7ef3e9f)) +* Add EXIF metadata extraction example to multimodal notebook (#2429) ([84c6f883aef8048e7013a8b3c03a1bde47e94eea](https://github.com/googleapis/python-bigquery-dataframes/commit/84c6f883aef8048e7013a8b3c03a1bde47e94eea)) + + +### Features + +* Initial support for biglake iceberg tables (#2409) ([ae35a9890a2f9903b12e431488362c091118bbdd](https://github.com/googleapis/python-bigquery-dataframes/commit/ae35a9890a2f9903b12e431488362c091118bbdd)) +* add bigquery.ai.generate_table function (#2453) ([b925aa243dad0e42ad126c9397f42be0aad7152d](https://github.com/googleapis/python-bigquery-dataframes/commit/b925aa243dad0e42ad126c9397f42be0aad7152d)) + ## [2.35.0](https://github.com/googleapis/python-bigquery-dataframes/compare/v2.34.0...v2.35.0) (2026-02-07) diff --git a/bigframes/version.py b/bigframes/version.py index c5b120dc239..eaddff2fcbb 100644 --- a/bigframes/version.py +++ b/bigframes/version.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "2.35.0" +__version__ = "2.36.0" # {x-release-please-start-date} -__release_date__ = "2026-02-07" +__release_date__ = "2026-02-17" # {x-release-please-end} diff --git a/third_party/bigframes_vendored/version.py b/third_party/bigframes_vendored/version.py index c5b120dc239..eaddff2fcbb 100644 --- a/third_party/bigframes_vendored/version.py +++ b/third_party/bigframes_vendored/version.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "2.35.0" +__version__ = "2.36.0" # {x-release-please-start-date} -__release_date__ = "2026-02-07" +__release_date__ = "2026-02-17" # {x-release-please-end}