Skip to content

Commit

Permalink
Merge pull request #447 from duckdb/jwills_184_updates
Browse files Browse the repository at this point in the history
Updates for dbt-duckdb 1.8.4
  • Loading branch information
jwills authored Sep 26, 2024
2 parents 47d447c + 020e0ee commit c30c548
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']

env:
TOXENV: "unit"
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']

env:
TOXENV: "functional"
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']

env:
TOXENV: "filebased"
Expand Down Expand Up @@ -445,7 +445,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- name: Set up Python ${{ matrix.python-version }}
Expand Down
13 changes: 11 additions & 2 deletions dbt/adapters/duckdb/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,17 @@ def render_column_constraint(cls, constraint: ColumnLevelConstraint) -> Optional
"""Render the given constraint as DDL text. Should be overriden by adapters which need custom constraint
rendering."""
if constraint.type == ConstraintType.foreign_key:
# DuckDB doesn't support 'foreign key' as an alias
return f"references {constraint.expression}"
if constraint.to and constraint.to_columns:
# TODO: this is a hack to get around a limitation in DuckDB around setting FKs
# across databases.
pieces = constraint.to.split(".")
if len(pieces) > 2:
constraint_to = ".".join(pieces[1:])
else:
constraint_to = constraint.to
return f"references {constraint_to} ({', '.join(constraint.to_columns)})"
else:
return f"references {constraint.expression}"
else:
return super().render_column_constraint(constraint)

Expand Down

0 comments on commit c30c548

Please sign in to comment.