diff --git a/CHANGELOG.md b/CHANGELOG.md index 06851bd46c7..61b5ee4afa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ #### Bug Fixes - Fixed a bug where SQL generated for selecting `*` column has an incorrect subquery. - Fixed a bug in `DataFrame.to_pandas_batches` where the iterator could throw an error if certain transformation is made to the pandas dataframe due to wrong isolation level. +- Fixed a bug in `DataFrame.lineage.trace` to split the quoted feature view's name and version correctly. ### Snowpark Local Testing Updates #### New Features diff --git a/src/snowflake/snowpark/lineage.py b/src/snowflake/snowpark/lineage.py index 72f93f5fef1..2d1d2444459 100644 --- a/src/snowflake/snowpark/lineage.py +++ b/src/snowflake/snowpark/lineage.py @@ -424,10 +424,13 @@ def _get_name_and_version(self, graph_entity: Dict[str, Any]): if user_domain in self._versioned_object_domains: if user_domain == _UserDomain.FEATURE_VIEW: if "$" in name: - parts = name.split("$") + had_quotes = name.startswith('"') and name.endswith('"') + parts = name.strip('"').split("$") if len(parts) >= 2: base_name = "$".join(parts[:-1]) version = parts[-1] + if had_quotes: + base_name = f'"{base_name}"' return (f"{db}.{schema}.{base_name}", version) else: raise SnowparkClientExceptionMessages.SERVER_FAILED_FETCH_LINEAGE( diff --git a/tests/unit/test_lineage.py b/tests/unit/test_lineage.py index b9f398d4c76..d5446d57c30 100644 --- a/tests/unit/test_lineage.py +++ b/tests/unit/test_lineage.py @@ -66,6 +66,17 @@ def test_get_name_and_version(): assert name == "db1.schema1.name1" assert version == "v1" + graph_entity = { + _ObjectField.USER_DOMAIN: _UserDomain.FEATURE_VIEW, + _ObjectField.DB: "db1", + _ObjectField.SCHEMA: "schema1", + _ObjectField.PROPERTIES: {_ObjectField.PARENT_NAME: "whatever"}, + _ObjectField.NAME: '"name1$v1"', + } + name, version = Lineage(fake_session)._get_name_and_version(graph_entity) + assert name == 'db1.schema1."name1"' + assert version == "v1" + graph_entity = { _ObjectField.USER_DOMAIN: _UserDomain.FEATURE_VIEW, _ObjectField.DB: "db1",