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

rusackas pushed a commit to branch tdd/issue-32028-timescaledb-hyperfunctions
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 8d3c5496f0412459d19368f55836ad32d503a006
Author: Claude Code <[email protected]>
AuthorDate: Thu May 14 18:50:36 2026 -0700

    test(sql-parser): pin TimescaleDB hyperfunctions parse on postgresql
    
    Closes #32028
    
    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
---
 tests/unit_tests/sql/parse_tests.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/tests/unit_tests/sql/parse_tests.py 
b/tests/unit_tests/sql/parse_tests.py
index 78b00f4487d..2a0c9ab8ed6 100644
--- a/tests/unit_tests/sql/parse_tests.py
+++ b/tests/unit_tests/sql/parse_tests.py
@@ -1164,6 +1164,32 @@ def test_has_mutation(engine: str, sql: str, expected: 
bool) -> None:
     assert SQLScript(sql, engine).has_mutation() == expected
 
 
[email protected](
+    "sql",
+    [
+        "SELECT last(my_value_column, my_time_column) FROM my_table",
+        "SELECT first(my_value_column, my_time_column) FROM my_table",
+        "SELECT time_bucket('1 hour', my_time_column) AS bucket FROM my_table",
+    ],
+)
+def test_postgres_parses_timescaledb_hyperfunctions(sql: str) -> None:
+    """
+    Regression for #32028: TimescaleDB extends Postgres with hyperfunctions
+    (``last``, ``first``, ``time_bucket``, etc.) that take more arguments
+    than vanilla Postgres equivalents. SQL Lab tolerates them (it routes
+    raw SQL straight to the engine), but the dashboard chart path runs the
+    SQL through ``SQLScript`` for inspection. A strict per-function arity
+    check in sqlglot was rejecting these queries with ``The number of
+    provided arguments (2) is greater than the maximum number of supported
+    arguments (1)``, which broke dashboards built on TimescaleDB datasets.
+
+    These tests pin that the parse path tolerates Postgres-dialect SQL
+    using TimescaleDB hyperfunction signatures. If a future sqlglot
+    upgrade reintroduces the strict arity check, this fails immediately.
+    """
+    SQLScript(sql, "postgresql")  # Must not raise.
+
+
 def test_get_settings() -> None:
     """
     Test `get_settings` in some edge cases.

Reply via email to