You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2025/10/01 21:10:36 UTC
(superset) branch pinot-substr created (now 3482fcb53c)
This is an automated email from the ASF dual-hosted git repository.
beto pushed a change to branch pinot-substr
in repository https://gitbox.apache.org/repos/asf/superset.git
at 3482fcb53c fix(pinot): `SUBSTR` function
This branch includes the following new commits:
new 3482fcb53c fix(pinot): `SUBSTR` function
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: fix(pinot): `SUBSTR` function
Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch pinot-substr
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 3482fcb53cb02dbbcf8c17e883c0131dbbb2344e
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Wed Oct 1 17:10:15 2025 -0400
fix(pinot): `SUBSTR` function
---
superset/sql/dialects/pinot.py | 6 ++++++
tests/unit_tests/sql/dialects/pinot_tests.py | 22 ++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/superset/sql/dialects/pinot.py b/superset/sql/dialects/pinot.py
index ff7427288e..a379006fba 100644
--- a/superset/sql/dialects/pinot.py
+++ b/superset/sql/dialects/pinot.py
@@ -108,6 +108,12 @@ class Pinot(MySQL):
e.args.get("expression"),
e.this,
),
+ exp.Substring: lambda self, e: self.func(
+ "SUBSTR",
+ e.this,
+ e.args.get("start"),
+ e.args.get("length"),
+ ),
}
# Remove DATE_TRUNC transformation - Pinot supports standard SQL DATE_TRUNC
TRANSFORMS.pop(exp.DateTrunc, None)
diff --git a/tests/unit_tests/sql/dialects/pinot_tests.py b/tests/unit_tests/sql/dialects/pinot_tests.py
index db05b281f8..22ee406ae6 100644
--- a/tests/unit_tests/sql/dialects/pinot_tests.py
+++ b/tests/unit_tests/sql/dialects/pinot_tests.py
@@ -562,3 +562,25 @@ def test_pinot_date_sub_simple() -> None:
# Verify that it generates valid SQL
generated = parsed.sql(dialect=Pinot)
assert "DATE_SUB" in generated.upper()
+
+
+def test_substr_cross_dialect_generation() -> None:
+ """
+ Test that SUBSTR is preserved when generating Pinot SQL.
+
+ Note that the MySQL dialect (in which Pinot is based) uses SUBSTRING instead of
+ SUBSTR.
+ """
+ # Parse with Pinot dialect
+ pinot_sql = "SELECT SUBSTR('hello', 0, 3) FROM users"
+ parsed = sqlglot.parse_one(pinot_sql, Pinot)
+
+ # Generate back to Pinot → should preserve SUBSTR
+ pinot_output = parsed.sql(dialect=Pinot)
+ assert "SUBSTR(" in pinot_output
+ assert "SUBSTRING(" not in pinot_output
+
+ # Generate to MySQL → should convert to SUBSTRING
+ mysql_output = parsed.sql(dialect="mysql")
+ assert "SUBSTRING(" in mysql_output
+ assert pinot_output != mysql_output # They should be different