Repository: kylin Updated Branches: refs/heads/master ae72c2570 -> eb92f96fc
KYLIN-1698 Also support int partition column using format yyyyMMdd Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/eb92f96f Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/eb92f96f Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/eb92f96f Branch: refs/heads/master Commit: eb92f96fc598a2add7a80a49768cd4f2d4184c76 Parents: ae72c25 Author: Li Yang <liy...@apache.org> Authored: Wed Sep 7 11:30:48 2016 +0800 Committer: Li Yang <liy...@apache.org> Committed: Wed Sep 7 11:30:48 2016 +0800 ---------------------------------------------------------------------- .../kylin/metadata/model/PartitionDesc.java | 25 +++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/eb92f96f/core-metadata/src/main/java/org/apache/kylin/metadata/model/PartitionDesc.java ---------------------------------------------------------------------- diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/model/PartitionDesc.java b/core-metadata/src/main/java/org/apache/kylin/metadata/model/PartitionDesc.java index 598e6d0..6487bfa 100644 --- a/core-metadata/src/main/java/org/apache/kylin/metadata/model/PartitionDesc.java +++ b/core-metadata/src/main/java/org/apache/kylin/metadata/model/PartitionDesc.java @@ -91,6 +91,14 @@ public class PartitionDesc { partitionConditionBuilder = (IPartitionConditionBuilder) ClassUtil.newInstance(partitionConditionBuilderClz); } + public boolean partitionColumnIsYmdInt() { + if (partitionDateColumnRef == null) + return false; + + DataType type = partitionDateColumnRef.getType(); + return type.isInt(); + } + public boolean partitionColumnIsTimeMillis() { if (partitionDateColumnRef == null) return false; @@ -175,8 +183,10 @@ public class PartitionDesc { String partitionDateColumnName = partDesc.getPartitionDateColumn(); String partitionTimeColumnName = partDesc.getPartitionTimeColumn(); - if (partDesc.partitionColumnIsTimeMillis()) { - buildSingleColumnRangeCondition(builder, partitionDateColumnName, startInclusive, endExclusive, tableAlias); + if (partDesc.partitionColumnIsYmdInt()) { + buildSingleColumnRangeCondAsYmdInt(builder, partitionDateColumnName, startInclusive, endExclusive, tableAlias); + } else if (partDesc.partitionColumnIsTimeMillis()) { + buildSingleColumnRangeCondAsTimeMillis(builder, partitionDateColumnName, startInclusive, endExclusive, tableAlias); } else if (partitionDateColumnName != null && partitionTimeColumnName == null) { buildSingleColumnRangeCondition(builder, partitionDateColumnName, startInclusive, endExclusive, partDesc.getPartitionDateFormat(), tableAlias); } else if (partitionDateColumnName == null && partitionTimeColumnName != null) { @@ -201,7 +211,7 @@ public class PartitionDesc { return columnName; } - private static void buildSingleColumnRangeCondition(StringBuilder builder, String partitionColumnName, long startInclusive, long endExclusive, Map<String, String> tableAlias) { + private static void buildSingleColumnRangeCondAsTimeMillis(StringBuilder builder, String partitionColumnName, long startInclusive, long endExclusive, Map<String, String> tableAlias) { partitionColumnName = replaceColumnNameWithAlias(partitionColumnName, tableAlias); if (startInclusive > 0) { builder.append(partitionColumnName + " >= " + startInclusive); @@ -210,6 +220,15 @@ public class PartitionDesc { builder.append(partitionColumnName + " < " + endExclusive); } + private static void buildSingleColumnRangeCondAsYmdInt(StringBuilder builder, String partitionColumnName, long startInclusive, long endExclusive, Map<String, String> tableAlias) { + partitionColumnName = replaceColumnNameWithAlias(partitionColumnName, tableAlias); + if (startInclusive > 0) { + builder.append(partitionColumnName + " >= " + DateFormat.formatToDateStr(startInclusive, DateFormat.COMPACT_DATE_PATTERN)); + builder.append(" AND "); + } + builder.append(partitionColumnName + " < " + DateFormat.formatToDateStr(endExclusive, DateFormat.COMPACT_DATE_PATTERN)); + } + private static void buildSingleColumnRangeCondition(StringBuilder builder, String partitionColumnName, long startInclusive, long endExclusive, String partitionColumnDateFormat, Map<String, String> tableAlias) { partitionColumnName = replaceColumnNameWithAlias(partitionColumnName, tableAlias); if (startInclusive > 0) {