Last active
April 26, 2022 11:39
-
-
Save vvgsrk/b6a6f3e14a168fee070e8feaad335694 to your computer and use it in GitHub Desktop.
Compiled version of src_product_management_product_latest_incremental.sql
This file contains hidden or 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
WITH ranked_data AS ( | |
SELECT | |
ROW_NUMBER() over ( | |
PARTITION BY product_id | |
ORDER BY | |
__event_ts DESC | |
) AS row_rank, | |
* | |
FROM dev_edw_dbt_incremental_model_test.dbt_src_product_management.src_product_management_product_history | |
) | |
SELECT | |
"PRODUCT_ID", | |
"PRODUCT_NAME", | |
"PRICE_PER_UNIT", | |
"BASIC_UNIT", | |
"IS_STOCK_LIMITED", | |
"IS_ACTIVE_FOR_SALE", | |
"__EVENT_TS", | |
"__LOAD_TS", | |
HASH( | |
product_id | |
) AS __uuid | |
FROM | |
ranked_data | |
WHERE | |
row_rank = 1 | |
ORDER BY __load_ts desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment