File tree Expand file tree Collapse file tree
sqlmesh/core/engine_adapter Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import importlib .util
34import sys
45import typing as t
56
2324from sqlmesh .core .engine_adapter .risingwave import RisingwaveEngineAdapter
2425from sqlmesh .core .engine_adapter .fabric import FabricEngineAdapter
2526
26- # DB2 adapter requires Python 3.10+ for db2-sqlglot-dialect
27- if sys .version_info >= (3 , 10 ):
27+ # DB2 adapter requires Python 3.10+ AND db2-sqlglot-dialect to be installed.
28+ # The dialect package registers "db2" with sqlglot at import time; without it,
29+ # class-level exp.DataType.build(dialect="db2") in db2.py raises
30+ # ValueError("Unknown dialect 'db2'") and crashes every non-db2 environment
31+ # (e.g. the dbt-1.6 test run which installs without the db2 extra).
32+ _DB2_AVAILABLE = (
33+ sys .version_info >= (3 , 10 )
34+ and importlib .util .find_spec ("db2_sqlglot" ) is not None
35+ )
36+ if _DB2_AVAILABLE :
2837 from sqlmesh .core .engine_adapter .db2 import Db2EngineAdapter
2938
3039DIALECT_TO_ENGINE_ADAPTER = {
4655 "starrocks" : StarRocksEngineAdapter ,
4756}
4857
49- # Add DB2 only on Python 3.10+
50- if sys . version_info >= ( 3 , 10 ) :
58+ # Add DB2 to the registry only when the dialect package is present
59+ if _DB2_AVAILABLE :
5160 DIALECT_TO_ENGINE_ADAPTER ["db2" ] = Db2EngineAdapter
5261
5362DIALECT_ALIASES = {
You can’t perform that action at this time.
0 commit comments