The date range pattern is used to extract a subset of the source data based on a date range. The end of the date range is the current batch execution date. The start of the date range is a number of days prior to the current batch effective date. Each time the ETL runs, the current batch effective date, for that batch execution, is set to midnight of the prior day. The date range ‘window’ moves forward a day as the current batch effective date changes.
The quickest way to define the columns of the Staging table is to import the column definitions from a Source table. If there isn’t a matching Source table, then you can manually define the columns. To import a Source table do the following:
On the Advanced tab, you will be presented with additional properties for the staging table. These properties are based on the target technology for the data warehouse. In this case, the target technology is Azure Data Warehouse, so you are presented with a DISTRIBUTION option with a default.
The Source tab defines the source table or query of the Extract.
The number of days of data to extract is specified by a custom metadata tag called ‘DIL_Extract_Period_Days’ added to the tags table on the advanced tab of the Extract dialog.
Your result should look like this:
You must also tag one source column as the Date attribute that contains the date that is used to filter the data in the source based on the date range. To identify this source column, edit it through the Mapping tab of the Extract dialog and add a tag named ‘DIL_Date_Attribute’.
Your result should look like this.
When Dimodelo Data Warehouse Studio generates the source query in the Shift data flow, it generates it like this:
SELECT [TaskId]
,[TaskName]
,[TaskDescription]
,[TaskEstimateMinutes]
,[TaskTypeCode]
,[ServiceId]
,[ScheduledDate]
,NULL AS [Reject_Ind]
FROM
[dbo].[Task] with (noLock) WHERE CONVERT(datetime,[ScheduledDate],112) >= ?
Where ScheduledDate is the selected DIL_Date_Attribute.
Then the package calculates the first date of the range as:
DATEADD(“dd”, -21, @[User::Current_Batch_Effective_Date] )
Where 21 is the DIL_Extract_Period_Days. So for example, if the current effective date was 2020-01-21, then the resulting date would be 2019-12-31.
Dimodelo Data Warehouse Studio then substitutes the resulting date for the question mark in the query.
All data where the scheduledDate >= 2019-12-31 is extracted.