-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SNOW-60,162,165] Add new columns to
userprofilesnapshots
(#95)
- Loading branch information
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...se/synapse_raw/tables/V2.28.0__add_is_two_factor_auth_enabled_to_userprofilesnapshots.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Configure environment | ||
USE SCHEMA {{database_name}}.synapse_raw; --noqa: JJ01,PRS,TMP,CP02 | ||
|
||
-- Add new column | ||
ALTER TABLE userprofilesnapshot ADD COLUMN is_two_factor_auth_enabled BOOLEAN COMMENT 'Indicates if the user had two factor authentication enabled when the snapshot was captured.'; | ||
ALTER TABLE userprofilesnapshot ADD COLUMN industry STRING COMMENT 'The industry/discipline that this person is associated with.'; | ||
ALTER TABLE userprofilesnapshot ADD COLUMN tos_agreements VARIANT COMMENT 'Contains the list of all the term of service that the user agreed to, with their agreed on date and version.'; |
45 changes: 45 additions & 0 deletions
45
synapse_data_warehouse/synapse_raw/tables/V2.28.1__update_userprofilesnapshots_task.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
-- Configure environment | ||
USE SCHEMA {{database_name}}.synapse_raw; --noqa: JJ01,PRS,TMP,CP02 | ||
|
||
-- Suspend the root task | ||
ALTER TASK refresh_synapse_warehouse_s3_stage_task SUSPEND; | ||
|
||
-- Suspend the child task in question | ||
ALTER TASK userprofilesnapshot_task SUSPEND; | ||
|
||
-- Add the new column to the child task | ||
ALTER TASK userprofilesnapshot_task MODIFY AS | ||
COPY INTO | ||
userprofilesnapshot | ||
FROM ( | ||
SELECT | ||
$1:change_type as change_type, | ||
$1:change_timestamp as change_timestamp, | ||
$1:change_user_id as change_user_id, | ||
$1:snapshot_timestamp as snapshot_timestamp, | ||
$1:id as id, | ||
$1:user_name as user_name, | ||
$1:first_name as first_name, | ||
$1:last_name as last_name, | ||
$1:email as email, | ||
$1:location as location, | ||
$1:company as company, | ||
$1:position as position, | ||
NULLIF( | ||
REGEXP_REPLACE( | ||
metadata$filename, | ||
'.*userprofilesnapshots\/snapshot_date\=(.*)\/.*', '\\1' | ||
), | ||
'__HIVE_DEFAULT_PARTITION__' | ||
) as snapshot_date, | ||
$1:created_on as created_on, | ||
$1:is_two_factor_auth_enabled as is_two_factor_auth_enabled, | ||
$1:industry as industry, | ||
$1:tos_agreements as tos_agreements | ||
from | ||
@synapse_prod_warehouse_s3_stage/userprofilesnapshots --noqa: TMP | ||
) | ||
pattern = '.*userprofilesnapshots/snapshot_date=.*/.*'; | ||
|
||
-- Resume the ROOT task and its child task | ||
SELECT SYSTEM$TASK_DEPENDENTS_ENABLE( 'refresh_synapse_warehouse_s3_stage_task' ); |
38 changes: 38 additions & 0 deletions
38
synapse_data_warehouse/synapse_raw/tables/V2.28.2__refresh_userprofilesnapshots.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
-- Configure environment | ||
USE SCHEMA {{database_name}}.synapse_raw; --noqa: JJ01,PRS,TMP,CP02 | ||
|
||
-- Drop all records from this table but keep structure and permissions intact | ||
TRUNCATE TABLE userprofilesnapshot; | ||
|
||
-- | ||
COPY INTO | ||
userprofilesnapshot | ||
FROM ( | ||
SELECT | ||
$1:change_type as change_type, | ||
$1:change_timestamp as change_timestamp, | ||
$1:change_user_id as change_user_id, | ||
$1:snapshot_timestamp as snapshot_timestamp, | ||
$1:id as id, | ||
$1:user_name as user_name, | ||
$1:first_name as first_name, | ||
$1:last_name as last_name, | ||
$1:email as email, | ||
$1:location as location, | ||
$1:company as company, | ||
$1:position as position, | ||
NULLIF( | ||
REGEXP_REPLACE( | ||
metadata$filename, | ||
'.*userprofilesnapshots\/snapshot_date\=(.*)\/.*', '\\1' | ||
), | ||
'__HIVE_DEFAULT_PARTITION__' | ||
) as snapshot_date, | ||
$1:created_on as created_on, | ||
$1:is_two_factor_auth_enabled as is_two_factor_auth_enabled, | ||
$1:industry as industry, | ||
$1:tos_agreements as tos_agreements | ||
from | ||
@synapse_prod_warehouse_s3_stage/userprofilesnapshots --noqa: TMP | ||
) | ||
pattern = '.*userprofilesnapshots/snapshot_date=.*/.*'; |