Last active
June 24, 2022 00:07
-
-
Save jingningzhang1/2fb7801b6380b26d8ff7d1681933d4a3 to your computer and use it in GitHub Desktop.
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
-- DBTITLE 1,Perform Upserts - Device Data | |
MERGE INTO plotly_iot_dashboard.silver_sensors AS target | |
USING (SELECT Id::integer, | |
device_id::integer, | |
user_id::integer, | |
calories_burnt::decimal, | |
miles_walked::decimal, | |
num_steps::decimal, | |
timestamp::timestamp, | |
value::string | |
FROM plotly_iot_dashboard.bronze_sensors) AS source | |
ON source.Id = target.Id | |
AND source.user_id = target.user_id | |
AND source.device_id = target.device_id | |
WHEN MATCHED THEN UPDATE SET | |
target.calories_burnt = source.calories_burnt, | |
target.miles_walked = source.miles_walked, | |
target.num_steps = source.num_steps, | |
target.timestamp = source.timestamp | |
WHEN NOT MATCHED THEN INSERT *; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment