Skip to content

Commit d76d4e0

Browse files
feat: [SNOW-1890085] remove options for dbt_version and dbt_adapter_version
1 parent 4a83985 commit d76d4e0

File tree

3 files changed

+4
-77
lines changed

3 files changed

+4
-77
lines changed

src/snowflake/cli/_plugins/dbt/commands.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ def deploy_dbt(
7070
False,
7171
help="Overwrites conflicting files in the project, if any.",
7272
),
73-
dbt_version: Optional[str] = typer.Option(
74-
None,
75-
help="Version of dbt tool to be used. Taken from dbt_project.yml if not provided.",
76-
),
77-
dbt_adapter_version: Optional[str] = typer.Option(
78-
None,
79-
help="dbt-snowflake adapter version to be used",
80-
),
8173
**options,
8274
) -> CommandResult:
8375
"""
@@ -91,8 +83,6 @@ def deploy_dbt(
9183
DBTManager().deploy(
9284
path.resolve(),
9385
name,
94-
dbt_version,
95-
dbt_adapter_version,
9686
force=force,
9787
)
9888
)

src/snowflake/cli/_plugins/dbt/manager.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@
1414

1515
from __future__ import annotations
1616

17-
from typing import Optional
18-
19-
import yaml
2017
from click import ClickException
2118
from snowflake.cli._plugins.object.manager import ObjectManager
2219
from snowflake.cli._plugins.stage.manager import StageManager
2320
from snowflake.cli.api.console import cli_console
24-
from snowflake.cli.api.constants import DEFAULT_SIZE_LIMIT_MB, ObjectType
21+
from snowflake.cli.api.constants import ObjectType
2522
from snowflake.cli.api.identifiers import FQN
2623
from snowflake.cli.api.secure_path import SecurePath
2724
from snowflake.cli.api.sql_execution import SqlExecutionMixin
@@ -43,24 +40,12 @@ def deploy(
4340
self,
4441
path: SecurePath,
4542
name: FQN,
46-
dbt_version: Optional[str],
47-
dbt_adapter_version: str,
4843
force: bool,
4944
) -> SnowflakeCursor:
5045
dbt_project_path = path / "dbt_project.yml"
5146
if not dbt_project_path.exists():
5247
raise ClickException(f"dbt_project.yml does not exist in provided path.")
5348

54-
if dbt_version is None:
55-
with dbt_project_path.open(read_file_limit_mb=DEFAULT_SIZE_LIMIT_MB) as fd:
56-
dbt_project_config = yaml.safe_load(fd)
57-
try:
58-
dbt_version = dbt_project_config["version"]
59-
except (KeyError, TypeError):
60-
raise ClickException(
61-
f"dbt-version was not provided and is not available in dbt_project.yml"
62-
)
63-
6449
if self.exists(name=name) and force is not True:
6550
raise ClickException(
6651
f"DBT project {name} already exists. Use --force flag to overwrite"
@@ -78,11 +63,8 @@ def deploy(
7863

7964
with cli_console.phase("Creating DBT project"):
8065
query = f"""{'CREATE OR REPLACE' if force is True else 'CREATE'} DBT PROJECT {name}
81-
FROM {stage_name}
82-
DBT_VERSION='{dbt_version}'"""
66+
FROM {stage_name}"""
8367

84-
if dbt_adapter_version:
85-
query += f"\nDBT_ADAPTER_VERSION='{dbt_adapter_version}'"
8668
return self.execute_query(query)
8769

8870
def execute(self, dbt_command: str, name: str, run_async: bool, *dbt_cli_args):

tests/dbt/test_dbt_commands.py

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,9 @@
1717
from unittest import mock
1818

1919
import pytest
20-
import yaml
2120
from snowflake.cli.api.identifiers import FQN
2221

2322

