You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"TemplateNotes": "Azure Databricks insert into Staging Area. This template generates the select column list command from the view which is created from dataframe."
361
-
},
362
-
{
363
-
"TemplateName": "500 Data Vault Satellite Reinitialisation Template",
"TemplateNotes": "This template expects a full copy of incoming data to be placed in a landing area, and performs a full outer join to detects data changes."
LEFT OUTER JOIN {{../../../metadataConfiguration.vdwSchemaName}}.{{name}}
54
-
ON TimeRanges.{{../../businessKeys.0.businessKeyComponentMapping.0.targetDataItem.name}} = {{../../../metadataConfiguration.vdwSchemaName}}.{{name}}.[{{../../businessKeys.0.businessKeyComponentMapping.0.targetDataItem.name}}]
55
-
AND {{../../../metadataConfiguration.vdwSchemaName}}.{{name}}.{{../../../metadataConfiguration.loadDateTimeAttribute}}<= TimeRanges.PIT_EFFECTIVE_DATETIME
56
-
AND {{../../../metadataConfiguration.vdwSchemaName}}.{{name}}.{{../../../metadataConfiguration.expiryDateTimeAttribute}} >= TimeRanges.PIT_EXPIRY_DATETIME
53
+
LEFT OUTER JOIN
54
+
(
55
+
SELECT
56
+
*,
57
+
LEAD ( {{../../../metadataConfiguration.loadDateTimeAttribute}},1,'9999-12-31') OVER
58
+
(
59
+
PARTITION BY {{#each../../businessKeys}}{{#eachbusinessKeyComponentMapping}}
ORDER BY [{{../../../metadataConfiguration.loadDateTimeAttribute}}], [{{../../../metadataConfiguration.sourceRowIdAttribute}}] ASC
62
+
) AS [{{../../../metadataConfiguration.expiryDateTimeAttribute}}]
63
+
FROM {{../../../metadataConfiguration.vdwSchemaName}}.{{name}}
64
+
) {{name}}_inline
65
+
ON TimeRanges.{{../../businessKeys.0.businessKeyComponentMapping.0.targetDataItem.name}} = {{name}}_inline.[{{../../businessKeys.0.businessKeyComponentMapping.0.targetDataItem.name}}]
66
+
AND {{name}}_inline.{{../../../metadataConfiguration.loadDateTimeAttribute}}<= TimeRanges.PIT_EFFECTIVE_DATETIME
67
+
AND {{name}}_inline.{{../../../metadataConfiguration.expiryDateTimeAttribute}} >= TimeRanges.PIT_EXPIRY_DATETIME
ON TimeRanges.{{../../businessKeys.0.businessKeyComponentMapping.0.targetDataItem.name}} = {{../../../metadataConfiguration.vdwSchemaName}}.{{name}}.[{{../../businessKeys.0.businessKeyComponentMapping.0.targetDataItem.name}}]
Copy file name to clipboardExpand all lines: Virtual_EDW/Templates/templateHubView.Handlebars
+4-6Lines changed: 4 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -5,11 +5,7 @@
5
5
-- The view shows the same data as would otherwise be the case if the table would be created and all data logistics processes run.
6
6
--
7
7
8
-
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[{{metadataConfiguration.vdwSchemaName}}].[{{generationSpecificMetadata.selectedDataObject.name}}]') AND type in (N'V'))
9
-
DROP VIEW [{{metadataConfiguration.vdwSchemaName}}].[{{generationSpecificMetadata.selectedDataObject.name}}]
10
-
GO
11
-
12
-
CREATE VIEW [{{metadataConfiguration.vdwSchemaName}}].[{{generationSpecificMetadata.selectedDataObject.name}}] AS
8
+
CREATE OR ALTER VIEW [{{metadataConfiguration.vdwSchemaName}}].[{{generationSpecificMetadata.selectedDataObject.name}}] AS
MIN({{../metadataConfiguration.loadDateTimeAttribute}}) AS {{../metadataConfiguration.loadDateTimeAttribute}}
36
+
MIN({{../../metadataConfiguration.loadDateTimeAttribute}}) AS {{../../metadataConfiguration.loadDateTimeAttribute}}
40
37
FROM [{{sourceDataObjects.0.dataObjectConnection.extensions.0.value}}].[{{sourceDataObjects.0.dataObjectConnection.extensions.1.value}}].[{{sourceDataObjects.0.name}}]
41
38
WHERE {{#eachbusinessKeys}}{{#eachbusinessKeyComponentMapping}}
42
39
{{sourceDataItems.0.name}} IS NOT NULL{{#unless@last}} AND{{/unless}}{{/each}}{{/each}}
CREATE OR ALTER PROCEDURE [{{targetDataObject.dataObjectConnection.extensions.1.value}}].[SP_{{targetDataObject.name}}]
3
+
AS
4
+
5
+
--
6
+
-- Insert Into statement for [{{targetDataObject.name}}] from [{{sourceDataObjects.0.dataObjectConnection.extensions.0.value}}].[{{sourceDataObjects.0.dataObjectConnection.extensions.1.value}}].[{{sourceDataObjects.0.name}}]
7
+
--
8
+
-- Create using '300 Presentation Daily Snapshot' template.
9
+
--
10
+
11
+
DECLARE @SnapshotEndDate DATE = GETUTCDATE();
12
+
DECLARE @SnapshotStartDate DATE = CONVERT(DATE,'2023-10-01'); -- A starting point.
13
+
DECLARE @CurrentSnapshotDate DATE = @SnapshotStartDate;
14
+
15
+
{{! -- Only apply this if the object is a procedure, as identified in the extension -- }}
PRINT 'The snapshots will be created from '+COALESCE(CONVERT(VARCHAR(100),@CurrentSnapshotDate),'<unknown>')+' up to '+CONVERT(VARCHAR(100),@SnapshotEndDate)+'.';
41
+
END
42
+
ELSE
43
+
BEGIN
44
+
PRINT 'The snapshots are up to date.';
45
+
GOTO EndOfProcess
46
+
END
47
+
48
+
WHILE @CurrentSnapshotDate<=@SnapShotEndDate
49
+
BEGIN
50
+
PRINT 'Working on '+CONVERT(VARCHAR(10),@CurrentSnapshotDate);
INSERT INTO [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}]
{{! -- Only apply this if the object is a function, as identified in the extension -- }}
84
+
{{#eachsourceDataObjects.0.extensions}}{{#stringcomparekeyobjectType}}{{#stringcomparevaluefunction}}FROM [{{../../../sourceDataObjects.0.dataObjectConnection.extensions.0.value}}].[{{../../../sourceDataObjects.0.dataObjectConnection.extensions.1.value}}].[{{../../../sourceDataObjects.0.name}}] (@CurrentSnapshotDate) bc
85
+
{{/stringcompare}}{{/stringcompare}}{{/each}}
86
+
87
+
SET @CurrentSnapshotDate = DATEADD(DAY,1,@CurrentSnapshotDate);
0 commit comments