Skip to content

Commit 6757bca

Browse files
committed
Sample updates
1 parent e51191d commit 6757bca

9 files changed

+335
-334
lines changed

Virtual_EDW/Templates/templateCollection.json

Lines changed: 237 additions & 237 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
{{#each dataObjectMappings}}{{#if @first}}
22
--
33
-- Hub Insert Into statement for {{targetDataObject.name}}
4-
-- Generated at {{now}}
4+
--
5+
-- This template inserts the data delta that has been detected by comparing the Hub View to the existing Hub data into the target Hub table.
56
--
67

7-
INSERT INTO [{{targetDataObject.name}}]
8+
INSERT INTO [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}]
89
(
910
[{{#each businessKeys}}{{#if @first}}{{surrogateKey}}{{/if}}{{/each}}],{{#each businessKeys}}{{#if @first}}{{#each businessKeyComponentMapping}}
1011
[{{targetDataItem.name}}],{{/each}}{{/if}}{{/each}}
1112
[{{../metadataConfiguration.etlProcessAttribute}}],
12-
[{{../metadataConfiguration.loadDateTimeAttribute}}],
13-
[{{../metadataConfiguration.recordSourceAttribute}}]
13+
[{{../metadataConfiguration.loadDateTimeAttribute}}]
14+
--,[{{../metadataConfiguration.recordSourceAttribute}}]
1415
)
1516
SELECT
1617
hub_view.[{{#each businessKeys}}{{#if @first}}{{surrogateKey}}{{/if}}{{/each}}],{{#each businessKeys}}{{#if @first}}{{#each businessKeyComponentMapping}}
1718
hub_view.[{{targetDataItem.name}}],{{/each}}{{/if}}{{/each}}
1819
-1 AS [{{../metadataConfiguration.etlProcessAttribute}}],
19-
hub_view.[{{../metadataConfiguration.loadDateTimeAttribute}}],
20-
hub_view.[{{../metadataConfiguration.recordSourceAttribute}}]
21-
FROM [{{sourceDataObjects.0.dataObjectConnection.extensions.0.value}}].[{{../metadataConfiguration.vdwSchemaName}}].[{{targetDataObject.name}}] hub_view
22-
LEFT OUTER JOIN
23-
[{{targetDataObject.name}}] hub_table
20+
hub_view.[{{../metadataConfiguration.loadDateTimeAttribute}}]
21+
--,hub_view.[{{../metadataConfiguration.recordSourceAttribute}}]
22+
FROM [{{../metadataConfiguration.vdwSchemaName}}].[{{targetDataObject.name}}] hub_view
23+
LEFT OUTER JOIN [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}] hub_table
2424
ON hub_view.[{{#each businessKeys}}{{#if @first}}{{surrogateKey}}{{/if}}{{/each}}] = hub_table.[{{#each businessKeys}}{{#if @first}}{{surrogateKey}}{{/if}}{{/each}}]
2525
WHERE hub_table.[{{#each businessKeys}}{{#if @first}}{{surrogateKey}}{{/if}}{{/each}}] IS NULL
26-
{{/if}}{{/each}}
26+
{{/if}}
27+
28+
{{/each}}

Virtual_EDW/Templates/templateHubInsertIntoDirectWrapper.Handlebars

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
GO
33
--
44
-- Hub ETL procedure for {{targetDataObject.name}}, coming from {{sourceDataObjects.0.name}}
5-
-- Generated at {{now}}
65
--
76

87
CREATE OR ALTER PROCEDURE [usp_{{targetDataObject.name}}_{{sourceDataObjects.0.name}}]
@@ -75,7 +74,7 @@ BEGIN
7574
Main ETL block
7675
*/
7776

78-
INSERT INTO [{{targetDataObject.name}}]
77+
INSERT INTO [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}]
7978
(
8079
[{{#each businessKeys}}{{#if @first}}{{surrogateKey}}{{/if}}{{/each}}],{{#each businessKeys}}{{#if @first}}{{#each businessKeyComponentMapping}}
8180
[{{targetDataItem.name}}],{{/each}}{{/if}}{{/each}}
@@ -89,8 +88,8 @@ BEGIN
8988
@ModuleInstanceId AS [MODULE_INSTANCE_ID],
9089
hub_view.[{{../metadataConfiguration.loadDateTimeAttribute}}],
9190
hub_view.[{{../metadataConfiguration.recordSourceAttribute}}]
92-
FROM [{{sourceDataObjects.0.dataObjectConnection.extensions.0.value}}].[{{../metadataConfiguration.vdwSchemaName}}].[{{targetDataObject.name}}] hub_view
93-
LEFT OUTER JOIN [{{targetDataObject.name}}] hub_table
91+
FROM [{{../metadataConfiguration.vdwSchemaName}}].[{{targetDataObject.name}}] hub_view
92+
LEFT OUTER JOIN [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}] hub_table
9493
ON hub_view.[{{#each businessKeys}}{{#if @first}}{{surrogateKey}}{{/if}}{{/each}}] = hub_table.[{{#each businessKeys}}{{#if @first}}{{surrogateKey}}{{/if}}{{/each}}]
9594
WHERE hub_table.[{{#each businessKeys}}{{#if @first}}{{surrogateKey}}{{/if}}{{/each}}] IS NULL
9695

Virtual_EDW/Templates/templateLinkView.Handlebars

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
--
22
-- Link View definition for {{generationSpecificMetadata.selectedDataObject.name}}
3-
-- Generated at {{generationSpecificMetadata.generationDateTime}}
43
--
54

65
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[{{metadataConfiguration.vdwSchemaName}}].[{{generationSpecificMetadata.selectedDataObject.name}}]') AND type in (N'V'))
@@ -17,7 +16,7 @@ SELECT
1716
{{#each dataItemMappings}} + ISNULL(RTRIM(CONVERT(NVARCHAR(100), [{{targetDataItem.name}}])), 'N/A') + '#~!'{{/each}}{{#each businessKeys}} {{#if @first}} ) AS {{surrogateKey}},{{/if}}{{/each}}
1817
-1 AS {{../metadataConfiguration.etlProcessAttribute}}, {{!-- List out the ETL Framework attributes --}}
1918
MIN({{../metadataConfiguration.loadDateTimeAttribute}}) AS {{../metadataConfiguration.loadDateTimeAttribute}},
20-
{{../metadataConfiguration.recordSourceAttribute}},{{#each businessKeys}}{{#unless @first}} {{!-- List out the separate (Hub) business keys, by skipping the first generic relationship key. --}}
19+
{{#each businessKeys}}{{#unless @first}} {{!-- List out the separate (Hub) business keys, by skipping the first generic relationship key. --}}
2120
{{#unless businessKeyClassification}}HASHBYTES('MD5',
2221
{{#each businessKeyComponentMapping}}
2322
ISNULL(RTRIM(CONVERT(NVARCHAR(100), {{targetDataItem.name}}{{@../index }})), 'N/A') + '#~!'{{#unless @last}} +{{/unless}}{{/each}}
@@ -37,7 +36,6 @@ FROM
3736
SELECT {{#each businessKeys}} {{#unless @first}} {{#each businessKeyComponentMapping}}
3837
CAST({{sourceDataItems.0.name}} AS NVARCHAR(100)) AS {{targetDataItem.name}}{{@../index }},{{/each}}{{/unless}}{{/each}}{{#each dataItemMappings}}
3938
[{{sourceDataItems.0.name}}] AS [{{targetDataItem.name}}],{{/each}}
40-
{{../metadataConfiguration.recordSourceAttribute}},
4139
MIN({{../metadataConfiguration.loadDateTimeAttribute}}) AS {{../metadataConfiguration.loadDateTimeAttribute}}
4240
FROM [{{sourceDataObjects.0.dataObjectConnection.extensions.1.value}}].[{{sourceDataObjects.0.name}}]
4341
WHERE {{#each businessKeys}} {{#unless @first}} {{#each businessKeyComponentMapping}}
@@ -47,13 +45,14 @@ FROM
4745
{{/each}}
4846
{{#if filterCriterion}}AND {{filterCriterion}}{{/if}}
4947
GROUP BY
50-
{{#each businessKeys}}{{#each businessKeyComponentMapping}}{{#each sourceDataItems}}{{#stringcompare isHardCodedValue "True"}}{{else}}{{name}},{{/stringcompare}}{{/each}}{{/each}}{{/each}}{{#each dataItemMappings}}[{{sourceDataItems.0.name}}],{{/each}}
51-
{{../metadataConfiguration.recordSourceAttribute}}{{#unless @last}}UNION{{/unless}}
48+
{{#each businessKeys}}{{#each businessKeyComponentMapping}}{{#each sourceDataItems}}{{#stringcompare isHardCodedValue "True"}}{{else}}{{name}},{{/stringcompare}}{{/each}}{{/each}}{{/each}}
49+
{{#each dataItemMappings}}[{{sourceDataItems.0.name}}],{{/each}}
50+
51+
{{#unless @last}}UNION{{/unless}}
5252
) LINK_selection
5353
GROUP BY {{#each businessKeys}} {{#unless @first}} {{#each businessKeyComponentMapping}}
54-
{{targetDataItem.name}}{{@../index }}{{#unless @last}},{{/unless}}{{/each}},{{/unless}}{{/each}}
54+
{{targetDataItem.name}}{{@../index }}{{#unless @last}},{{/unless}}{{/each}}{{#unless @last}},{{/unless}}{{/unless}}{{/each}}
5555
{{#each dataItemMappings}}
56-
[{{targetDataItem.name}}],{{/each}}
57-
{{../metadataConfiguration.recordSourceAttribute}} {{/each}}
56+
[{{targetDataItem.name}}],{{/each}}{{/each}}
5857
) link
5958
WHERE ROW_NR = 1

Virtual_EDW/Templates/templateSatelliteInsertInto.Handlebars

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
--
33
-- Satellite Insert Into statement for {{targetDataObject.name}}
44
--
5+
-- This template inserts the data delta that has been detected by comparing the Satellite View to the existing data into the target Satellite table.
6+
--
57

6-
INSERT INTO [{{targetDataObject.name}}]
8+
INSERT INTO [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}]
79
( {{#each businessKeys}}
810
[{{surrogateKey}}],{{/each}}
911
{{#each dataItemMappings}}
@@ -27,8 +29,8 @@ SELECT {{#each businessKeys}}
2729
sat_view.[{{../metadataConfiguration.changeDataCaptureAttribute}}],
2830
sat_view.[{{../metadataConfiguration.sourceRowIdAttribute}}],
2931
sat_view.[{{../metadataConfiguration.recordChecksumAttribute}}]
30-
FROM [{{sourceDataObjects.0.dataObjectConnection.extensions.0.value}}].[{{../metadataConfiguration.vdwSchemaName}}].[{{targetDataObject.name}}] sat_view
31-
LEFT OUTER JOIN [{{targetDataObject.name}}] sat_table
32+
FROM [{{../metadataConfiguration.vdwSchemaName}}].[{{targetDataObject.name}}] sat_view
33+
LEFT OUTER JOIN [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}] sat_table
3234
ON sat_view.[{{#each businessKeys}}{{#if @first}}{{surrogateKey}}{{/if}}{{/each}}] = sat_table.[{{#each businessKeys}}{{#if @first}}{{surrogateKey}}{{/if}}{{/each}}]
3335
AND sat_view.[{{../metadataConfiguration.loadDateTimeAttribute}}] = sat_table.[{{../metadataConfiguration.loadDateTimeAttribute}}]
3436
{{#each dataItemMappings}}{{#each targetDataItem.dataItemClassification}}{{#if classification}}AND sat_view.{{../targetDataItem.name}} = sat_table.{{../targetDataItem.name}}{{/if}}{{/each}}{{/each}}

Virtual_EDW/Templates/templateSatelliteReferentialIntegrity.Handlebars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
--
33
-- Satellite Insert Referential Integrity check for {{targetDataObject.name}}
44
--
5+
-- By convention, the parent (referencing) data object is the first object in the related data object list.
6+
--
57

68
SELECT
79
COUNT(*) AS RI_ISSUES,

Virtual_EDW/Templates/templateSatelliteView.Handlebars

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ SELECT
1616
{{#each businessKeyComponentMapping}}
1717
ISNULL(RTRIM(CONVERT(NVARCHAR(100), {{targetDataItem.name}})), 'N/A') + '#~!'{{#unless @last}} +{{/unless}}
1818
{{/each}}
19-
) AS {{surrogateKey}},{{/each}}
20-
DATEADD(mcs,[{{../metadataConfiguration.sourceRowIdAttribute}}], {{../metadataConfiguration.loadDateTimeAttribute}}) AS {{../metadataConfiguration.loadDateTimeAttribute}},
19+
) AS [{{surrogateKey}}],{{/each}}
20+
--DATEADD(mcs,[{{../metadataConfiguration.sourceRowIdAttribute}}], {{../metadataConfiguration.loadDateTimeAttribute}}) AS {{../metadataConfiguration.loadDateTimeAttribute}},
21+
[{{../metadataConfiguration.loadDateTimeAttribute}}],
22+
[{{../metadataConfiguration.sourceRowIdAttribute}}],
2123
--COALESCE (
2224
-- LEAD (DATEADD(mcs,[{{../metadataConfiguration.sourceRowIdAttribute}}], {{../metadataConfiguration.loadDateTimeAttribute}}) ) OVER
2325
-- ( PARTITION BY {{#each businessKeys}}
@@ -34,30 +36,29 @@ SELECT
3436
-- ORDER BY {{../metadataConfiguration.loadDateTimeAttribute}} desc )) = 1
3537
-- THEN 'Y'
3638
-- ELSE 'N'
37-
--END AS CURRENT_RECORD_INDICATOR,
38-
-1 AS {{../metadataConfiguration.etlProcessAttribute}}, {{!-- List out the ETL Framework attributes --}}
39+
--END AS [CURRENT_RECORD_INDICATOR],
40+
-1 AS {{../metadataConfiguration.etlProcessAttribute}}, {{!-- List out the Control Framework attributes --}}
3941
{{../metadataConfiguration.changeDataCaptureAttribute}},
40-
{{../metadataConfiguration.sourceRowIdAttribute}},
4142
--{{../metadataConfiguration.recordSourceAttribute}},
4243
--CASE
4344
-- WHEN {{../metadataConfiguration.changeDataCaptureAttribute}} = 'D' THEN 'Y'
4445
-- ELSE 'N'
4546
--END AS [DELETED_RECORD_INDICATOR],
4647
HASHBYTES('MD5',
4748
ISNULL(RTRIM(CONVERT(NVARCHAR(100),{{../metadataConfiguration.changeDataCaptureAttribute}})), 'N/A') + '#~!' +{{#each dataItemMappings}}
48-
ISNULL(RTRIM(CONVERT(NVARCHAR(100),{{sourceDataItems.0.name}})), 'N/A') + '#~!'{{#unless @last}} +{{/unless}}{{/each}}
49-
) AS {{../metadataConfiguration.recordChecksumAttribute}},
49+
ISNULL(RTRIM(CONVERT(NVARCHAR(100),{{targetDataItem.name}})), 'N/A') + '#~!'{{#unless @last}} +{{/unless}}{{/each}}
50+
) AS [{{../metadataConfiguration.recordChecksumAttribute}}],
5051
{{#each dataItemMappings}}
51-
{{sourceDataItems.0.name}} AS {{targetDataItem.name}},
52+
[{{targetDataItem.name}}],
5253
{{/each}}
5354
ROW_NUMBER() OVER (PARTITION BY {{#each businessKeys}}{{#each businessKeyComponentMapping}} {{!-- Create a row number to enable selection only the earliest row, ordered by date/time --}}
5455
{{targetDataItem.name}}{{#unless @last}},{{/unless}}{{/each}}{{/each}}
55-
{{#each dataItemMappings}}{{#each targetDataItem.dataItemClassification}}{{#if classification}},{{../sourceDataItems.0.name}}{{/if}}{{/each}}{{/each}}
56+
{{#each dataItemMappings}}{{#each targetDataItem.dataItemClassification}}{{#if classification}},{{../targetDataItem.name}}{{/if}}{{/each}}{{/each}}
5657
ORDER BY {{#each businessKeys}}{{#each businessKeyComponentMapping}} {{!-- Create a row number to enable selection only the earliest row, ordered by date/time --}}
5758
{{targetDataItem.name}},{{/each}}{{/each}}
58-
{{#each dataItemMappings}}{{#each targetDataItem.dataItemClassification}}{{#if classification}}{{../sourceDataItems.0.name}},{{/if}}{{/each}}{{/each}}
59+
{{#each dataItemMappings}}{{#each targetDataItem.dataItemClassification}}{{#if classification}}{{../targetDataItem.name}},{{/if}}{{/each}}{{/each}}
5960
{{../metadataConfiguration.loadDateTimeAttribute}}
60-
) AS ROW_NUMBER
61+
) AS [ROW_NUMBER]
6162
FROM
6263
(
6364
SELECT
@@ -68,33 +69,33 @@ FROM
6869
[{{../metadataConfiguration.changeDataCaptureAttribute}}],{{#each businessKeys}}{{#each businessKeyComponentMapping}}
6970
{{targetDataItem.name}},{{/each}}{{/each}}
7071
{{#each dataItemMappings}}
71-
{{sourceDataItems.0.name}},
72+
{{targetDataItem.name}},
7273
{{/each}}
73-
COMBINED_VALUE,
74+
[COMBINED_VALUE],
7475
CASE
7576
WHEN LAG(COMBINED_VALUE,1,0x00000000000000000000000000000000) OVER (PARTITION BY {{#each businessKeys}} {{#each businessKeyComponentMapping}}
7677
{{targetDataItem.name}}{{#unless @last}},{{/unless}}{{/each}}{{/each}}
77-
{{#each dataItemMappings}}{{#each targetDataItem.dataItemClassification}}{{#if classification}},{{../sourceDataItems.0.name}}{{/if}}{{/each}}{{/each}}
78+
{{#each dataItemMappings}}{{#each targetDataItem.dataItemClassification}}{{#if classification}},{{../targetDataItem.name}}{{/if}}{{/each}}{{/each}}
7879
ORDER BY [{{../metadataConfiguration.loadDateTimeAttribute}}] ASC, [{{../metadataConfiguration.eventDateTimeAttribute}}] ASC, [{{../metadataConfiguration.changeDataCaptureAttribute}}] DESC) = COMBINED_VALUE
7980
THEN 'Same'
8081
ELSE 'Different'
81-
END AS VALUE_CHANGE_INDICATOR,
82+
END AS [VALUE_CHANGE_INDICATOR],
8283
CASE
8384
WHEN LAG([{{../metadataConfiguration.changeDataCaptureAttribute}}],1,'') OVER (PARTITION BY {{#each businessKeys}} {{#each businessKeyComponentMapping}}
8485
{{targetDataItem.name}}{{#unless @last}},{{/unless}}{{/each}}{{/each}}
85-
{{#each dataItemMappings}}{{#each targetDataItem.dataItemClassification}}{{#if classification}},{{../sourceDataItems.0.name}}{{/if}}{{/each}}{{/each}}
86+
{{#each dataItemMappings}}{{#each targetDataItem.dataItemClassification}}{{#if classification}},{{../targetDataItem.name}}{{/if}}{{/each}}{{/each}}
8687
ORDER BY [{{../metadataConfiguration.loadDateTimeAttribute}}] ASC, [{{../metadataConfiguration.eventDateTimeAttribute}}] ASC, [{{../metadataConfiguration.changeDataCaptureAttribute}}] ASC) = [{{../metadataConfiguration.changeDataCaptureAttribute}}]
8788
THEN 'Same'
8889
ELSE 'Different'
89-
END AS CDC_CHANGE_INDICATOR,
90+
END AS [CDC_CHANGE_INDICATOR],
9091
CASE
9192
WHEN LEAD([{{../metadataConfiguration.loadDateTimeAttribute}}],1,'9999-12-31') OVER (PARTITION BY {{#each businessKeys}} {{#each businessKeyComponentMapping}}
9293
{{targetDataItem.name}}{{#unless @last}},{{/unless}}{{/each}}{{/each}}
93-
{{#each dataItemMappings}}{{#each targetDataItem.dataItemClassification}}{{#if classification}},{{../sourceDataItems.0.name}}{{/if}}{{/each}}{{/each}}
94+
{{#each dataItemMappings}}{{#each targetDataItem.dataItemClassification}}{{#if classification}},{{../targetDataItem.name}}{{/if}}{{/each}}{{/each}}
9495
ORDER BY [{{../metadataConfiguration.loadDateTimeAttribute}}] ASC, [{{../metadataConfiguration.eventDateTimeAttribute}}] ASC, [{{../metadataConfiguration.changeDataCaptureAttribute}}] ASC) = [{{../metadataConfiguration.loadDateTimeAttribute}}]
9596
THEN 'Same'
9697
ELSE 'Different'
97-
END AS TIME_CHANGE_INDICATOR
98+
END AS [TIME_CHANGE_INDICATOR]
9899
FROM
99100
(
100101
SELECT
@@ -105,17 +106,17 @@ FROM
105106
[{{../metadataConfiguration.changeDataCaptureAttribute}}],{{#each businessKeys}} {{#each businessKeyComponentMapping}}
106107
CAST ({{sourceDataItems.0.name}} AS NVARCHAR(100)) AS [{{targetDataItem.name}}],{{/each}}{{/each}}
107108
{{#each dataItemMappings}}
108-
[{{sourceDataItems.0.name}}],
109+
[{{sourceDataItems.0.name}}] AS [{{targetDataItem.name}}],
109110
{{/each}}
110111
HASHBYTES('MD5',{{#each dataItemMappings}}
111112
ISNULL(RTRIM(CONVERT(NVARCHAR(100),{{sourceDataItems.0.name}})), 'N/A') + '#~!'{{#unless @last}} +{{/unless}}{{/each}}
112-
) AS COMBINED_VALUE
113+
) AS [COMBINED_VALUE]
113114
FROM [{{sourceDataObjects.0.dataObjectConnection.extensions.0.value}}].[{{sourceDataObjects.0.dataObjectConnection.extensions.1.value}}].[{{sourceDataObjects.0.name}}]
114115
{{#if filterCriterion}}WHERE {{filterCriterion}} {{/if}}
115116
) sub
116117
) combined_value
117118
WHERE
118-
( VALUE_CHANGE_INDICATOR ='Different' and [{{../metadataConfiguration.changeDataCaptureAttribute}}] in ('C'))
119+
( [VALUE_CHANGE_INDICATOR] ='Different' and [{{../metadataConfiguration.changeDataCaptureAttribute}}] in ('C'))
119120
OR
120-
( CDC_CHANGE_INDICATOR = 'Different' and TIME_CHANGE_INDICATOR = 'Different')
121+
( [CDC_CHANGE_INDICATOR] = 'Different' and [TIME_CHANGE_INDICATOR] = 'Different')
121122
{{/each}}

0 commit comments

Comments
 (0)