Shiva
09/19/2024, 7:58 PM%flink.ssql(type=update)
INSERT INTO alarm_transitions_table
SELECT
i.*,
m.*,
CASE
WHEN i.power1 = true AND i.set_point > 0 AND i.temperature <> 0 AND i.temperature < i.set_point THEN 'heating'
WHEN i.power1 = true AND i.set_point > 0 AND i.temperature <> 0 AND i.temperature >= i.set_point AND ABS(i.temperature - i.set_point) <= 50 THEN 'reached'
WHEN i.power1 = true AND i.set_point > 0 AND i.temperature <> 0 AND i.temperature > i.set_point + 50 THEN 'deviated'
ELSE NULL
END AS grill_state
FROM
``rt-dev-wus2-glue-iotdatastream` i`
left JOIN
``rt-dev-wus2-glue-mobiledatastream` m`
ON i.device_id = m.id
But when referred online documents found out we can perform LEFT JOIN with Temporal Joins. And I modified my query to this -
%flink.ssql(type=update)
INSERT INTO alarm_transitions_table
SELECT
i.*,
m.*,
CASE
WHEN i.power1 = true AND i.set_point > 0 AND i.temperature <> 0 AND i.temperature < i.set_point THEN 'heating'
WHEN i.power1 = true AND i.set_point > 0 AND i.temperature <> 0 AND i.temperature >= i.set_point AND ABS(i.temperature - i.set_point) <= 50 THEN 'reached'
WHEN i.power1 = true AND i.set_point > 0 AND i.temperature <> 0 AND i.temperature > i.set_point + 50 THEN 'deviated'
ELSE NULL
END AS grill_state
FROM
``rt-dev-wus2-glue-iotdatastream` i`
`LEFT JOIN rt-dev-wus2-glue-mobiledatastream
FOR SYSTEM_TIME AS OF i.event_time AS m`
ON i.device_id = m.id;
For the updated query I am getting "Temporal table join currently only supports 'FOR SYSTEM_TIME AS OF' left table's time attribute field"
Can someone please give me a solution to this and LMK how to perform Temporal Join in Apache Flink SQL along with AWS Kinesis Data Stream?