From 348500c4bf6105d741d83ae7ecd26142e854edc3 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Thu, 24 Oct 2024 08:51:48 -0400 Subject: [PATCH] fix(trino): remove invalid ranking function window frames (#10363) --- ibis/backends/sql/compilers/trino.py | 4 ++++ .../snapshots/test_sql/test_rewrite_context/trino/out.sql | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ibis/backends/sql/compilers/trino.py b/ibis/backends/sql/compilers/trino.py index 0e8873e77bfd..e47945d8288a 100644 --- a/ibis/backends/sql/compilers/trino.py +++ b/ibis/backends/sql/compilers/trino.py @@ -23,6 +23,8 @@ from ibis.backends.sql.dialects import Trino from ibis.backends.sql.rewrites import ( exclude_unsupported_window_frame_from_ops, + exclude_unsupported_window_frame_from_rank, + exclude_unsupported_window_frame_from_row_number, lower_sample, split_select_distinct_with_order_by, ) @@ -38,6 +40,8 @@ class TrinoCompiler(SQLGlotCompiler): agg = AggGen(supports_filter=True, supports_order_by=True) rewrites = ( + exclude_unsupported_window_frame_from_row_number, + exclude_unsupported_window_frame_from_rank, exclude_unsupported_window_frame_from_ops, *SQLGlotCompiler.rewrites, ) diff --git a/ibis/backends/tests/snapshots/test_sql/test_rewrite_context/trino/out.sql b/ibis/backends/tests/snapshots/test_sql/test_rewrite_context/trino/out.sql index ebcf7e2f4c08..4c6d3e2cf113 100644 --- a/ibis/backends/tests/snapshots/test_sql/test_rewrite_context/trino/out.sql +++ b/ibis/backends/tests/snapshots/test_sql/test_rewrite_context/trino/out.sql @@ -1,4 +1,4 @@ SELECT - NTILE(2) OVER (ORDER BY RAND() ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) - 1 AS "new_col" + NTILE(2) OVER (ORDER BY RAND() ASC) - 1 AS "new_col" FROM "test" AS "t0" LIMIT 10 \ No newline at end of file