Skip to content

Commit

Permalink
update readme - warehouse spark etls
Browse files Browse the repository at this point in the history
  • Loading branch information
eslamdyab21 committed Feb 18, 2025
1 parent 677c33d commit df1ac9b
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1117,13 +1117,23 @@ WITH battery_info AS (
SELECT
timestamp,
CAST(SPLIT_PART(battery_name, '_', 2) AS INT) as battery_id,
TIMESTAMP(FLOOR(UNIX_MICROS(timestamp) / (15 * 60 * 1000000)) * (15 * 60)) AS timestamp_15min,
battery.battery_name,
battery.capacity_kwh,
battery.max_charge_speed_w,
battery.max_output_w
battery.max_output_w,
ROW_NUMBER() OVER (PARTITION BY TIMESTAMP(FLOOR(UNIX_MICROS(timestamp) / (15 * 60 * 1000000)) * (15 * 60)), battery_name ORDER BY timestamp DESC) AS row_num
FROM SolarX_Raw_Transactions.battery_readings battery
ORDER BY timestamp desc
LIMIT 3
),
battery_info AS (
SELECT * FROM (
SELECT * FROM battery_readings_15m
WHERE row_num = 1
ORDER BY timestamp_15min DESC
LIMIT 3
)
)

MERGE INTO SolarX_WH.dim_battery dim_battery
Expand All @@ -1147,13 +1157,23 @@ WITH battery_info AS (
SELECT
timestamp,
CAST(SPLIT_PART(battery_name, '_', 2) AS INT) as battery_id,
TIMESTAMP(FLOOR(UNIX_MICROS(timestamp) / (15 * 60 * 1000000)) * (15 * 60)) AS timestamp_15min,
battery.battery_name,
battery.capacity_kwh,
battery.max_charge_speed_w,
battery.max_output_w
battery.max_output_w,
ROW_NUMBER() OVER (PARTITION BY TIMESTAMP(FLOOR(UNIX_MICROS(timestamp) / (15 * 60 * 1000000)) * (15 * 60)), battery_name ORDER BY timestamp DESC) AS row_num
FROM SolarX_Raw_Transactions.battery_readings battery
ORDER BY timestamp desc
LIMIT 3
),
battery_info AS (
SELECT * FROM (
SELECT * FROM battery_readings_15m
WHERE row_num = 1
ORDER BY timestamp_15min DESC
LIMIT 3
)
)

MERGE INTO SolarX_WH.dim_battery dim_battery
Expand Down

0 comments on commit df1ac9b

Please sign in to comment.