Skip to content

Commit

Permalink
SNOW-1552816 : Fix Session.lineage.trace API output for feature views (
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-rsureshbabu authored Jul 30, 2024
1 parent 61ba224 commit 5130ae3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion src/snowflake/snowpark/lineage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_lineage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5130ae3

Please sign in to comment.