Skip to content

Commit 5110e10

Browse files
committed
Reinit templates
1 parent bd78da9 commit 5110e10

File tree

3 files changed

+115
-2
lines changed

3 files changed

+115
-2
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{{#each dataObjectMappings}}
2+
{{#if enabled}}
3+
--
4+
-- Satellite Reinitialisation logic for [{{#each targetDataObject.dataObjectConnection.extensions}}{{#stringcompare key schema}}{{value}}{{/stringcompare}}{{/each}}].[{{targetDataObject.name}}]
5+
--
6+
7+
-- Truncate the source for the Satellite, the Staging Area table.
8+
TRUNCATE TABLE [{{#each sourceDataObjects.0.dataObjectConnection.extensions}}{{#stringcompare key schema}}{{value}}{{/stringcompare}}{{/each}}].[{{sourceDataObjects.0.name}}]
9+
10+
-- Copy the data from the Staging Area to the PSA.
11+
INSERT INTO STG.{{sourceDataObjects.0.name}}
12+
(
13+
[OMD_INSERT_MODULE_INSTANCE_ID]
14+
,[OMD_FILE_LOCATION]
15+
,[OMD_EVENT_DATETIME]
16+
,[OMD_INSERT_DATETIME]
17+
,[OMD_HASH_DIFF]
18+
,[OMD_CURRENT_RECORD_INDICATOR]
19+
,[OMD_DELETED_RECORD_INDICATOR]
20+
,[OMD_EXPIRY_DATETIME]
21+
,[OMD_RECORD_SOURCE_ID]
22+
,[OMD_SOURCE_ROW_ID]
23+
{{#each dataItemMappings}}
24+
,[{{sourceDataItems.0.name}}]
25+
{{/each}}
26+
)
27+
SELECT
28+
[OMD_INSERT_MODULE_INSTANCE_ID]
29+
,[OMD_FILE_LOCATION]
30+
,[OMD_EVENT_DATETIME]
31+
,[OMD_EFFECTIVE_DATETIME]
32+
,[OMD_HASH_DIFF]
33+
,[OMD_CURRENT_RECORD_INDICATOR]
34+
,[OMD_DELETED_RECORD_INDICATOR]
35+
,[OMD_EXPIRY_DATETIME]
36+
,[OMD_RECORD_SOURCE_ID]
37+
,[OMD_SOURCE_ROW_ID]
38+
{{#each dataItemMappings}}
39+
,[{{sourceDataItems.0.name}}]
40+
{{/each}}
41+
FROM PSA.{{StringReplace sourceDataObjects.0.name "STG" "PSA"}}
42+
43+
-- Truncate the Satellite table.
44+
TRUNCATE TABLE [{{#each targetDataObject.dataObjectConnection.extensions}}{{#stringcompare key schema}}{{value}}{{/stringcompare}}{{/each}}].[{{targetDataObject.name}}];
45+
46+
-- Rerun the Satellite loading procedure.
47+
EXEC [INT].[SP_{{targetDataObject.name}}] 0;
48+
49+
{{/if}}{{/each}}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{{#each dataObjectMappings}}
2+
{{#if enabled}}
3+
--
4+
-- Satellite Reinitialisation logic for [{{#each targetDataObject.dataObjectConnection.extensions}}{{#stringcompare key schema}}{{value}}{{/stringcompare}}{{/each}}].[{{targetDataObject.name}}]
5+
--
6+
7+
-- Truncate the source for the Satellite, the Staging Area table.
8+
TRUNCATE TABLE [{{#each sourceDataObjects.0.dataObjectConnection.extensions}}{{#stringcompare key schema}}{{value}}{{/stringcompare}}{{/each}}].[{{sourceDataObjects.0.name}}]
9+
10+
-- Copy the data from the Staging Area to the PSA.
11+
INSERT INTO STG.{{sourceDataObjects.0.name}}
12+
(
13+
[OMD_INSERT_MODULE_INSTANCE_ID]
14+
,[OMD_FILE_LOCATION]
15+
,[OMD_EVENT_DATETIME]
16+
,[OMD_INSERT_DATETIME]
17+
,[OMD_HASH_DIFF]
18+
,[OMD_CURRENT_RECORD_INDICATOR]
19+
,[OMD_DELETED_RECORD_INDICATOR]
20+
,[OMD_EXPIRY_DATETIME]
21+
,[OMD_RECORD_SOURCE_ID]
22+
,[OMD_SOURCE_ROW_ID]
23+
{{#each dataItemMappings}}
24+
,[{{sourceDataItems.0.name}}]
25+
{{/each}}
26+
)
27+
SELECT
28+
[OMD_INSERT_MODULE_INSTANCE_ID]
29+
,[OMD_FILE_LOCATION]
30+
,[OMD_EVENT_DATETIME]
31+
,[OMD_EFFECTIVE_DATETIME]
32+
,[OMD_HASH_DIFF]
33+
,[OMD_CURRENT_RECORD_INDICATOR]
34+
,[OMD_DELETED_RECORD_INDICATOR]
35+
,[OMD_EXPIRY_DATETIME]
36+
,[OMD_RECORD_SOURCE_ID]
37+
,[OMD_SOURCE_ROW_ID]
38+
{{#each dataItemMappings}}
39+
,[{{sourceDataItems.0.name}}]
40+
{{/each}}
41+
FROM PSA.{{StringReplace sourceDataObjects.0.name "STG" "PSA"}}
42+
43+
-- Truncate the Satellite table.
44+
TRUNCATE TABLE [{{#each targetDataObject.dataObjectConnection.extensions}}{{#stringcompare key schema}}{{value}}{{/stringcompare}}{{/each}}].[{{targetDataObject.name}}];
45+
46+
-- Rerun the Satellite loading procedure.
47+
EXEC [SP_{{targetDataObject.name}}] 0;
48+
{{/if}}{{/each}}

Virtual_EDW/Templates/templateCollection.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"TemplateOutputFileConvention": "{targetDataObject.name}.sql",
3939
"TemplateFilePath": "templateLinkSatelliteView.handlebars",
4040
"TemplateNotes": ""
41-
},
41+
},
4242
{
4343
"TemplateName": "100 Data Vault Satellite View Template",
4444
"TemplateType": "Context",
@@ -358,7 +358,23 @@
358358
"TemplateOutputFileConvention": "{targetDataObject.name}_SelectView.sql",
359359
"TemplateFilePath": "templateLandingtoSilverFromView.handlebars",
360360
"TemplateNotes": "Azure Databricks insert into Staging Area. This template generates the select column list command from the view which is created from dataframe."
361-
},
361+
},
362+
{
363+
"TemplateName": "500 Data Vault Satellite Reinitialisation Template",
364+
"TemplateType": "Context",
365+
"TemplateConnectionKey": "PsaConnectionInternalId",
366+
"TemplateOutputFileConvention": "{targetDataObject.name}_reinitialise.sql",
367+
"TemplateFilePath": "loadPatternSatelliteReinitialisation.handlebars",
368+
"TemplateNotes": ""
369+
},
370+
{
371+
"TemplateName": "500 Data Vault Link-Satellite Reinitialisation Template",
372+
"TemplateType": "NaturalBusinessRelationshipContext",
373+
"TemplateConnectionKey": "PsaConnectionInternalId",
374+
"TemplateOutputFileConvention": "{targetDataObject.name}_reinitialise.sql",
375+
"TemplateFilePath": "loadPatternLinkSatelliteReinitialisation.handlebars",
376+
"TemplateNotes": ""
377+
},
362378
{
363379
"TemplateName": "900 Unit Test - Hub Key Null Check",
364380
"TemplateType": "CoreBusinessConcept",

0 commit comments

Comments
 (0)