Skip to content

Commit 2a57a60

Browse files
authored
Fix: Imports for seed column type inference to support older versions of dbt (#2332)
1 parent 6172d87 commit 2a57a60

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

setup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"beautifulsoup4",
6464
"black==24.1.1",
6565
"cryptography~=41.0.7",
66-
"dbt-common",
6766
"dbt-core",
6867
"dbt-duckdb>=1.7.1",
6968
"Faker",
@@ -114,7 +113,6 @@
114113
],
115114
"dbt": [
116115
"dbt-core<2",
117-
"dbt-common",
118116
],
119117
"gcppostgres": [
120118
"cloud-sql-python-connector[pg8000]",

sqlmesh/dbt/seed.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
import typing as t
44

55
import agate
6-
from dbt_common.clients import agate_helper
6+
7+
try:
8+
from dbt_common.clients import agate_helper # type: ignore
9+
10+
SUPPORTS_DELIMITER = True
11+
except ImportError:
12+
from dbt.clients import agate_helper # type: ignore
13+
14+
SUPPORTS_DELIMITER = False
715
from sqlglot import exp
816

917
from sqlmesh.core.model import Model, SeedKind, create_seed_model
@@ -29,7 +37,11 @@ def to_sqlmesh(self, context: DbtContext) -> Model:
2937
seed_path = self.path.absolute().as_posix()
3038
kwargs = self.sqlmesh_model_kwargs(context)
3139
if kwargs.get("columns") is None:
32-
agate_table = agate_helper.from_csv(seed_path, [], delimiter=self.delimiter)
40+
agate_table = (
41+
agate_helper.from_csv(seed_path, [], delimiter=self.delimiter)
42+
if SUPPORTS_DELIMITER
43+
else agate_helper.from_csv(seed_path, [])
44+
)
3345
kwargs["columns"] = {
3446
name: AGATE_TYPE_MAPPING[tpe.__class__]
3547
for name, tpe in zip(agate_table.column_names, agate_table.column_types)

0 commit comments

Comments
 (0)