-
Notifications
You must be signed in to change notification settings - Fork 4
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-155] Converting userprofile_latest table to dynamic table #100
Conversation
LOCATION VARCHAR(16777216) COMMENT 'The location of the user.', | ||
COMPANY VARCHAR(16777216) COMMENT 'The company where the user works.', | ||
POSITION VARCHAR(16777216) COMMENT 'The position of the user in the company.', | ||
INDUSTRY VARCHAR(16777216) COMMENT 'The industry/discipline that this person is associated with.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if explicitly listing out the columns like this would ever clash with the SELECT *
from the main query, if say userprofilesnapshot
gets a column added to it later down the line? So either we keep the SELECT *
and implicitly call the columns in this script + introduce the column comments in a separate script, or the columns selected are explicitly written out in the main query of this script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're not modifying any columns from the upstream table I recommend using the more succinct style which you can see in Jenny's PR which I linked to below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I will add column comments as a separate step as like what Jenny said, new columns might be added to the source table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a heads up: I noticed that dynamic table comments don't show up in their own little Description box the way regular table comments do. With the dynamic table, you have to dive into the Table Definition itself to see that the dynamic table comment was added. It would be nice if we can also have the dynamic table comments front and center the way it is with the normal ones, but for now this is what it is. Dynamic tables were just added last year, so I'm sure this is a QOL improvement they'll add in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the only ways to check the Table comments are either hover over the table name and the comment section which is pretty tiny or refer to the Table Definition. Hope the Description box gets added soon.
synapse_data_warehouse/synapse_raw/tasks/V2.29.1__delete_userprofile_latest_tasks.sql
Outdated
Show resolved
Hide resolved
synapse_data_warehouse/synapse/dynamic_tables/V2.29.4__userprofile_latest.sql
Outdated
Show resolved
Hide resolved
synapse_data_warehouse/synapse/dynamic_tables/V2.29.4__userprofile_latest.sql
Outdated
Show resolved
Hide resolved
NULLIF(LOCATION, '') AS LOCATION, | ||
NULLIF(COMPANY, '') AS COMPANY, | ||
NULLIF(POSITION, '') AS POSITION, | ||
NULLIF(INDUSTRY, '') AS INDUSTRY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we ever figure out why some columns were being recorded as null and others as a blank string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, not sure why this happened. Besides these columns, First_Name and Last_Name do have both empty strings and nulls. But I feel these 4 columns are more generic for business metrics so I convert empty strings for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a platform ticket to investigate this here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bugged Marco about this in the Slack thread to see if we can figure out whether this is in the Parquet or if Snowflake is introducing these inconsistencies during data load.
@danlu1 if you want to merge this before we've figured out the root of the issue can you leave an inline comment with the Jira ticket identifier which Jenny linked so that we have some provenance for these changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As Marco's reply, it seems there is no easy answer for the discrepancies since he noticed this in Athena as well. I'd just merge the PR and leave a comment and we can revisit after SWC-7215 is resolved.
Depends on #99 due to V script versioning |
* | ||
FROM {{database_name}}.SYNAPSE_RAW.USERPROFILESNAPSHOT --noqa: TMP | ||
WHERE | ||
SNAPSHOT_DATE >= CURRENT_TIMESTAMP - INTERVAL '14 days' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be consistent and use the same day interval for reduplication of all snapshots?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency is a good idea. If we do this, we will have to go with INTERVAL '30 days'
as that is the time window for node_latest
and we can't make that one shorter.
Edit: Coming back to this, it's better to keep the interval as 14 days for all dynamic tables but with exceptions like node_latest
because not all snapshot tables have the change_type=DELETE
value, so we will inevitably end up with duplicates in all our tables if we stick to a single window (which would have to be 30+ days because of the exceptions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I second Jenny. Another reason is that the majority of the existing dynamic table is implementing the 14-days interval. @jaymedina I will add the interval setting in SOP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaymedina Another risk that we assume is if snapshotting doesn't occur for 2 weeks in a row.
That said - I think that risk is small except around the holidays. We will need to determine all the tables that we need to be concerned about delete events (even if they don't all track that change type). So do all of these below need to use interval of 30?
- Teams
- Node
- File
- ACL
- teammember?
- project settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like
- AR snapshots
- User group
- Userprofile
As well ( although User group and Userprofile don't capture deletions )
Another thought I just had is a lot of these tables are related to each other (file entities in node_latest
should also be present in file_latest
) sooo maybe for consistency as far as data availability, having all the same windows is better for the users. It would be nice to expedite having change_type=DELETE
be available for all snapshots with a delete option on Synapse so we don't have to worry about the time window thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaymedina @thomasyu888 @philerooski
I did a brief check and the following snapshot tables have change_type=DELETE
:
- ACCESSREQUIREMENTSNAPSHOTS
- ACLSNAPSHOTS
- FILESNAPSHOTS
- NODESNAPSHOTS
- PROJECTSETTINGSNAPSHOTS
Do we agree to keep time window for dynamic tables derived from snopshots with change_type=DELETE to 30 days and other dynamic tables to 14 days?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! This workaround will do until platform team can address the missing change_type=DELETE
for some snapshot tables. Thanks!
@thomasyu888 @jaymedina The above PR is still in draft mode. How about I merge this one first? |
Ill defer to @jaymedina and you to self-organize. The issue is the V script versions, if we merge this first, then it would have to be modified to 2.28 and Jenny's PR would have to be modified to 2.29. My 2cents: I am ok with waiting a bit - Jenny's PR seems almost done - but since you'll be traveling for conference on M-Th, we can help merge if it's not complete. |
@jaymedina The |
🎉 All dependencies have been resolved ! |
|
Problem:
Currently, the userprofile_latest table is a table that is updated via upserting task that is based on userprofilesnapshot stream. We want to convert it to dynamic table so it gets refreshed automatically.
Solution:
Following the instructions of this SOP:
LOCATION
,COMPANY
,POSITION
,INDUSTRY
to Null for easy search. KeepTOS_AGREEMENTS
as VARIANT variable as Phil's comments.Validation(edited):
As the instructions in Validating a "latest" table on synapse_data_warehouse_dev:
Before:

After:

Depends on #99