Skip to content

Commit b9c9a57

Browse files
authored
feat: lazy import duckdb (#4655)
1 parent 9584fda commit b9c9a57

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies = [
1010
"astor",
1111
"click",
1212
"croniter",
13-
"duckdb!=0.10.3",
13+
"duckdb>=0.10.0,!=0.10.3",
1414
"dateparser",
1515
"hyperscript>=0.1.0",
1616
"importlib-metadata; python_version<'3.12'",
@@ -275,6 +275,7 @@ extend-select = ["TID"]
275275

276276
[tool.ruff.lint.flake8-tidy-imports]
277277
banned-module-level-imports = [
278-
"pandas",
278+
"duckdb",
279279
"numpy",
280+
"pandas",
280281
]

sqlmesh/core/engine_adapter/duckdb.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import typing as t
4-
from duckdb import __version__ as duckdb_version
54
from sqlglot import exp
65

76
from sqlmesh.core.engine_adapter.mixins import (
@@ -18,7 +17,6 @@
1817
SourceQuery,
1918
set_catalog,
2019
)
21-
from sqlmesh.utils import major_minor
2220
from sqlmesh.core.schema_diff import SchemaDiffer
2321

2422
if t.TYPE_CHECKING:
@@ -35,13 +33,8 @@ class DuckDBEngineAdapter(LogicalMergeMixin, GetCurrentCatalogFromFunctionMixin,
3533
exp.DataType.build("DECIMAL", dialect=DIALECT).this: [(18, 3), (0,)],
3634
},
3735
)
38-
39-
# TODO: remove once we stop supporting DuckDB 0.9
40-
COMMENT_CREATION_TABLE, COMMENT_CREATION_VIEW = (
41-
(CommentCreationTable.UNSUPPORTED, CommentCreationView.UNSUPPORTED)
42-
if major_minor(duckdb_version) < (0, 10)
43-
else (CommentCreationTable.COMMENT_COMMAND_ONLY, CommentCreationView.COMMENT_COMMAND_ONLY)
44-
)
36+
COMMENT_CREATION_TABLE = CommentCreationTable.COMMENT_COMMAND_ONLY
37+
COMMENT_CREATION_VIEW = CommentCreationView.COMMENT_COMMAND_ONLY
4538

4639
@property
4740
def catalog_support(self) -> CatalogSupport:

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import os
1515
import shutil
1616

17-
import duckdb
17+
import duckdb # noqa: TID253
1818
import pandas as pd # noqa: TID253
1919
import pytest
2020
from pytest_mock.plugin import MockerFixture

tests/core/state_sync/test_state_sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import typing as t
55
from unittest.mock import call, patch
66

7-
import duckdb
7+
import duckdb # noqa: TID253
88
import pandas as pd # noqa: TID253
99
import pytest
1010
import time_machine

0 commit comments

Comments
 (0)