Skip to content

Commit f9ad5da

Browse files
feat: [SNOW-1890085] add spinner to dbt execute
1 parent ac819d3 commit f9ad5da

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from typing import Optional
1919

2020
import typer
21+
from rich.progress import Progress, SpinnerColumn, TextColumn
2122
from snowflake.cli._plugins.dbt.constants import DBT_COMMANDS
2223
from snowflake.cli._plugins.dbt.manager import DBTManager
2324
from snowflake.cli._plugins.object.command_aliases import add_object_command_aliases
@@ -137,9 +138,18 @@ def _dbt_execute(
137138
dbt_command = ctx.command.name
138139
name = ctx.parent.params["name"]
139140
run_async = ctx.parent.params["run_async"]
140-
result = DBTManager().execute(dbt_command, name, run_async, *dbt_cli_args)
141-
if not run_async:
142-
return QueryResult(result)
143-
return MessageResult(
144-
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}');\"`"
145-
)
141+
execute_args = (dbt_command, name, run_async, *dbt_cli_args)
142+
143+
if run_async is True:
144+
result = DBTManager().execute(*execute_args)
145+
return MessageResult(
146+
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}');\"`"
147+
)
148+
149+
with Progress(
150+
SpinnerColumn(),
151+
TextColumn("[progress.description]{task.description}"),
152+
transient=True,
153+
) as progress:
154+
progress.add_task(description="Executing dbt command...", total=None)
155+
return QueryResult(DBTManager().execute(*execute_args))

0 commit comments

Comments
 (0)