Skip to content

Commit 37ae4f7

Browse files
authored
Merge pull request #114902 from sidramadoss/patch-72
Update sql-reference-data.md
2 parents 060328e + be19432 commit 37ae4f7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

articles/stream-analytics/sql-reference-data.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,16 @@ When using the delta query, [temporal tables in Azure SQL Database](../sql-datab
150150

151151
2. Author the delta query.
152152

153-
This query retrieves all of the rows in your SQL database that were inserted or deleted within a start time, **\@deltaStartTime**, and an end time **\@deltaEndTime**. The delta query must return the same columns as the snapshot query, as well as the column **_operation_**. This column defines if the row is inserted or deleted between **\@deltaStartTime** and **\@deltaEndTime**. The resulting rows are flagged as **1** if the records were inserted, or **2** if deleted.
153+
This query retrieves all of the rows in your SQL database that were inserted or deleted within a start time, **\@deltaStartTime**, and an end time **\@deltaEndTime**. The delta query must return the same columns as the snapshot query, as well as the column **_operation_**. This column defines if the row is inserted or deleted between **\@deltaStartTime** and **\@deltaEndTime**. The resulting rows are flagged as **1** if the records were inserted, or **2** if deleted. The query must also add **watermark** from the SQL Server side to ensure all the updates in the delta period are captured appropriately. Using delta query without **watermark** may result in incorrect reference dataset.
154154

155155
For records that were updated, the temporal table does bookkeeping by capturing an insertion and deletion operation. The Stream Analytics runtime will then apply the results of the delta query to the previous snapshot to keep the reference data up to date. An example of delta query is show below:
156156

157157
```SQL
158-
SELECT DeviceId, GroupDeviceId, Description, 1 as _operation_
158+
SELECT DeviceId, GroupDeviceId, Description, ValidFrom as watermark 1 as _operation_
159159
FROM dbo.DeviceTemporal
160160
WHERE ValidFrom BETWEEN @deltaStartTime AND @deltaEndTime -- records inserted
161161
UNION
162-
SELECT DeviceId, GroupDeviceId, Description, 2 as _operation_
162+
SELECT DeviceId, GroupDeviceId, Description, ValidTo as watermark 2 as _operation_
163163
FROM dbo.DeviceHistory -- table we created in step 1
164164
WHERE ValidTo BETWEEN @deltaStartTime AND @deltaEndTime -- record deleted
165165
```

0 commit comments

Comments
 (0)