DoNotProcess & Lower/Upper Boundary
This commit is contained in:
parent
f5493e9a17
commit
41face83fe
@ -7,7 +7,7 @@ namespace AsPartitionProcessing.SampleClient
|
||||
{
|
||||
class Program
|
||||
{
|
||||
const bool UseDatabase = true;
|
||||
const bool UseDatabase = false;
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
@ -43,6 +43,7 @@ namespace AsPartitionProcessing
|
||||
,[SourceTableName]
|
||||
,[SourcePartitionColumn]
|
||||
FROM [dbo].[vPartitioningConfiguration]
|
||||
WHERE [DoNotProcess] = 0
|
||||
ORDER BY
|
||||
[ModelConfigurationID],
|
||||
[TableConfigurationID],
|
||||
|
@ -28,10 +28,20 @@ namespace AsPartitionProcessing
|
||||
public int NumberOfPartitionsForIncrementalProcess { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The maximum date that needs to be accounted for in the partitioned table. Represents the upper boundary of the rolling window.
|
||||
/// The maximum date that needs to be accounted for in the partitioned table.
|
||||
/// </summary>
|
||||
public DateTime MaxDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Lower boundary for date range covered by partitioning configuration.
|
||||
/// </summary>
|
||||
public DateTime LowerBoundary { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Upper boundary for date range covered by partitioning configuration.
|
||||
/// </summary>
|
||||
public DateTime UpperBoundary { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the source table in the relational database.
|
||||
/// </summary>
|
||||
@ -70,6 +80,28 @@ namespace AsPartitionProcessing
|
||||
MaxDate = maxDate;
|
||||
SourceTableName = sourceTableName;
|
||||
SourcePartitionColumn = sourcePartitionColumn;
|
||||
|
||||
switch (granularity)
|
||||
{
|
||||
case Granularity.Daily:
|
||||
LowerBoundary = maxDate.AddDays(-numberOfPartitionsFull + 1);
|
||||
UpperBoundary = maxDate;
|
||||
break;
|
||||
|
||||
case Granularity.Monthly:
|
||||
LowerBoundary = Convert.ToDateTime(maxDate.AddMonths(-numberOfPartitionsFull + 1).ToString("yyyy-MMM-01"));
|
||||
UpperBoundary = Convert.ToDateTime(maxDate.AddMonths(1).ToString("yyyy-MMM-01")).AddDays(-1);
|
||||
break;
|
||||
|
||||
case Granularity.Yearly:
|
||||
LowerBoundary = Convert.ToDateTime(maxDate.AddYears(-numberOfPartitionsFull + 1).ToString("yyyy-01-01"));
|
||||
UpperBoundary = Convert.ToDateTime(maxDate.AddYears(1).ToString("yyyy-01-01")).AddDays(-1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@ CREATE TABLE [dbo].[PartitioningConfiguration](
|
||||
[NumberOfPartitionsFull] [int] NOT NULL,
|
||||
[NumberOfPartitionsForIncrementalProcess] [int] NOT NULL,
|
||||
[MaxDate] [date] NOT NULL,
|
||||
[MinDate] AS (case when [Granularity]=(0) then dateadd(day,( -[NumberOfPartitionsFull])+(1),[MaxDate]) when [Granularity]=(1) then CONVERT([date],format(dateadd(month,( -[NumberOfPartitionsFull])+(1),[MaxDate]),'yyyy-MMM-01')) when [Granularity]=(2) then CONVERT([date],format(dateadd(year,( -[NumberOfPartitionsFull])+(1),[MaxDate]),'yyyy-01-01')) else [MaxDate] end),
|
||||
[SourceTableName] [varchar](255) NOT NULL,
|
||||
[SourcePartitionColumn] [varchar](255) NOT NULL,
|
||||
CONSTRAINT [PK_PartitioningConfiguration] PRIMARY KEY CLUSTERED
|
||||
@ -52,6 +51,7 @@ CREATE TABLE [dbo].[TableConfiguration](
|
||||
[TableConfigurationID] [int] NOT NULL,
|
||||
[ModelConfigurationID] [int] NOT NULL,
|
||||
[AnalysisServicesTable] [varchar](255) NOT NULL,
|
||||
[DoNotProcess] [bit] NOT NULL,
|
||||
CONSTRAINT [PK_TableConfiguration] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[TableConfigurationID] ASC
|
||||
@ -73,6 +73,9 @@ GO
|
||||
ALTER TABLE [dbo].[ProcessingLog] CHECK CONSTRAINT [FK_ProcessingLog_ModelConfiguration]
|
||||
GO
|
||||
|
||||
ALTER TABLE [dbo].[TableConfiguration] ADD CONSTRAINT [DF_TableConfiguration_DoNotProcess] DEFAULT ((0)) FOR [DoNotProcess]
|
||||
GO
|
||||
|
||||
ALTER TABLE [dbo].[TableConfiguration] WITH CHECK ADD CONSTRAINT [FK_TableConfiguration_ModelConfiguration] FOREIGN KEY([ModelConfigurationID])
|
||||
REFERENCES [dbo].[ModelConfiguration] ([ModelConfigurationID])
|
||||
GO
|
||||
@ -94,7 +97,6 @@ GO
|
||||
|
||||
|
||||
|
||||
|
||||
CREATE VIEW [dbo].[vPartitioningConfiguration]
|
||||
AS
|
||||
SELECT m.[ModelConfigurationID]
|
||||
@ -106,6 +108,7 @@ SELECT m.[ModelConfigurationID]
|
||||
,m.[IntegratedAuth]
|
||||
,t.[TableConfigurationID]
|
||||
,t.[AnalysisServicesTable]
|
||||
,t.[DoNotProcess]
|
||||
,CASE
|
||||
WHEN p.[TableConfigurationID] IS NULL THEN 0
|
||||
ELSE 1
|
||||
@ -115,7 +118,6 @@ SELECT m.[ModelConfigurationID]
|
||||
,p.[NumberOfPartitionsFull]
|
||||
,p.[NumberOfPartitionsForIncrementalProcess]
|
||||
,p.[MaxDate]
|
||||
,p.[MinDate]
|
||||
,p.[SourceTableName]
|
||||
,p.[SourcePartitionColumn]
|
||||
FROM [dbo].[ModelConfiguration] m
|
||||
|
@ -14,11 +14,13 @@ VALUES(
|
||||
1 --[TableConfigurationID]
|
||||
,1 --[ModelConfigurationID]
|
||||
,'Internet Sales' --[AnalysisServicesTable]
|
||||
,0 --[DoNotProcess]
|
||||
),
|
||||
(
|
||||
2 --[TableConfigurationID]
|
||||
,1 --[ModelConfigurationID]
|
||||
,'Reseller Sales' --[AnalysisServicesTable]
|
||||
,0 --[DoNotProcess]
|
||||
);
|
||||
|
||||
INSERT INTO [dbo].[PartitioningConfiguration]
|
||||
|
Loading…
Reference in New Issue
Block a user