diff --git a/src/snowflake/snowpark/session.py b/src/snowflake/snowpark/session.py index 57ab2cdadcf..6313fd6d195 100644 --- a/src/snowflake/snowpark/session.py +++ b/src/snowflake/snowpark/session.py @@ -1167,13 +1167,22 @@ def get_req_identifiers_list( name = package.name version = package.specs[0][1] if package.specs else None + # result_dict is a mapping of package name -> package_spec, example + # {'pyyaml': 'pyyaml==6.0', + # 'networkx': 'networkx==3.1', + # 'numpy': 'numpy', + # 'scikit-learn': 'scikit-learn==1.2.2', + # 'python-dateutil': 'python-dateutil==2.8.2'} # Add to packages dictionary if name in result_dict: - if version is not None and result_dict[name] != str(package): - raise ValueError( - f"Cannot add dependency package '{name}=={version}' " - f"because {result_dict[name]} is already added." - ) + if version is not None: + added_package_has_version = "==" in result_dict[name] + if added_package_has_version and result_dict[name] != str(package): + raise ValueError( + f"Cannot add dependency package '{name}=={version}' " + f"because {result_dict[name]} is already added." + ) + result_dict[name] = str(package) else: result_dict[name] = str(package) @@ -1707,7 +1716,6 @@ def connection(self) -> "SnowflakeConnection": and Snowflake server.""" return self._conn._conn - def _run_query( self, query: str,