Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downgrade dbt-core dependency to concrete required version (i.e. first one with behavior flags) #842

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion dbt/adapters/databricks/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@
from dbt_common.exceptions import DbtInternalError
from dbt_common.contracts.config.base import BaseConfig

from importlib import metadata
from packaging import version

if TYPE_CHECKING:
from agate import Row
from agate import Table

dbt_version = metadata.version("dbt-core")
SUPPORT_MICROBATCH = version.parse(dbt_version) >= version.parse("1.9.0b1")

CURRENT_CATALOG_MACRO_NAME = "current_catalog"
USE_CATALOG_MACRO_NAME = "use_catalog"
GET_CATALOG_MACRO_NAME = "get_catalog"
Expand Down Expand Up @@ -659,8 +665,13 @@ def run_sql_for_tests(
cursor.close()
conn.transaction_open = False

@available
def valid_incremental_strategies(self) -> list[str]:
return ["append", "merge", "insert_overwrite", "replace_where", "microbatch"]
valid_strategies = ["append", "merge", "insert_overwrite", "replace_where"]
if SUPPORT_MICROBATCH:
valid_strategies.append("microbatch")

return valid_strategies

@property
def python_submission_helpers(self) -> dict[str, type[PythonJobHelper]]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
Use the 'merge' or 'replace_where' strategy instead
{%- endset %}

{% if raw_strategy not in ['append', 'merge', 'insert_overwrite', 'replace_where', 'microbatch'] %}
{% if raw_strategy not in adapter.valid_incremental_strategies() %}
{% do exceptions.raise_compiler_error(invalid_strategy_msg) %}
{%-else %}
{% if raw_strategy == 'merge' and file_format not in ['delta', 'hudi'] %}
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
databricks-sql-connector>=3.5.0, <4.0
dbt-spark>=1.9.0b1, <2.0
dbt-core>=1.9.0b1, <2.0
dbt-spark>=1.8.0, <2.0
dbt-core>=1.8.7, <2.0
dbt-common>=1.10.0, <2.0
dbt-adapters>=1.7.0, <2.0
databricks-sdk==0.17.0
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import sys

# require python 3.8 or newer
# require python 3.9 or newer
if sys.version_info < (3, 9):
print("Error: dbt does not support this version of Python.")
print("Please upgrade to Python 3.9 or higher.")
Expand Down Expand Up @@ -54,8 +54,8 @@ def _get_plugin_version() -> str:
packages=find_namespace_packages(include=["dbt", "dbt.*"]),
include_package_data=True,
install_requires=[
"dbt-spark>=1.9.0b1, <2.0",
"dbt-core>=1.9.0b1, <2.0",
"dbt-spark>=1.8.0, <2.0",
"dbt-core>=1.8.7, <2.0",
"dbt-adapters>=1.7.0, <2.0",
"dbt-common>=1.10.0, <2.0",
"databricks-sql-connector>=3.5.0, <4.0.0",
Expand Down
8 changes: 8 additions & 0 deletions tests/functional/adapter/microbatch/test_microbatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
BaseMicrobatch,
)
import pytest
from packaging import version
from importlib import metadata

from tests.functional.adapter.microbatch import fixtures

dbt_version = metadata.version("dbt-core")


@pytest.mark.skipif(
version.parse(dbt_version) < version.parse("1.9.0b1"),
reason="Microbatch is not supported with this version of core",
)
class TestDatabricksMicrobatch(BaseMicrobatch):
@pytest.fixture(scope="class")
def models(self, microbatch_model_sql, input_model_sql):
Expand Down
Loading