Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1552816 : Fix Session.lineage.trace API output for feature views #1990

Merged
merged 2 commits into from
Jul 30, 2024
Merged
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
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
#### New Features
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('"')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: has_quotes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, I didnt see this. I have another PR open, I will fix this in that one

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
Loading