Skip to content

Commit dd39f6f

Browse files
Merge branch 'main' into jw/SNOW-1890085-snow-dbt-commands
2 parents 978dc27 + 998a747 commit dd39f6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1791
-808
lines changed

RELEASE-NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
## Deprecations
2020

2121
## New additions
22+
* Added `--prune` flag to `deploy` commands, which removes files that exist in the stage,
23+
but not in the local filesystem.
24+
* Added `snow logs` command for retrieving and streaming logs from the server.
2225

2326
## Fixes and improvements
2427

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dependencies = [
3838
"setuptools==78.0.1",
3939
"snowflake-connector-python[secure-local-storage]==3.14.0",
4040
'snowflake-snowpark-python>=1.15.0,<1.26.0;python_version < "3.12"',
41-
'snowflake.core==1.0.2; python_version < "3.12"',
41+
'snowflake.core==1.1.0; python_version < "3.12"',
4242
"tomlkit==0.13.2",
4343
"typer==0.15.2",
4444
"urllib3>=1.24.3,<2.4",

scripts/cleanup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ def remove_resources(single: str, plural: str, known_instances: t.List[str], rol
4545
items = session.sql(f"show {plural}").collect()
4646

4747
for item in items:
48-
if item.name not in known_instances:
48+
# services don't have an owner
49+
if item.name not in known_instances and (
50+
plural == "services" or item.owner == "INTEGRATION_TESTS"
51+
):
4952
remove_resource(resource_type=single, item=item, role=role)
5053

5154

@@ -80,6 +83,15 @@ def remove_resources(single: str, plural: str, known_instances: t.List[str], rol
8083
("application", "applications"): [],
8184
("warehouse", "warehouses"): ["XSMALL"],
8285
("image repository", "image repositories"): ["SNOWCLI_REPOSITORY"],
86+
("role", "roles"): [
87+
"ACCOUNTADMIN",
88+
"PUBLIC",
89+
"SECURITYADMIN",
90+
"SYSADMIN",
91+
"USERADMIN",
92+
"INTEGRATION_TESTS",
93+
"APP_PUBLIC",
94+
],
8395
}
8496

8597
for (single, plural), known in known_objects.items():

scripts/packaging/build_darwin_package.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ install_cargo() {
3636
sudo bash rustup-init.sh -y
3737
. $HOME/.cargo/env
3838
elif [[ ${MACHINE} == "x86_64" ]]; then
39-
bash -s rustup-init.sh -y --no-modify-path
39+
export CARGO_HOME="$HOME/.cargo"
40+
export RUSTUP_HOME="$HOME/.rustup"
41+
bash -s rustup-init.sh -y
4042
. $HOME/.cargo/env
4143
rustup default stable
4244
else

scripts/packaging/win/snowflake_cli_exitdlg.wxs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<Control Id="Description2" Type="Text" X="135" Y="70" Width="220" Height="20" Transparent="yes" NoPrefix="yes" Text="2. Execute the command to test your connection:"/>
1717
<Control Id="Description3" Type="Text" X="135" Y="90" Width="220" Height="20" Transparent="yes" NoPrefix="yes" Text="{\DlgMonoFont}snow connection add"/>
1818
<Control Id="Description4" Type="Text" X="135" Y="110" Width="220" Height="20" Transparent="yes" NoPrefix="yes" Text="When prompted, supply the required connection, account, username parameters, and any desired optional parameters"/>
19-
<Control Id="Description5" Type="Text" X="135" Y="190" Width="220" Height="20" Transparent="yes" NoPrefix="yes" Text="3. Execute the command to connect to Snowflake:"/>
20-
<Control Id="Description6" Type="Text" X="135" Y="210" Width="220" Height="20" Transparent="yes" NoPrefix="yes" Text="{\DlgMonoFont}snow connection test"/>
21-
<Control Id="Description7" Type="Text" X="135" Y="190" Width="220" Height="20" Transparent="yes" NoPrefix="yes" Text="Explore all connection settings https://docs.snowflake.com/en/developer-guide/snowflake-cli-v2/connecting/connect"/>
19+
<Control Id="Description5" Type="Text" X="135" Y="130" Width="220" Height="20" Transparent="yes" NoPrefix="yes" Text="3. Execute the command to connect to Snowflake:"/>
20+
<Control Id="Description6" Type="Text" X="135" Y="150" Width="220" Height="20" Transparent="yes" NoPrefix="yes" Text="{\DlgMonoFont}snow connection test"/>
21+
<Control Id="Description7" Type="Text" X="135" Y="170" Width="220" Height="20" Transparent="yes" NoPrefix="yes" Text="Explore all connection settings https://docs.snowflake.com/en/developer-guide/snowflake-cli-v2/connecting/connect"/>
2222
<Control Id="Title" Type="Text" X="135" Y="20" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.ExitDialogTitle)" />
2323
</Dialog>
2424
<InstallUISequence>

snyk/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ rich==13.9.4
1111
setuptools==78.0.1
1212
snowflake-connector-python[secure-local-storage]==3.14.0
1313
snowflake-snowpark-python>=1.15.0,<1.26.0;python_version < "3.12"
14-
snowflake.core==1.0.2; python_version < "3.12"
14+
snowflake.core==1.1.0; python_version < "3.12"
1515
tomlkit==0.13.2
1616
typer==0.15.2
1717
urllib3>=1.24.3,<2.4

src/snowflake/cli/_app/commands_registration/builtin_plugins.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from snowflake.cli._plugins.git import plugin_spec as git_plugin_spec
2020
from snowflake.cli._plugins.helpers import plugin_spec as migrate_plugin_spec
2121
from snowflake.cli._plugins.init import plugin_spec as init_plugin_spec
22+
from snowflake.cli._plugins.logs import plugin_spec as logs_plugin_spec
2223
from snowflake.cli._plugins.nativeapp import plugin_spec as nativeapp_plugin_spec
2324
from snowflake.cli._plugins.notebook import plugin_spec as notebook_plugin_spec
2425
from snowflake.cli._plugins.object import plugin_spec as object_plugin_spec
@@ -53,6 +54,7 @@ def get_builtin_plugin_name_to_plugin_spec():
5354
"workspace": workspace_plugin_spec,
5455
"plugin": plugin_plugin_spec,
5556
"dbt": dbt_plugin_spec,
57+
"logs": logs_plugin_spec,
5658
}
5759

5860
return plugin_specs

src/snowflake/cli/_plugins/auth/keypair/commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def setup(
8787
**options,
8888
):
8989
"""
90-
Generates the key pair, sets the public key for the user in Snowflake and creates or updates the connection.
90+
Generates the key pair, sets the public key for the user in Snowflake, and creates or updates the connection.
9191
"""
9292
AuthManager().setup(
9393
connection_name=connection_name,
@@ -106,7 +106,7 @@ def rotate(
106106
**options,
107107
):
108108
"""
109-
Rotates the key for the connection. Generates the key pair, sets the public key for the user in Snowflake and creates or updates the connection.
109+
Rotates the key for the connection. Generates the key pair, sets the public key for the user in Snowflake, and creates or updates the connection.
110110
"""
111111
AuthManager().rotate(
112112
key_length=key_length,
@@ -129,7 +129,7 @@ def remove(
129129
public_key_property: PublicKeyProperty = typer.Option(
130130
...,
131131
"--key-id",
132-
help=f"local path to template directory or URL to git repository with templates.",
132+
help=f"Local path to the template directory or a URL to Git repository with templates.",
133133
show_default=False,
134134
),
135135
**options,

src/snowflake/cli/_plugins/logs/__init__.py

Whitespace-only changes.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import itertools
2+
from datetime import datetime
3+
from typing import Generator, Iterable, Optional, cast
4+
5+
import typer
6+
from click import ClickException
7+
from snowflake.cli._plugins.logs.manager import LogsManager, LogsQueryRow
8+
from snowflake.cli._plugins.object.commands import NameArgument, ObjectArgument
9+
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
10+
from snowflake.cli.api.identifiers import FQN
11+
from snowflake.cli.api.output.types import (
12+
CommandResult,
13+
MessageResult,
14+
StreamResult,
15+
)
16+
17+
app = SnowTyperFactory()
18+
19+
20+
@app.command(name="logs", requires_connection=True)
21+
def get_logs(
22+
object_type: str = ObjectArgument,
23+
object_name: FQN = NameArgument,
24+
from_: Optional[str] = typer.Option(
25+
None,
26+
"--from",
27+
help="The start time of the logs to retrieve. Accepts all ISO8061 formats",
28+
),
29+
to: Optional[str] = typer.Option(
30+
None,
31+
"--to",
32+
help="The end time of the logs to retrieve. Accepts all ISO8061 formats",
33+
),
34+
refresh_time: int = typer.Option(
35+
None,
36+
"--refresh",
37+
help="If set, the logs will be streamed with the given refresh time in seconds",
38+
),
39+
**options,
40+
):
41+
"""
42+
Retrieves logs for a given object.
43+
"""
44+
if refresh_time and to:
45+
raise ClickException(
46+
"You cannot set both --refresh and --to parameters. Please check the values"
47+
)
48+
49+
from_time = get_datetime_from_string(from_, "--from") if from_ else None
50+
to_time = get_datetime_from_string(to, "--to") if to else None
51+
52+
if refresh_time:
53+
logs_stream: Iterable[LogsQueryRow] = LogsManager().stream_logs(
54+
object_type=object_type,
55+
object_name=object_name,
56+
from_time=from_time,
57+
refresh_time=refresh_time,
58+
)
59+
logs = itertools.chain(
60+
(MessageResult(log.log_message) for logs in logs_stream for log in logs)
61+
)
62+
else:
63+
logs_iterable: Iterable[LogsQueryRow] = LogsManager().get_logs(
64+
object_type=object_type,
65+
object_name=object_name,
66+
from_time=from_time,
67+
to_time=to_time,
68+
)
69+
logs = (MessageResult(log.log_message) for log in logs_iterable) # type: ignore
70+
71+
return StreamResult(cast(Generator[CommandResult, None, None], logs))
72+
73+
74+
def get_datetime_from_string(
75+
date_str: str,
76+
name: Optional[str] = None,
77+
) -> datetime:
78+
try:
79+
return datetime.fromisoformat(date_str)
80+
except ValueError:
81+
raise ClickException(
82+
f"Incorrect format for '{name}'. Please use one of approved ISO formats."
83+
)

0 commit comments

Comments
 (0)