You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jl...@apache.org on 2026/08/13 20:16:13 UTC
(superset) branch master updated: fix(sql): rebase Dremio dialect on sqlglot's native dialect (#43099)
This is an automated email from the ASF dual-hosted git repository.
sadpandajoe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new a63483b9b1a fix(sql): rebase Dremio dialect on sqlglot's native dialect (#43099)
a63483b9b1a is described below
commit a63483b9b1ade3cc009bac85c46d61b363f00c41
Author: Evan Rusackas <ev...@preset.io>
AuthorDate: Thu Aug 13 13:16:06 2026 -0700
fix(sql): rebase Dremio dialect on sqlglot's native dialect (#43099)
Co-authored-by: Superset Dev <de...@superset.apache.org>
Co-authored-by: Claude Sonnet 5 <no...@anthropic.com>
Co-authored-by: Joe Li <jo...@preset.io>
---
superset/sql/dialects/dremio.py | 28 ++++++++++++++++++++-------
tests/unit_tests/sql/dialects/dremio_tests.py | 27 ++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/superset/sql/dialects/dremio.py b/superset/sql/dialects/dremio.py
index 317882c695e..cd5c428dffe 100644
--- a/superset/sql/dialects/dremio.py
+++ b/superset/sql/dialects/dremio.py
@@ -15,14 +15,20 @@
# specific language governing permissions and limitations
# under the License.
-from sqlglot import exp, generator, parser
-from sqlglot.dialects.dialect import Dialect, rename_func
+from sqlglot import exp
+from sqlglot.dialects.dialect import rename_func
+from sqlglot.dialects.dremio import Dremio as SqlglotDremio
+from sqlglot.generators.dremio import DremioGenerator
+from sqlglot.parsers.dremio import DremioParser
class DremioRegexpSplit(exp.Expression, exp.Func):
"""
Custom REGEXP_SPLIT function for Dremio that supports 4 arguments.
+ sqlglot's native Dremio dialect does not parse this form; Superset adds
+ it on top until it lands upstream.
+
In sqlglot 30 the Expression class was split from the Func base class; custom
Func subclasses must now explicitly inherit from both exp.Expression and exp.Func
so that exp.Expression._set_parent is reachable via the MRO.
@@ -36,15 +42,23 @@ class DremioRegexpSplit(exp.Expression, exp.Func):
}
-class Dremio(Dialect):
- class Parser(parser.Parser):
+class Dremio(SqlglotDremio):
+ """
+ Superset's Dremio dialect, built on sqlglot's native Dremio dialect.
+
+ Adds the 4-argument REGEXP_SPLIT form on top of everything sqlglot
+ already gets right for Dremio (type mapping, DATE_ADD/DATE_SUB
+ semantics, TO_CHAR, CURRENT_DATE_UTC, timestamp-timezone rejection).
+ """
+
+ class Parser(DremioParser):
FUNCTIONS = {
- **parser.Parser.FUNCTIONS,
+ **DremioParser.FUNCTIONS,
"REGEXP_SPLIT": DremioRegexpSplit.from_arg_list,
}
- class Generator(generator.Generator):
+ class Generator(DremioGenerator):
TRANSFORMS = {
- **generator.Generator.TRANSFORMS,
+ **DremioGenerator.TRANSFORMS,
DremioRegexpSplit: rename_func("REGEXP_SPLIT"),
}
diff --git a/tests/unit_tests/sql/dialects/dremio_tests.py b/tests/unit_tests/sql/dialects/dremio_tests.py
index 7d7aa9b6702..0de042f3e71 100644
--- a/tests/unit_tests/sql/dialects/dremio_tests.py
+++ b/tests/unit_tests/sql/dialects/dremio_tests.py
@@ -30,3 +30,30 @@ def test_regexp_split() -> None:
regenerated = ast.sql(dialect=Dremio)
assert regenerated == "SELECT REGEXP_SPLIT(tags, ',', 'ALL', 1000) AS t"
+
+
+def test_inherits_sqlglot_native_type_mapping() -> None:
+ """
+ Superset's Dremio dialect is built on sqlglot's native Dremio dialect,
+ not a bare Dialect base, so it should get correct type mapping for free
+ (e.g. TINYINT, which Dremio doesn't support, maps to INT).
+ """
+ sql = "SELECT CAST(x AS TINYINT)"
+
+ ast = parse_one(sql, dialect=Dremio)
+ regenerated = ast.sql(dialect=Dremio)
+
+ assert regenerated == "SELECT CAST(x AS INT)"
+
+
+def test_inherits_sqlglot_native_current_date_utc() -> None:
+ """
+ sqlglot's native Dremio dialect round-trips CURRENT_DATE_UTC(); a bare
+ Dialect base does not understand this Dremio-specific construct.
+ """
+ sql = "SELECT CURRENT_DATE_UTC()"
+
+ ast = parse_one(sql, dialect=Dremio)
+ regenerated = ast.sql(dialect=Dremio)
+
+ assert regenerated == "SELECT CURRENT_DATE_UTC"