Cleanup
This commit is contained in:
parent
c4b3ee7e3b
commit
2de96c3ba5
@ -220,19 +220,6 @@ namespace AsPartitionProcessing
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Partition CreateNewPartition(Table table, Partition templatePartition, PartitioningConfiguration partitioningConfiguration, string partitionKey)
|
|
||||||
{
|
|
||||||
Partition partitionToProcess;
|
|
||||||
//Doesn't exist so create it
|
|
||||||
string selectQueryTemplate = DeriveSelectQueryTemplate(partitioningConfiguration.Granularity);
|
|
||||||
partitionToProcess = new Partition();
|
|
||||||
templatePartition.CopyTo(partitionToProcess);
|
|
||||||
partitionToProcess.Name = partitionKey;
|
|
||||||
((QueryPartitionSource)partitionToProcess.Source).Query = String.Format(selectQueryTemplate, partitioningConfiguration.SourceTableName, partitioningConfiguration.SourcePartitionColumn, partitionKey);
|
|
||||||
table.Partitions.Add(partitionToProcess);
|
|
||||||
return partitionToProcess;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Merge months into a year, or days into a month.
|
/// Merge months into a year, or days into a month.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -510,20 +497,10 @@ namespace AsPartitionProcessing
|
|||||||
return partitionsExisting;
|
return partitionsExisting;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IncludePartition(Granularity granularity, string filter, Partition partition, ref int partitionKey)
|
private static Partition CreateNewPartition(Table table, Partition templatePartition, PartitioningConfiguration partitioningConfiguration, string partitionKey)
|
||||||
{
|
|
||||||
//Ignore partitions that don't follow the convention yyyy, yyyymm or yyyymmdd, or are not included in the filter expression
|
|
||||||
return ( (partition.Name.Length == 4 && granularity == Granularity.Yearly) ||
|
|
||||||
(partition.Name.Length == 6 && granularity == Granularity.Monthly) ||
|
|
||||||
(partition.Name.Length == 8 && granularity == Granularity.Daily)
|
|
||||||
) && int.TryParse(partition.Name, out partitionKey) &&
|
|
||||||
partition.Name.StartsWith(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string DeriveSelectQueryTemplate(Granularity granularity)
|
|
||||||
{
|
{
|
||||||
string selectQueryTemplate;
|
string selectQueryTemplate;
|
||||||
switch (granularity)
|
switch (partitioningConfiguration.Granularity)
|
||||||
{
|
{
|
||||||
case Granularity.Daily:
|
case Granularity.Daily:
|
||||||
selectQueryTemplate = "SELECT * FROM {0} WHERE {1} = {2} ORDER BY {1}";
|
selectQueryTemplate = "SELECT * FROM {0} WHERE {1} = {2} ORDER BY {1}";
|
||||||
@ -535,8 +512,23 @@ namespace AsPartitionProcessing
|
|||||||
selectQueryTemplate = "SELECT * FROM {0} WHERE FLOOR({1} / 10000) = {2} ORDER BY {1}";
|
selectQueryTemplate = "SELECT * FROM {0} WHERE FLOOR({1} / 10000) = {2} ORDER BY {1}";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Partition newPartition;
|
||||||
|
newPartition = new Partition();
|
||||||
|
templatePartition.CopyTo(newPartition);
|
||||||
|
newPartition.Name = partitionKey;
|
||||||
|
((QueryPartitionSource)newPartition.Source).Query = String.Format(selectQueryTemplate, partitioningConfiguration.SourceTableName, partitioningConfiguration.SourcePartitionColumn, partitionKey);
|
||||||
|
table.Partitions.Add(newPartition);
|
||||||
|
return newPartition;
|
||||||
|
}
|
||||||
|
|
||||||
return selectQueryTemplate;
|
private static bool IncludePartition(Granularity granularity, string filter, Partition partition, ref int partitionKey)
|
||||||
|
{
|
||||||
|
//Ignore partitions that don't follow the convention yyyy, yyyymm or yyyymmdd, or are not included in the filter expression
|
||||||
|
return ( (partition.Name.Length == 4 && granularity == Granularity.Yearly) ||
|
||||||
|
(partition.Name.Length == 6 && granularity == Granularity.Monthly) ||
|
||||||
|
(partition.Name.Length == 8 && granularity == Granularity.Daily)
|
||||||
|
) && int.TryParse(partition.Name, out partitionKey) &&
|
||||||
|
partition.Name.StartsWith(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
Reference in New Issue
Block a user