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-172] Add filter to file_latest and add comments #128

Merged
merged 3 commits into from
Feb 6, 2025

Conversation

danlu1
Copy link
Contributor

@danlu1 danlu1 commented Feb 6, 2025

Problem:

The original file_latest dynamic table does not have filter since the interpretation of CHANGE_TYPE='DELETE' vs STATUS != "AVAILABLE". Platform team confirmed that CHANGE_TYPE!='DELETE' can be used to filter out file handles which have been deleted.

Solution:

  • Replace file_latest by adding the filter CHANGE_TYPE!='DELETE' and NOT IS_PREVIEW
  • Add table and column comments again since comments will be wiped out when replacing the table

@danlu1 danlu1 requested a review from a team as a code owner February 6, 2025 19:26
Copy link
Collaborator

@philerooski philerooski left a comment

Choose a reason for hiding this comment

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

There's one other filter which is missing. The original upsert_to_file_latest_task had this filter before QUALIFYing the results.

... WHERE NOT IS_PREVIEW

See these lines: https://github.com/Sage-Bionetworks/snowflake/blob/main/synapse_data_warehouse/synapse_raw/tasks/V1.14.0__merge_into_latest_tables.sql#L149-L150

@danlu1 danlu1 requested a review from philerooski February 6, 2025 19:41
@danlu1
Copy link
Contributor Author

danlu1 commented Feb 6, 2025

There's one other filter which is missing. The original upsert_to_file_latest_task had this filter before QUALIFYing the results.

... WHERE NOT IS_PREVIEW

See these lines: https://github.com/Sage-Bionetworks/snowflake/blob/main/synapse_data_warehouse/synapse_raw/tasks/V1.14.0__merge_into_latest_tables.sql#L149-L150

Thanks for catching. I forgot to add this one back when removing the status filter.

@philerooski
Copy link
Collaborator

@danlu1 There's an optimization we can do here, since a file handle which is a preview file handle will never NOT be a preview, we don't need to consider whether this is the latest snapshot of that file. That means we can move the WHERE filter up into the WITH... AS... statement.

The WHERE filtering will be done before QUALIFY as documented here.

@philerooski
Copy link
Collaborator

@danlu1 Do you want to move the WHERE NOT IS_PREVIEW statement? I'd like to approve and validate this today so that we can make a new release.

@danlu1
Copy link
Contributor Author

danlu1 commented Feb 6, 2025

@philerooski Done.

Copy link

sonarqubecloud bot commented Feb 6, 2025

@philerooski philerooski merged commit a6d2502 into dev Feb 6, 2025
3 checks passed
@philerooski philerooski deleted the snow-172-file-latest-dynamic-table-add-filter branch February 6, 2025 23:17
philerooski pushed a commit that referenced this pull request Feb 6, 2025
* add filter to file_latest and add comments

* Update V2.38.0__reintroduce_file_latest_dynamic_table.sql

Add NOT IS_PREVIEW filter

* Update V2.38.0__reintroduce_file_latest_dynamic_table.sql

move not is_preview filter
philerooski pushed a commit that referenced this pull request Feb 7, 2025
* add filter to file_latest and add comments

* Update V2.38.0__reintroduce_file_latest_dynamic_table.sql

Add NOT IS_PREVIEW filter

* Update V2.38.0__reintroduce_file_latest_dynamic_table.sql

move not is_preview filter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants