snowflake-cli 3.1.0__py3-none-any.whl → 3.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- snowflake/cli/__about__.py +1 -1
- snowflake/cli/_app/dev/docs/templates/usage.rst.jinja2 +1 -1
- snowflake/cli/_plugins/connection/commands.py +124 -109
- snowflake/cli/_plugins/connection/util.py +54 -9
- snowflake/cli/_plugins/cortex/manager.py +1 -1
- snowflake/cli/_plugins/git/manager.py +4 -4
- snowflake/cli/_plugins/nativeapp/artifacts.py +64 -10
- snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +5 -3
- snowflake/cli/_plugins/nativeapp/commands.py +10 -3
- snowflake/cli/_plugins/nativeapp/constants.py +1 -0
- snowflake/cli/_plugins/nativeapp/entities/application.py +501 -440
- snowflake/cli/_plugins/nativeapp/entities/application_package.py +563 -885
- snowflake/cli/_plugins/nativeapp/entities/models/event_sharing_telemetry.py +58 -0
- snowflake/cli/_plugins/nativeapp/same_account_install_method.py +0 -2
- snowflake/cli/_plugins/nativeapp/sf_facade.py +30 -0
- snowflake/cli/_plugins/nativeapp/sf_facade_constants.py +25 -0
- snowflake/cli/_plugins/nativeapp/sf_facade_exceptions.py +117 -0
- snowflake/cli/_plugins/nativeapp/sf_sql_facade.py +525 -0
- snowflake/cli/_plugins/nativeapp/v2_conversions/compat.py +1 -89
- snowflake/cli/_plugins/nativeapp/version/commands.py +6 -3
- snowflake/cli/_plugins/notebook/manager.py +2 -2
- snowflake/cli/_plugins/object/commands.py +10 -1
- snowflake/cli/_plugins/object/manager.py +13 -5
- snowflake/cli/_plugins/snowpark/common.py +3 -3
- snowflake/cli/_plugins/snowpark/package/anaconda_packages.py +1 -1
- snowflake/cli/_plugins/spcs/common.py +29 -0
- snowflake/cli/_plugins/spcs/compute_pool/manager.py +7 -9
- snowflake/cli/_plugins/spcs/image_registry/manager.py +2 -2
- snowflake/cli/_plugins/spcs/image_repository/manager.py +1 -1
- snowflake/cli/_plugins/spcs/services/commands.py +64 -13
- snowflake/cli/_plugins/spcs/services/manager.py +75 -15
- snowflake/cli/_plugins/sql/commands.py +9 -1
- snowflake/cli/_plugins/sql/manager.py +9 -4
- snowflake/cli/_plugins/stage/commands.py +20 -16
- snowflake/cli/_plugins/stage/diff.py +1 -1
- snowflake/cli/_plugins/stage/manager.py +140 -11
- snowflake/cli/_plugins/streamlit/manager.py +5 -5
- snowflake/cli/_plugins/workspace/commands.py +6 -3
- snowflake/cli/api/cli_global_context.py +1 -0
- snowflake/cli/api/config.py +23 -5
- snowflake/cli/api/console/console.py +4 -19
- snowflake/cli/api/entities/utils.py +19 -32
- snowflake/cli/api/errno.py +2 -0
- snowflake/cli/api/exceptions.py +9 -0
- snowflake/cli/api/metrics.py +223 -7
- snowflake/cli/api/output/types.py +1 -1
- snowflake/cli/api/project/definition_conversion.py +179 -62
- snowflake/cli/api/rest_api.py +26 -4
- snowflake/cli/api/secure_utils.py +1 -1
- snowflake/cli/api/sql_execution.py +35 -22
- snowflake/cli/api/stage_path.py +5 -2
- {snowflake_cli-3.1.0.dist-info → snowflake_cli-3.2.1.dist-info}/METADATA +7 -8
- {snowflake_cli-3.1.0.dist-info → snowflake_cli-3.2.1.dist-info}/RECORD +56 -55
- {snowflake_cli-3.1.0.dist-info → snowflake_cli-3.2.1.dist-info}/WHEEL +1 -1
- snowflake/cli/_plugins/nativeapp/manager.py +0 -392
- snowflake/cli/_plugins/nativeapp/project_model.py +0 -211
- snowflake/cli/_plugins/nativeapp/run_processor.py +0 -184
- snowflake/cli/_plugins/nativeapp/version/version_processor.py +0 -56
- {snowflake_cli-3.1.0.dist-info → snowflake_cli-3.2.1.dist-info}/entry_points.txt +0 -0
- {snowflake_cli-3.1.0.dist-info → snowflake_cli-3.2.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import List, Optional
|
|
16
|
+
|
|
17
|
+
from click import ClickException
|
|
18
|
+
from pydantic import Field, field_validator, model_validator
|
|
19
|
+
from snowflake.cli.api.project.schemas.updatable_model import UpdatableModel
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class EventSharingTelemetry(UpdatableModel):
|
|
23
|
+
share_mandatory_events: Optional[bool] = Field(
|
|
24
|
+
title="Indicates whether Snowflake is authorized to share application usage data with the application package provider. When enabled, mandatory events will be shared automatically.",
|
|
25
|
+
default=None,
|
|
26
|
+
)
|
|
27
|
+
optional_shared_events: Optional[List[str]] = Field(
|
|
28
|
+
title="A list of optional telemetry events that the application owner consents to share with the application package provider.",
|
|
29
|
+
default=None,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
@model_validator(mode="after")
|
|
33
|
+
@classmethod
|
|
34
|
+
def validate_telemetry_event_sharing(
|
|
35
|
+
cls, value: "EventSharingTelemetry"
|
|
36
|
+
) -> "EventSharingTelemetry":
|
|
37
|
+
if value.optional_shared_events and not value.share_mandatory_events:
|
|
38
|
+
raise ClickException(
|
|
39
|
+
"'telemetry.share_mandatory_events' must be set to 'true' when sharing optional events through 'telemetry.optional_shared_events'."
|
|
40
|
+
)
|
|
41
|
+
return value
|
|
42
|
+
|
|
43
|
+
@field_validator("optional_shared_events")
|
|
44
|
+
@classmethod
|
|
45
|
+
def validate_optional_shared_events(
|
|
46
|
+
cls, original_shared_events: Optional[List[str]]
|
|
47
|
+
) -> Optional[List[str]]:
|
|
48
|
+
if original_shared_events is None:
|
|
49
|
+
return None
|
|
50
|
+
|
|
51
|
+
# make sure each event is non-empty String:
|
|
52
|
+
for event in original_shared_events:
|
|
53
|
+
if not event:
|
|
54
|
+
raise ClickException(
|
|
55
|
+
"Events listed in 'telemetry.optional_shared_events' must not be blank"
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
return original_shared_events
|
|
@@ -7,8 +7,6 @@ from snowflake.cli._plugins.nativeapp.constants import (
|
|
|
7
7
|
from snowflake.cli._plugins.nativeapp.exceptions import (
|
|
8
8
|
ApplicationCreatedExternallyError,
|
|
9
9
|
)
|
|
10
|
-
|
|
11
|
-
# from snowflake.cli._plugins.nativeapp.project_model import NativeAppProjectModel
|
|
12
10
|
from snowflake.cli._plugins.stage.manager import StageManager
|
|
13
11
|
|
|
14
12
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from contextvars import ContextVar
|
|
16
|
+
|
|
17
|
+
from snowflake.cli._plugins.nativeapp.sf_sql_facade import SnowflakeSQLFacade
|
|
18
|
+
|
|
19
|
+
_SNOWFLAKE_FACADE: ContextVar[SnowflakeSQLFacade | None] = ContextVar(
|
|
20
|
+
"snowflake_sql_facade", default=None
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get_snowflake_facade() -> SnowflakeSQLFacade:
|
|
25
|
+
"""Returns a Snowflake Facade"""
|
|
26
|
+
facade = _SNOWFLAKE_FACADE.get()
|
|
27
|
+
if not facade:
|
|
28
|
+
facade = SnowflakeSQLFacade()
|
|
29
|
+
_SNOWFLAKE_FACADE.set(facade)
|
|
30
|
+
return facade
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from enum import Enum
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class UseObjectType(Enum):
|
|
19
|
+
DATABASE = "database"
|
|
20
|
+
ROLE = "role"
|
|
21
|
+
SCHEMA = "schema"
|
|
22
|
+
WAREHOUSE = "warehouse"
|
|
23
|
+
|
|
24
|
+
def __str__(self):
|
|
25
|
+
return self.value
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
from typing import NoReturn
|
|
15
|
+
|
|
16
|
+
from click import ClickException
|
|
17
|
+
from snowflake.cli._plugins.nativeapp.sf_facade_constants import UseObjectType
|
|
18
|
+
from snowflake.connector import DatabaseError, Error, ProgrammingError
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def handle_unclassified_error(err: Error | Exception, context: str) -> NoReturn:
|
|
22
|
+
"""
|
|
23
|
+
Handles exceptions that are not caught by categorized exceptions in SQLFacade
|
|
24
|
+
@param err: connector error or base exception
|
|
25
|
+
@param context: message to add context to exception
|
|
26
|
+
"""
|
|
27
|
+
message = f"{context} {str(err)}"
|
|
28
|
+
if isinstance(err, ProgrammingError):
|
|
29
|
+
raise InvalidSQLError(message) from err
|
|
30
|
+
|
|
31
|
+
if isinstance(err, DatabaseError):
|
|
32
|
+
raise UnknownSQLError(message) from err
|
|
33
|
+
|
|
34
|
+
if isinstance(err, Error):
|
|
35
|
+
raise UnknownConnectorError(message) from err
|
|
36
|
+
|
|
37
|
+
# Not a connector error
|
|
38
|
+
raise Exception(message) from err
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class _BaseFacadeError(Exception):
|
|
42
|
+
"""Base class for SnowflakeFacade Exceptions"""
|
|
43
|
+
|
|
44
|
+
def __init__(self, msg):
|
|
45
|
+
self.msg = msg
|
|
46
|
+
super().__init__(self.msg)
|
|
47
|
+
|
|
48
|
+
def __str__(self):
|
|
49
|
+
return self.msg
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class InvalidSQLError(_BaseFacadeError):
|
|
53
|
+
"""Raised when Snowflake executed a SQL command but encountered an error, for example due to syntax or logical errors"""
|
|
54
|
+
|
|
55
|
+
def __init__(self, msg):
|
|
56
|
+
super().__init__(f"Invalid SQL error occurred. {msg}")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class UnknownSQLError(_BaseFacadeError):
|
|
60
|
+
"""Raised when Snowflake could not execute the SQL command"""
|
|
61
|
+
|
|
62
|
+
def __init__(self, msg):
|
|
63
|
+
super().__init__(f"Unknown SQL error occurred. {msg}")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class UnknownConnectorError(_BaseFacadeError):
|
|
67
|
+
"""Raised when there was a problem reaching Snowflake to execute a SQL command"""
|
|
68
|
+
|
|
69
|
+
def __init__(self, msg):
|
|
70
|
+
super().__init__(f"Unknown error occurred. {msg}")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class UnexpectedResultError(_BaseFacadeError):
|
|
74
|
+
"""Raised when an unexpected result was returned from execution of a SQL command"""
|
|
75
|
+
|
|
76
|
+
def __init__(self, msg):
|
|
77
|
+
super().__init__(f"Received unexpected result from query. {msg}")
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class UserScriptError(ClickException):
|
|
81
|
+
"""Exception raised when user-provided scripts fail."""
|
|
82
|
+
|
|
83
|
+
def __init__(self, script_name, msg):
|
|
84
|
+
super().__init__(f"Failed to run script {script_name}. {msg}")
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class UserInputError(ClickException):
|
|
88
|
+
"""Exception raised when execution of SQL with user input fails."""
|
|
89
|
+
|
|
90
|
+
pass
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class CouldNotUseObjectError(UserInputError):
|
|
94
|
+
def __init__(self, object_type: UseObjectType, name: str):
|
|
95
|
+
super().__init__(
|
|
96
|
+
f"Could not use {object_type} {name}. Object does not exist, or operation cannot be performed."
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class InsufficientPrivilegesError(ClickException):
|
|
101
|
+
"""Raised when user does not have sufficient privileges to perform an operation"""
|
|
102
|
+
|
|
103
|
+
def __init__(
|
|
104
|
+
self,
|
|
105
|
+
message,
|
|
106
|
+
*,
|
|
107
|
+
role: str | None = None,
|
|
108
|
+
database: str | None = None,
|
|
109
|
+
schema: str | None = None,
|
|
110
|
+
):
|
|
111
|
+
if schema:
|
|
112
|
+
message += f" in schema: {schema}"
|
|
113
|
+
if database:
|
|
114
|
+
message += f" in database: {database}"
|
|
115
|
+
if role:
|
|
116
|
+
message += f" using role: {role}"
|
|
117
|
+
super().__init__(message)
|