From c5fc31a67f89ac60ce0293af8ec7d25c744b8fe3 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 20 May 2026 17:45:55 -0700 Subject: [PATCH] fix(db2): explicitly register DB2Interval in TRANSFORMS for sqlglot 30 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sqlglot 30 changed how the generator dispatch is built. In 28 the auto-discovery walked all expression subclasses; in 30 it only considers classes registered in sqlglot.expressions.EXPR_CLASSES, which is populated once at module load via subclasses(__name__, Expr) — i.e. ONLY built-in expression types. Custom user-defined Expression subclasses defined outside that module — like our DB2Interval — no longer get auto-wired to their _sql handler. Adding DB2Interval to TRANSFORMS as a lambda → db2interval_sql restores the dispatch. All 24 dialects/db2_tests.py tests pass. --- superset/sql/dialects/db2.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/superset/sql/dialects/db2.py b/superset/sql/dialects/db2.py index 4f70543be33..df5bbd04a35 100644 --- a/superset/sql/dialects/db2.py +++ b/superset/sql/dialects/db2.py @@ -136,6 +136,12 @@ class DB2(Postgres): TRANSFORMS = { **Postgres.Generator.TRANSFORMS, + # sqlglot 30 only auto-discovers _sql handlers for expression + # classes that live in sqlglot.expressions.EXPR_CLASSES (the + # registry is built once at module load via ``subclasses(__name__, Expr)``). + # Custom Expression subclasses defined outside that module — like + # DB2Interval below — must be wired up explicitly in TRANSFORMS. + DB2Interval: lambda self, e: self.db2interval_sql(e), } def db2interval_sql(self, expression: DB2Interval) -> str: