Skip to content

Commit c30c548

Browse files
authored
Merge pull request #447 from duckdb/jwills_184_updates
Updates for dbt-duckdb 1.8.4
2 parents 47d447c + 020e0ee commit c30c548

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

.github/workflows/main.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
strategy:
7474
fail-fast: false
7575
matrix:
76-
python-version: ['3.8', '3.9', '3.10', '3.11']
76+
python-version: ['3.9', '3.10', '3.11', '3.12']
7777

7878
env:
7979
TOXENV: "unit"
@@ -118,7 +118,7 @@ jobs:
118118
strategy:
119119
fail-fast: false
120120
matrix:
121-
python-version: ['3.8', '3.9', '3.10', '3.11']
121+
python-version: ['3.9', '3.10', '3.11', '3.12']
122122

123123
env:
124124
TOXENV: "functional"
@@ -163,7 +163,7 @@ jobs:
163163
strategy:
164164
fail-fast: false
165165
matrix:
166-
python-version: ['3.8', '3.9', '3.10', '3.11']
166+
python-version: ['3.9', '3.10', '3.11', '3.12']
167167

168168
env:
169169
TOXENV: "filebased"
@@ -445,7 +445,7 @@ jobs:
445445
fail-fast: false
446446
matrix:
447447
os: [ubuntu-latest, macos-latest, windows-latest]
448-
python-version: ['3.8', '3.9', '3.10', '3.11']
448+
python-version: ['3.9', '3.10', '3.11', '3.12']
449449

450450
steps:
451451
- name: Set up Python ${{ matrix.python-version }}

dbt/adapters/duckdb/impl.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,17 @@ def render_column_constraint(cls, constraint: ColumnLevelConstraint) -> Optional
237237
"""Render the given constraint as DDL text. Should be overriden by adapters which need custom constraint
238238
rendering."""
239239
if constraint.type == ConstraintType.foreign_key:
240-
# DuckDB doesn't support 'foreign key' as an alias
241-
return f"references {constraint.expression}"
240+
if constraint.to and constraint.to_columns:
241+
# TODO: this is a hack to get around a limitation in DuckDB around setting FKs
242+
# across databases.
243+
pieces = constraint.to.split(".")
244+
if len(pieces) > 2:
245+
constraint_to = ".".join(pieces[1:])
246+
else:
247+
constraint_to = constraint.to
248+
return f"references {constraint_to} ({', '.join(constraint.to_columns)})"
249+
else:
250+
return f"references {constraint.expression}"
242251
else:
243252
return super().render_column_constraint(constraint)
244253

0 commit comments

Comments
 (0)