Skip to content

Commit 0fdec03

Browse files
committed
Sample updates
1 parent 6093b3f commit 0fdec03

4 files changed

+56
-50
lines changed

Virtual_EDW/Templates/templateLinkSatelliteDrivingKeyInsertInto.Handlebars

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
{{#each dataObjectMappings}}{{#if @first}}
22
--
3-
-- Link Satellite Insert Into statement for {{targetDataObject.name}}
3+
-- Link-Satellite Insert Into statement for {{targetDataObject.name}}.
4+
--
5+
-- This template inserts the data delta that has been detected into the landing area table.
46
--
57

6-
INSERT INTO [{{targetDataObject.name}}]
8+
INSERT INTO [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}]
79
( {{#each businessKeys}}{{#if @first}}
810
[{{surrogateKey}}],{{/if}}{{/each}}
911
{{#each dataItemMappings}}
1012
[{{targetDataItem.name}}],
1113
{{/each}}
12-
[{{../metadataConfiguration.etlProcessAttribute}}],
1314
[{{../metadataConfiguration.loadDateTimeAttribute}}],
14-
[{{../metadataConfiguration.recordSourceAttribute}}],
15-
[{{../metadataConfiguration.changeDataCaptureAttribute}}],
1615
[{{../metadataConfiguration.sourceRowIdAttribute}}],
16+
[{{../metadataConfiguration.changeDataCaptureAttribute}}],
17+
[{{../metadataConfiguration.etlProcessAttribute}}],
1718
[{{../metadataConfiguration.recordChecksumAttribute}}]
1819
)
1920
SELECT {{#each businessKeys}}{{#if @first}}
2021
sat_view.[{{surrogateKey}}],{{/if}}{{/each}}
2122
{{#each dataItemMappings}}
2223
sat_view.[{{targetDataItem.name}}],
2324
{{/each}}
24-
-1 AS [{{../metadataConfiguration.etlProcessAttribute}}],
2525
sat_view.[{{../metadataConfiguration.loadDateTimeAttribute}}],
26-
sat_view.[{{../metadataConfiguration.recordSourceAttribute}}],
27-
sat_view.[{{../metadataConfiguration.changeDataCaptureAttribute}}],
2826
sat_view.[{{../metadataConfiguration.sourceRowIdAttribute}}],
27+
sat_view.[{{../metadataConfiguration.changeDataCaptureAttribute}}],
28+
-1 AS [{{../metadataConfiguration.etlProcessAttribute}}],
2929
sat_view.[{{../metadataConfiguration.recordChecksumAttribute}}]
3030
FROM [{{../metadataConfiguration.vdwSchemaName}}].[{{targetDataObject.name}}] sat_view
3131
LEFT OUTER JOIN [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}] sat_table

Virtual_EDW/Templates/templateLinkSatelliteDrivingKeyView.Handlebars

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,80 +12,86 @@ SELECT
1212
HASHBYTES('MD5', {{#each businessKeys}}{{#unless @first}} +{{/unless}}{{!-- Create the Surrogate Key using the Business Key and components --}}{{#each businessKeyComponentMapping}}
1313
ISNULL(RTRIM(CONVERT(NVARCHAR(100), {{targetDataItem.name}})), 'N/A') + '#~!'{{#unless @last}} +{{/unless}}{{/each}}{{/each}}{{#each businessKeys}}{{#if @first}}
1414
) AS {{surrogateKey}},{{/if}}{{/each}}
15-
{{#each businessKeys}}{{#each BusinessKeyComponentMapping}}--{{targetDataItem.name}}{{#unless @last}},{{/unless}}
16-
{{/each}}{{/each}}DATEADD(mcs,[{{../metadataConfiguration.sourceRowIdAttribute}}], {{../metadataConfiguration.loadDateTimeAttribute}}) AS {{../metadataConfiguration.loadDateTimeAttribute}},
17-
COALESCE (
18-
LEAD (DATEADD(mcs,[{{../metadataConfiguration.sourceRowIdAttribute}}], {{../metadataConfiguration.loadDateTimeAttribute}}) ) OVER
19-
( PARTITION BY
20-
{{#each businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringcompare dataItemClassification.0.classification "DrivingKey"}}{{../../targetDataItem.name}}{{#unless @last}},{{/unless}}{{/stringcompare}}{{/each}}{{/each}}{{/each}}
21-
ORDER BY {{../metadataConfiguration.loadDateTimeAttribute}}),
22-
CAST( '9999-12-31' AS DATETIME)
23-
) AS LOAD_END_DATETIME,
24-
CASE
25-
WHEN ( LEAD ({{../metadataConfiguration.loadDateTimeAttribute}}) OVER (PARTITION BY {{#each businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringcompare dataItemClassification.0.classification "DrivingKey"}}{{../../targetDataItem.name}}{{#unless @last}},{{/unless}}{{/stringcompare}}{{/each}}{{/each}}{{/each}}
26-
ORDER BY {{../metadataConfiguration.loadDateTimeAttribute}})) IS NULL
27-
THEN 'Y'
28-
ELSE 'N'
29-
END AS CURRENT_RECORD_INDICATOR,
30-
-1 AS {{../metadataConfiguration.etlProcessAttribute}}, {{!-- List out the ETL Framework attributes --}}
15+
{{#each businessKeys}}{{#each BusinessKeyComponentMapping}}--[{{targetDataItem.name}}]{{#unless @last}},{{/unless}}{{/each}}
16+
{{/each}}
17+
[{{../metadataConfiguration.loadDateTimeAttribute}}],
18+
[{{../metadataConfiguration.sourceRowIdAttribute}}],
19+
--COALESCE (
20+
-- LEAD (DATEADD(mcs,[{{../metadataConfiguration.sourceRowIdAttribute}}], {{../metadataConfiguration.loadDateTimeAttribute}}) ) OVER
21+
-- ( PARTITION BY
22+
-- {{#each businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringcompare dataItemClassification.0.classification "DrivingKey"}}{{../../targetDataItem.name}}{{#unless @last}},{{/unless}}{{/stringcompare}}{{/each}}{{/each}}{{/each}}
23+
-- ORDER BY {{../metadataConfiguration.loadDateTimeAttribute}}),
24+
-- CAST( '9999-12-31' AS DATETIME)
25+
--) AS [{{../metadataConfiguration.expiryDateTimeAttribute}}],
26+
--CASE
27+
-- WHEN ( LEAD ({{../metadataConfiguration.loadDateTimeAttribute}}) OVER (PARTITION BY {{#each businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringcompare dataItemClassification.0.classification "DrivingKey"}}{{../../targetDataItem.name}}{{#unless @last}},{{/unless}}{{/stringcompare}}{{/each}}{{/each}}{{/each}}
28+
-- ORDER BY {{../metadataConfiguration.loadDateTimeAttribute}})) IS NULL
29+
-- THEN 'Y'
30+
-- ELSE 'N'
31+
--END AS CURRENT_RECORD_INDICATOR,
32+
-1 AS {{../metadataConfiguration.etlProcessAttribute}}, {{!-- List out the Control Framework attributes --}}
3133
{{../metadataConfiguration.changeDataCaptureAttribute}},
32-
{{../metadataConfiguration.sourceRowIdAttribute}},
33-
{{../metadataConfiguration.recordSourceAttribute}},
34-
CASE
35-
WHEN {{../metadataConfiguration.changeDataCaptureAttribute}} = 'Delete' THEN 'Y'
36-
ELSE 'N'
37-
END AS [DELETED_RECORD_INDICATOR],
34+
--CASE
35+
-- WHEN {{../metadataConfiguration.changeDataCaptureAttribute}} = 'D' THEN 'Y'
36+
-- ELSE 'N'
37+
--END AS [DELETED_RECORD_INDICATOR],
3838
HASHBYTES('MD5',
3939
ISNULL(RTRIM(CONVERT(NVARCHAR(100),{{../metadataConfiguration.changeDataCaptureAttribute}})), 'N/A') + '#~!' +
4040
{{#each businessKeys}}{{#each BusinessKeyComponentMapping}}ISNULL(RTRIM(CONVERT(NVARCHAR(100),{{targetDataItem.name}})), 'N/A') + '#~!'{{#unless @last}} +{{/unless}}
41-
{{/each}}{{/each}}) AS {{../metadataConfiguration.recordChecksumAttribute}},
41+
{{/each}}{{/each}}) AS [{{../metadataConfiguration.recordChecksumAttribute}}],
42+
{{#each dataItemMappings}}
43+
[{{targetDataItem.name}}],
44+
{{/each}}
4245
CAST (
4346
ROW_NUMBER() OVER (PARTITION BY {{#each businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringcompare dataItemClassification.0.classification "DrivingKey"}}{{../../targetDataItem.name}}{{#unless @last}},{{/unless}}{{/stringcompare}}{{/each}}{{/each}}{{/each}}
4447
ORDER BY {{#each businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringcompare dataItemClassification.0.classification "DrivingKey"}}{{../../targetDataItem.name}}{{#unless @last}},{{/unless}}{{/stringcompare}}{{/each}}{{/each}}{{/each}}, {{../metadataConfiguration.loadDateTimeAttribute}}
4548
) AS INT)
46-
AS ROW_NUMBER
49+
AS [ROW_NUMBER]
4750
FROM
4851
(
4952
SELECT
5053
[{{../metadataConfiguration.loadDateTimeAttribute}}],
51-
[{{../metadataConfiguration.eventDateTimeAttribute}}],
52-
[{{../metadataConfiguration.recordSourceAttribute}}],
5354
[{{../metadataConfiguration.sourceRowIdAttribute}}],
55+
[{{../metadataConfiguration.eventDateTimeAttribute}}],
5456
[{{../metadataConfiguration.changeDataCaptureAttribute}}],{{#each businessKeys}}{{#each businessKeyComponentMapping}}
5557
[{{sourceDataItems.0.name}}] AS [{{targetDataItem.name}}],{{/each}}{{/each}}
56-
{{#each businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringdiff dataItemClassification.0.classification "DrivingKey"}}LAG ([{{../name}}], 1, '0') OVER (
58+
{{#each dataItemMappings}}
59+
[{{sourceDataItems.0.name}}] AS [{{targetDataItem.name}}],
60+
{{/each}}
61+
{{#each businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringdiff dataItemClassification.0.classification "DrivingKey"}}LAG ([{{../name}}], 1, '0') OVER (
5762
PARTITION BY {{#each ../../../../businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringcompare dataItemClassification.0.classification "DrivingKey"}}{{name}}{{#unless @last}},{{/unless}}{{/stringcompare}}{{/each}}{{/each}}{{/each}}
5863
ORDER BY [{{../../../../../metadataConfiguration.loadDateTimeAttribute}}]
5964
) AS PREVIOUS_FOLLOWER_KEY{{@index}} {{/stringdiff}}{{/each}}{{/each}}{{/each}}
6065
FROM [{{sourceDataObjects.0.dataObjectConnection.extensions.1.value}}].[{{sourceDataObjects.0.name}}]
6166
WHERE NOT
62-
([{{../metadataConfiguration.sourceRowIdAttribute}}]>1 AND [{{../metadataConfiguration.changeDataCaptureAttribute}}] ='Delete')
67+
([{{../metadataConfiguration.sourceRowIdAttribute}}]>1 AND [{{../metadataConfiguration.changeDataCaptureAttribute}}] ='D')
6368
{{#if filterCriterion}}AND {{filterCriterion}} {{/if}}
69+
/* -- Dummy record only for example purposes.
6470
UNION
6571
SELECT
6672
[{{../metadataConfiguration.loadDateTimeAttribute}}],
67-
[{{../metadataConfiguration.eventDateTimeAttribute}}],
68-
[{{../metadataConfiguration.recordSourceAttribute}}],
6973
[{{../metadataConfiguration.sourceRowIdAttribute}}],
74+
[{{../metadataConfiguration.eventDateTimeAttribute}}],
7075
[{{../metadataConfiguration.changeDataCaptureAttribute}}],{{#each businessKeys}}{{#each businessKeyComponentMapping}}
7176
[{{targetDataItem.name}}],{{/each}}{{/each}}
7277
{{#each businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringdiff dataItemClassification.0.classification "DrivingKey"}}'{{@index}}' AS PREVIOUS_FOLLOWER_KEY{{@index}}{{/stringdiff}}{{/each}}{{/each}}{{/each}}
7378
FROM
7479
(
7580
SELECT
7681
'1900-01-01' AS [{{../metadataConfiguration.loadDateTimeAttribute}}],
82+
1 AS [{{../metadataConfiguration.sourceRowIdAttribute}}],
7783
'1900-01-01' AS [{{../metadataConfiguration.eventDateTimeAttribute}}],
78-
'Data Warehouse' AS [{{../metadataConfiguration.recordSourceAttribute}}],
79-
0 AS [{{../metadataConfiguration.sourceRowIdAttribute}}],
80-
'N/A' AS [{{../metadataConfiguration.changeDataCaptureAttribute}}],{{#each businessKeys}}
84+
--'Data Warehouse' AS [{{../metadataConfiguration.recordSourceAttribute}}],
85+
'C' AS [{{../metadataConfiguration.changeDataCaptureAttribute}}],{{#each businessKeys}}
8186
{{#each businessKeyComponentMapping}}[{{sourceDataItems.0.name}}] AS [{{targetDataItem.name}}],
8287
{{/each}}{{/each}}DENSE_RANK() OVER (
8388
PARTITION BY {{#each businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringcompare dataItemClassification.0.classification "DrivingKey"}}{{name}}{{#unless @last}},{{/unless}}{{/stringcompare}}{{/each}}{{/each}}{{/each}}
84-
ORDER BY [{{../metadataConfiguration.loadDateTimeAttribute}}], {{#each businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringcompare dataItemClassification.0.classification "DrivingKey"}}{{name}}{{#unless @last}},{{/unless}}{{/stringcompare}}{{/each}}{{/each}}{{/each}} ASC
89+
ORDER BY [{{../metadataConfiguration.loadDateTimeAttribute}}], [{{../metadataConfiguration.sourceRowIdAttribute}}], {{#each businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringcompare dataItemClassification.0.classification "DrivingKey"}}{{name}}{{#unless @last}},{{/unless}}{{/stringcompare}}{{/each}}{{/each}}{{/each}} ASC
8590
) AS ROWVERSION
8691
FROM [{{sourceDataObjects.0.dataObjectConnection.extensions.1.value}}].[{{sourceDataObjects.0.name}}]
8792
) dummysub
88-
WHERE ROWVERSION=1
93+
WHERE ROWVERSION=1
94+
*/
8995
) sub
9096
WHERE
9197
{{#each businessKeys}}{{#each BusinessKeyComponentMapping}}{{#each SourceDataItems}}{{#stringdiff dataItemClassification.0.classification "DrivingKey"}}{{../../targetDataItem.name}} != PREVIOUS_FOLLOWER_KEY{{@index}}{{/stringdiff}}{{/each}}{{/each}}{{/each}}

Virtual_EDW/Templates/templateLinkSatelliteInsertInto.Handlebars

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
{{#each dataObjectMappings}}{{#if @first}}
22
--
3-
-- Link Satellite Insert Into statement for {{targetDataObject.name}}
3+
-- Link-Satellite Insert Into statement for {{targetDataObject.name}}.
4+
--
5+
-- This template inserts the data delta that has been detected into the landing area table.
46
--
57

6-
INSERT INTO [{{targetDataObject.name}}]
8+
INSERT INTO [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}]
79
( {{#each businessKeys}}{{#if @first}}
810
[{{surrogateKey}}],{{/if}}{{/each}}
911
{{#each dataItemMappings}}
1012
[{{targetDataItem.name}}],
1113
{{/each}}
1214
[{{../metadataConfiguration.etlProcessAttribute}}],
1315
[{{../metadataConfiguration.loadDateTimeAttribute}}],
14-
[{{../metadataConfiguration.recordSourceAttribute}}],
15-
[{{../metadataConfiguration.changeDataCaptureAttribute}}],
1616
[{{../metadataConfiguration.sourceRowIdAttribute}}],
17+
[{{../metadataConfiguration.changeDataCaptureAttribute}}],
1718
[{{../metadataConfiguration.recordChecksumAttribute}}]
1819
)
1920
SELECT {{#each businessKeys}}{{#if @first}}
@@ -23,9 +24,8 @@ SELECT {{#each businessKeys}}{{#if @first}}
2324
{{/each}}
2425
-1 AS [{{../metadataConfiguration.etlProcessAttribute}}],
2526
sat_view.[{{../metadataConfiguration.loadDateTimeAttribute}}],
26-
sat_view.[{{../metadataConfiguration.recordSourceAttribute}}],
27-
sat_view.[{{../metadataConfiguration.changeDataCaptureAttribute}}],
2827
sat_view.[{{../metadataConfiguration.sourceRowIdAttribute}}],
28+
sat_view.[{{../metadataConfiguration.changeDataCaptureAttribute}}],
2929
sat_view.[{{../metadataConfiguration.recordChecksumAttribute}}]
3030
FROM [{{../metadataConfiguration.vdwSchemaName}}].[{{targetDataObject.name}}] sat_view
3131
LEFT OUTER JOIN [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}] sat_table

Virtual_EDW/Templates/templateSatelliteViewWithDeliveryKey.Handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SELECT
2929
-- {{#each dataItemMappings}}{{#each targetDataItem.dataItemClassification}}{{#if classification}},{{../sourceDataItems.0.name}}{{/if}}{{/each}}{{/each}}
3030
-- ORDER BY {{../metadataConfiguration.loadDateTimeAttribute}}),
3131
-- CAST( '9999-12-31' AS DATETIME)
32-
--) AS [{{../metadataConfiguration.expiryDateTimeAttribute}},
32+
--) AS [{{../metadataConfiguration.expiryDateTimeAttribute}}],
3333
--CASE
3434
-- WHEN ( RANK() OVER (PARTITION BY {{#each businessKeys}} {{#each businessKeyComponentMapping}}
3535
-- {{targetDataItem.name}}{{#unless @last}},{{/unless}}{{/each}}{{/each}}

0 commit comments

Comments
 (0)