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-29] Initialize dynamic table: verificationsubmission_latest #83

Merged
merged 8 commits into from
Nov 14, 2024
Merged
Changes from 7 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
jaymedina marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use schema {{database_name}}.synapse; --noqa: JJ01,PRS,TMP,CP01

CREATE DYNAMIC TABLE IF NOT EXISTS VERIFICATIONSUBMISSION_LATEST
TARGET_LAG = '1 day'
WAREHOUSE = compute_xsmall
AS
-- We deduplicate simply by selecting the latest record for each
-- verification submission ID...
WITH latest_unique_rows AS (
SELECT
verificationsubmissionsnapshots.*,
FROM
{{database_name}}.synapse_raw.verificationsubmissionsnapshots --noqa: TMP
QUALIFY ROW_NUMBER() OVER (
PARTITION BY id
ORDER BY change_timestamp DESC, snapshot_timestamp DESC
) = 1
jaymedina marked this conversation as resolved.
Show resolved Hide resolved
)
SELECT
*
FROM
latest_unique_rows
ORDER BY
latest_unique_rows.id ASC;