24-
@pytest.fixture
25-
def mock_connect(mock_ctx):
26-
with mock.patch("snowflake.connector.connect") as _fixture:
27-
ctx = mock_ctx()
28-
_fixture.return_value = ctx
29-
_fixture.mocked_ctx = _fixture.return_value
30-
yield _fixture
31-
32-
3323
class TestDBTList:
3424
def test_list_command_alias(self, mock_connect, runner):
3525
result = runner.invoke(
@@ -67,8 +57,6 @@ def dbt_project_path(self, tmp_path_factory):
6757
source_path = tmp_path_factory.mktemp("dbt_project")
6858
dbt_file = source_path / "dbt_project.yml"
6959
dbt_file.touch()
70-
with dbt_file.open(mode="w") as fd:
71-
yaml.dump({"version": "1.2.3"}, fd)
7260
yield source_path
7361

7462
@pytest.fixture
@@ -101,17 +89,14 @@ def test_deploys_project_from_source(
10189
"deploy",
10290
"TEST_PIPELINE",
10391
f"--source={dbt_project_path}",
104-
"--dbt-adapter-version=3.4.5",
10592
]
10693
)
10794

10895
assert result.exit_code == 0, result.output
10996
assert (
11097
mock_connect.mocked_ctx.get_query()
11198
== """CREATE DBT PROJECT TEST_PIPELINE
112-
FROM @MockDatabase.MockSchema.dbt_TEST_PIPELINE_stage
113-
DBT_VERSION='1.2.3'
114-
DBT_ADAPTER_VERSION='3.4.5'"""
99+
FROM @MockDatabase.MockSchema.dbt_TEST_PIPELINE_stage"""
115100
)
116101
stage_fqn = FQN.from_string(f"dbt_TEST_PIPELINE_stage").using_context()
117102
mock_create.assert_called_once_with(stage_fqn, temporary=True)
@@ -136,18 +121,14 @@ def test_dbt_version_from_option_has_precedence_over_file(
136121
"deploy",
137122
"TEST_PIPELINE",
138123
f"--source={dbt_project_path}",
139-
"--dbt-version=2.3.4",
140-
"--dbt-adapter-version=3.4.5",
141124
]
142125
)
143126

144127
assert result.exit_code == 0, result.output
145128
assert (
146129
mock_connect.mocked_ctx.get_query()
147130
== """CREATE DBT PROJECT TEST_PIPELINE
148-
FROM @MockDatabase.MockSchema.dbt_TEST_PIPELINE_stage
149-
DBT_VERSION='2.3.4'
150-
DBT_ADAPTER_VERSION='3.4.5'"""
131+
FROM @MockDatabase.MockSchema.dbt_TEST_PIPELINE_stage"""
151132
)
152133

153134
@pytest.mark.parametrize("exists", (True, False))
@@ -172,7 +153,6 @@ def test_force_flag_uses_create_or_replace(
172153
"TEST_PIPELINE",
173154
f"--source={dbt_project_path}",
174155
"--force",
175-
"--dbt-adapter-version=3.4.5",
176156
]
177157
)
178158

@@ -193,38 +173,13 @@ def test_raises_when_dbt_project_is_not_available(
193173
"deploy",
194174
"TEST_PIPELINE",
195175
f"--source={dbt_project_path}",
196-
"--dbt-adapter-version=3.4.5",
197176
],
198177
)
199178

200179
assert result.exit_code == 1, result.output
201180
assert "dbt_project.yml does not exist in provided path." in result.output
202181
assert mock_connect.mocked_ctx.get_query() == ""
203182

204-
def test_raises_when_dbt_project_version_is_not_specified(
205-
self, dbt_project_path, mock_connect, runner
206-
):
207-
dbt_file = dbt_project_path / "dbt_project.yml"
208-
with dbt_file.open(mode="w") as fd:
209-
yaml.dump({}, fd)
210-
211-
result = runner.invoke(
212-
[
213-
"dbt",
214-
"deploy",
215-
"TEST_PIPELINE",
216-
f"--source={dbt_project_path}",
217-
"--dbt-adapter-version=3.4.5",
218-
]
219-
)
220-
221-
assert result.exit_code == 1, result.output
222-
assert (
223-
"dbt-version was not provided and is not available in dbt_project.yml"
224-
in result.output
225-
)
226-
assert mock_connect.mocked_ctx.get_query() == ""
227-
228183
def test_raises_when_dbt_project_exists_and_is_not_force(
229184
self, dbt_project_path, mock_connect, runner, mock_exists
230185
):

0 commit comments

Comments
 (0)