Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
# Release History

## 1.47.0 (TBD)

### Snowpark Python API Updates

#### New Features

#### Bug Fixes

- Fixed a bug where `Session.udf.register_from_file` did not properly process the `strict` and `secure` parameters.

#### Improvements


## 1.46.0 (TBD)
## 1.46.0 (2026-02-23)

### Snowpark Python API Updates

Expand All @@ -26,6 +13,7 @@

- Fixed a bug where `cloudpickle` was not automatically added to the package list when using `artifact_repository` with custom packages, causing `ModuleNotFoundError` at runtime.
- Fixed a bug when reading xml with custom schema, result include element attributes when column is not `StructType` type.
- Fixed a bug where `Session.udf.register_from_file` did not properly process the `strict` and `secure` parameters.

#### Improvements

Expand Down
2 changes: 1 addition & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "snowflake-snowpark-python" %}
{% set version = "1.45.0" %}
{% set version = "1.46.0" %}
{% set noarch_build = (os.environ.get('SNOWFLAKE_SNOWPARK_PYTHON_NOARCH_BUILD', 'false')) == 'true' %}
{% set build_number = os.environ.get('SNOWFLAKE_SNOWPARK_PYTHON_BUILD_NUMBER', 0) %}

Expand Down
20 changes: 12 additions & 8 deletions src/snowflake/snowpark/_internal/udf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,9 +1142,9 @@ def add_snowpark_package_to_sproc_packages(
packages = [this_package]
else:
with session._package_lock:
existing_packages = session._artifact_repository_packages[
existing_packages = session._get_packages_by_artifact_repository(
artifact_repository
]
)
if package_name not in existing_packages:
packages = list(existing_packages.values()) + [this_package]
return packages
Expand Down Expand Up @@ -1239,7 +1239,9 @@ def resolve_imports_and_packages(
)

existing_packages_dict = (
session._artifact_repository_packages[artifact_repository] if session else {}
session._get_packages_by_artifact_repository(artifact_repository)
if session
else {}
)

if artifact_repository != _ANACONDA_SHARED_REPOSITORY:
Expand All @@ -1248,7 +1250,9 @@ def resolve_imports_and_packages(
if not packages and session:
resolved_packages = list(
session._resolve_packages(
[], artifact_repository, existing_packages_dict
[],
artifact_repository=artifact_repository,
existing_packages_dict=existing_packages_dict,
)
)
elif packages:
Expand Down Expand Up @@ -1286,17 +1290,17 @@ def resolve_imports_and_packages(
resolved_packages = (
session._resolve_packages(
packages,
artifact_repository,
{}, # ignore session packages if passed in explicitly
artifact_repository=artifact_repository,
existing_packages_dict={}, # ignore session packages if passed in explicitly
include_pandas=is_pandas_udf,
statement_params=statement_params,
_suppress_local_package_warnings=_suppress_local_package_warnings,
)
if packages is not None
else session._resolve_packages(
[],
artifact_repository,
existing_packages_dict,
artifact_repository=artifact_repository,
existing_packages_dict=existing_packages_dict,
validate_package=False,
include_pandas=is_pandas_udf,
statement_params=statement_params,
Expand Down
48 changes: 39 additions & 9 deletions src/snowflake/snowpark/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,9 @@ def __init__(
self._conn = conn
self._query_tag = None
self._import_paths: Dict[str, Tuple[Optional[str], Optional[str]]] = {}
# packages under the DEFAULT_ARTIFACT_REPOSITORY
# due to server side accessing private session members, this cannot be merged with _artifact_repository_packages
self._packages: Dict[str, str] = {}
# map of artifact repository name -> packages that should be added to functions under that repository
self._artifact_repository_packages: DefaultDict[
str, Dict[str, str]
Expand Down Expand Up @@ -1599,6 +1602,14 @@ def _list_files_in_stage(
prefix_length = get_stage_file_prefix_length(stage_location)
return {str(row[0])[prefix_length:] for row in file_list}

def _get_packages_by_artifact_repository(
self, artifact_repository: str
) -> Dict[str, str]:
if artifact_repository == _DEFAULT_ARTIFACT_REPOSITORY:
return self._packages
else:
return self._artifact_repository_packages[artifact_repository]

def get_packages(self, artifact_repository: Optional[str] = None) -> Dict[str, str]:
"""
Returns a ``dict`` of packages added for user-defined functions (UDFs).
Expand All @@ -1613,7 +1624,7 @@ def get_packages(self, artifact_repository: Optional[str] = None) -> Dict[str, s
artifact_repository = self._get_default_artifact_repository()

with self._package_lock:
return self._artifact_repository_packages[artifact_repository].copy()
return self._get_packages_by_artifact_repository(artifact_repository).copy()

def add_packages(
self,
Expand Down Expand Up @@ -1686,8 +1697,10 @@ def add_packages(

self._resolve_packages(
parse_positional_args_to_list(*packages),
artifact_repository,
self._artifact_repository_packages[artifact_repository],
artifact_repository=artifact_repository,
existing_packages_dict=self._get_packages_by_artifact_repository(
artifact_repository
),
)

def remove_package(
Expand Down Expand Up @@ -1724,7 +1737,7 @@ def remove_package(
artifact_repository = self._get_default_artifact_repository()

with self._package_lock:
packages = self._artifact_repository_packages[artifact_repository]
packages = self._get_packages_by_artifact_repository(artifact_repository)
if package_name in packages:
packages.pop(package_name)
else:
Expand All @@ -1742,7 +1755,7 @@ def clear_packages(
artifact_repository = self._get_default_artifact_repository()

with self._package_lock:
self._artifact_repository_packages[artifact_repository].clear()
self._get_packages_by_artifact_repository(artifact_repository).clear()

def add_requirements(
self,
Expand Down Expand Up @@ -2110,11 +2123,11 @@ def _get_req_identifiers_list(
def _resolve_packages(
self,
packages: List[Union[str, ModuleType]],
artifact_repository: str,
existing_packages_dict: Dict[str, str],
existing_packages_dict: Dict[str, str] = None,
validate_package: bool = True,
include_pandas: bool = False,
statement_params: Optional[Dict[str, str]] = None,
artifact_repository: str = None,
**kwargs,
) -> List[str]:
"""
Expand All @@ -2132,6 +2145,13 @@ def _resolve_packages(
Returns:
List[str]: List of package specifiers
"""
if artifact_repository is None:
artifact_repository = self._get_default_artifact_repository()
if existing_packages_dict is None:
existing_packages_dict = self._get_packages_by_artifact_repository(
artifact_repository
)

# Always include cloudpickle
extra_modules = [cloudpickle]
if include_pandas:
Expand Down Expand Up @@ -2404,7 +2424,10 @@ def _get_default_artifact_repository(self) -> str:
if isinstance(self._conn, MockServerConnection):
return _DEFAULT_ARTIFACT_REPOSITORY

cache_key = (self.get_current_database(), self.get_current_schema())
account = self.get_current_account()
database = self.get_current_database()
schema = self.get_current_schema()
cache_key = (database, schema)

if (
self._default_artifact_repository_cache is not None
Expand All @@ -2414,8 +2437,15 @@ def _get_default_artifact_repository(self) -> str:

try:
python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
entity_selector_args = (
f"'schema', '{schema}'"
if schema
else f"'database', '{database}'"
if database
else f"'account', '{account}'"
)
result = self._run_query(
f"SELECT SYSTEM$GET_DEFAULT_PYTHON_ARTIFACT_REPOSITORY('{python_version}')"
f"SELECT SYSTEM$GET_DEFAULT_PYTHON_ARTIFACT_REPOSITORY('{python_version}', {entity_selector_args})"
)
value = result[0][0] if result else None
resolved = value or _DEFAULT_ARTIFACT_REPOSITORY
Expand Down
2 changes: 1 addition & 1 deletion src/snowflake/snowpark/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


# Update this for the versions
VERSION = (1, 45, 0)
VERSION = (1, 46, 0)
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.agg.test
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.ai.test
Original file line number Diff line number Diff line change
Expand Up @@ -2146,6 +2146,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.col_ilike.test
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.collect.test
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.count.test
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.count2.test
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.create_or_replace.test
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.cross_join.lsuffix.test
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.cross_join.rsuffix.test
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.cross_join.suffix.test
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.describe.test
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.flatten.test
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.indexers.test
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.join.inner.column.test
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.join.inner.column_list.test
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.join.inner.predicate.test
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.join.left_outer.column.test
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.join.right_outer.predicate.test
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.join_table_function.test
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
2 changes: 1 addition & 1 deletion tests/ast/data/DataFrame.lateral_join.test
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,6 @@ client_language {
}
client_version {
major: 1
minor: 45
minor: 46
}
id: "\003U\"\366q\366P\346\260\261?\234\303\254\316\353"
Loading