Skip to content

Commit 5c3369b

Browse files
refactor: [SNOW-1890085] post code review fixes
1 parent d9075b0 commit 5c3369b

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ def _dbt_execute(
130130
run_async = ctx.parent.params["run_async"]
131131
execute_args = (dbt_command, name, run_async, *dbt_cli_args)
132132

133+
result = DBTManager().execute(*execute_args)
134+
133135
if run_async is True:
134-
result = DBTManager().execute(*execute_args)
135136
return MessageResult(
136137
f"Command submitted. You can check the result with `snow sql -q \"select execution_status from table(information_schema.query_history_by_user()) where query_id in ('{result.sfqid}');\"`"
137138
)
@@ -142,4 +143,4 @@ def _dbt_execute(
142143
transient=True,
143144
) as progress:
144145
progress.add_task(description="Executing dbt command...", total=None)
145-
return QueryResult(DBTManager().execute(*execute_args))
146+
return QueryResult(result)

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def deploy(
4444
) -> SnowflakeCursor:
4545
dbt_project_path = path / "dbt_project.yml"
4646
if not dbt_project_path.exists():
47-
raise ClickException(f"dbt_project.yml does not exist in provided path.")
47+
raise ClickException(
48+
f"dbt_project.yml does not exist in directory {path.path.absolute()}."
49+
)
4850

4951
if self.exists(name=name) and force is not True:
5052
raise ClickException(
@@ -69,6 +71,6 @@ def deploy(
6971

7072
def execute(self, dbt_command: str, name: str, run_async: bool, *dbt_cli_args):
7173
if dbt_cli_args:
72-
dbt_command = dbt_command + " " + " ".join([arg for arg in dbt_cli_args])
73-
query = f"EXECUTE DBT PROJECT {name} args='{dbt_command.strip()}'"
74+
dbt_command = " ".join([dbt_command, *dbt_cli_args]).strip()
75+
query = f"EXECUTE DBT PROJECT {name} args='{dbt_command}'"
7476
return self.execute_query(query, _exec_async=run_async)

tests/dbt/test_dbt_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def test_raises_when_dbt_project_is_not_available(
177177
)
178178

179179
assert result.exit_code == 1, result.output
180-
assert "dbt_project.yml does not exist in provided path." in result.output
180+
assert f"dbt_project.yml does not exist in directory" in result.output
181181
assert mock_connect.mocked_ctx.get_query() == ""
182182

183183
def test_raises_when_dbt_project_exists_and_is_not_force(

0 commit comments

Comments
 (0)