DoNotProcess & Lower/Upper Boundary
This commit is contained in:
parent
f5493e9a17
commit
41face83fe
@ -7,7 +7,7 @@ namespace AsPartitionProcessing.SampleClient
|
|||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
const bool UseDatabase = true;
|
const bool UseDatabase = false;
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
@ -43,6 +43,7 @@ namespace AsPartitionProcessing
|
|||||||
,[SourceTableName]
|
,[SourceTableName]
|
||||||
,[SourcePartitionColumn]
|
,[SourcePartitionColumn]
|
||||||
FROM [dbo].[vPartitioningConfiguration]
|
FROM [dbo].[vPartitioningConfiguration]
|
||||||
|
WHERE [DoNotProcess] = 0
|
||||||
ORDER BY
|
ORDER BY
|
||||||
[ModelConfigurationID],
|
[ModelConfigurationID],
|
||||||
[TableConfigurationID],
|
[TableConfigurationID],
|
||||||
|
@ -28,10 +28,20 @@ namespace AsPartitionProcessing
|
|||||||
public int NumberOfPartitionsForIncrementalProcess { get; set; }
|
public int NumberOfPartitionsForIncrementalProcess { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public DateTime MaxDate { get; set; }
|
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>
|
/// <summary>
|
||||||
/// Name of the source table in the relational database.
|
/// Name of the source table in the relational database.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -70,6 +80,28 @@ namespace AsPartitionProcessing
|
|||||||
MaxDate = maxDate;
|
MaxDate = maxDate;
|
||||||
SourceTableName = sourceTableName;
|
SourceTableName = sourceTableName;
|
||||||
SourcePartitionColumn = sourcePartitionColumn;
|
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,
|
[NumberOfPartitionsFull] [int] NOT NULL,
|
||||||
[NumberOfPartitionsForIncrementalProcess] [int] NOT NULL,
|
[NumberOfPartitionsForIncrementalProcess] [int] NOT NULL,
|
||||||
[MaxDate] [date] 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,
|
[SourceTableName] [varchar](255) NOT NULL,
|
||||||
[SourcePartitionColumn] [varchar](255) NOT NULL,
|
[SourcePartitionColumn] [varchar](255) NOT NULL,
|
||||||
CONSTRAINT [PK_PartitioningConfiguration] PRIMARY KEY CLUSTERED
|
CONSTRAINT [PK_PartitioningConfiguration] PRIMARY KEY CLUSTERED
|
||||||
@ -52,6 +51,7 @@ CREATE TABLE [dbo].[TableConfiguration](
|
|||||||
[TableConfigurationID] [int] NOT NULL,
|
[TableConfigurationID] [int] NOT NULL,
|
||||||
[ModelConfigurationID] [int] NOT NULL,
|
[ModelConfigurationID] [int] NOT NULL,
|
||||||
[AnalysisServicesTable] [varchar](255) NOT NULL,
|
[AnalysisServicesTable] [varchar](255) NOT NULL,
|
||||||
|
[DoNotProcess] [bit] NOT NULL,
|
||||||
CONSTRAINT [PK_TableConfiguration] PRIMARY KEY CLUSTERED
|
CONSTRAINT [PK_TableConfiguration] PRIMARY KEY CLUSTERED
|
||||||
(
|
(
|
||||||
[TableConfigurationID] ASC
|
[TableConfigurationID] ASC
|
||||||
@ -73,6 +73,9 @@ GO
|
|||||||
ALTER TABLE [dbo].[ProcessingLog] CHECK CONSTRAINT [FK_ProcessingLog_ModelConfiguration]
|
ALTER TABLE [dbo].[ProcessingLog] CHECK CONSTRAINT [FK_ProcessingLog_ModelConfiguration]
|
||||||
GO
|
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])
|
ALTER TABLE [dbo].[TableConfiguration] WITH CHECK ADD CONSTRAINT [FK_TableConfiguration_ModelConfiguration] FOREIGN KEY([ModelConfigurationID])
|
||||||
REFERENCES [dbo].[ModelConfiguration] ([ModelConfigurationID])
|
REFERENCES [dbo].[ModelConfiguration] ([ModelConfigurationID])
|
||||||
GO
|
GO
|
||||||
@ -94,7 +97,6 @@ GO
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE VIEW [dbo].[vPartitioningConfiguration]
|
CREATE VIEW [dbo].[vPartitioningConfiguration]
|
||||||
AS
|
AS
|
||||||
SELECT m.[ModelConfigurationID]
|
SELECT m.[ModelConfigurationID]
|
||||||
@ -106,6 +108,7 @@ SELECT m.[ModelConfigurationID]
|
|||||||
,m.[IntegratedAuth]
|
,m.[IntegratedAuth]
|
||||||
,t.[TableConfigurationID]
|
,t.[TableConfigurationID]
|
||||||
,t.[AnalysisServicesTable]
|
,t.[AnalysisServicesTable]
|
||||||
|
,t.[DoNotProcess]
|
||||||
,CASE
|
,CASE
|
||||||
WHEN p.[TableConfigurationID] IS NULL THEN 0
|
WHEN p.[TableConfigurationID] IS NULL THEN 0
|
||||||
ELSE 1
|
ELSE 1
|
||||||
@ -115,7 +118,6 @@ SELECT m.[ModelConfigurationID]
|
|||||||
,p.[NumberOfPartitionsFull]
|
,p.[NumberOfPartitionsFull]
|
||||||
,p.[NumberOfPartitionsForIncrementalProcess]
|
,p.[NumberOfPartitionsForIncrementalProcess]
|
||||||
,p.[MaxDate]
|
,p.[MaxDate]
|
||||||
,p.[MinDate]
|
|
||||||
,p.[SourceTableName]
|
,p.[SourceTableName]
|
||||||
,p.[SourcePartitionColumn]
|
,p.[SourcePartitionColumn]
|
||||||
FROM [dbo].[ModelConfiguration] m
|
FROM [dbo].[ModelConfiguration] m
|
||||||
|
@ -14,11 +14,13 @@ VALUES(
|
|||||||
1 --[TableConfigurationID]
|
1 --[TableConfigurationID]
|
||||||
,1 --[ModelConfigurationID]
|
,1 --[ModelConfigurationID]
|
||||||
,'Internet Sales' --[AnalysisServicesTable]
|
,'Internet Sales' --[AnalysisServicesTable]
|
||||||
|
,0 --[DoNotProcess]
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
2 --[TableConfigurationID]
|
2 --[TableConfigurationID]
|
||||||
,1 --[ModelConfigurationID]
|
,1 --[ModelConfigurationID]
|
||||||
,'Reseller Sales' --[AnalysisServicesTable]
|
,'Reseller Sales' --[AnalysisServicesTable]
|
||||||
|
,0 --[DoNotProcess]
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO [dbo].[PartitioningConfiguration]
|
INSERT INTO [dbo].[PartitioningConfiguration]
|
||||||
|
Loading…
Reference in New Issue
Block a user