You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2015/06/11 10:47:32 UTC

incubator-kylin git commit: KYLIN-815 add a partition builder, and merge change on CubeDesc.java from 0.7

Repository: incubator-kylin
Updated Branches:
  refs/heads/0.8 adb3b4ee1 -> 80cccad50


KYLIN-815 add a partition builder, and merge change on CubeDesc.java from 0.7

Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/80cccad5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/80cccad5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/80cccad5

Branch: refs/heads/0.8
Commit: 80cccad50e9f7fcf268713288023818a5479519b
Parents: adb3b4e
Author: shaofengshi <sh...@apache.org>
Authored: Thu Jun 11 16:47:12 2015 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Thu Jun 11 16:47:12 2015 +0800

----------------------------------------------------------------------
 .../org/apache/kylin/cube/model/CubeDesc.java   |  2 +
 .../kylin/metadata/model/PartitionDesc.java     | 39 ++++++++++++++++++++
 .../kylin/rest/controller/CubeController.java   |  1 -
 3 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/80cccad5/cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
----------------------------------------------------------------------
diff --git a/cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java b/cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
index f91aff1..755e0cd 100644
--- a/cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
+++ b/cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
@@ -518,6 +518,7 @@ public class CubeDesc extends RootPersistentEntity {
                         initDerivedMap(hostCols[find], DeriveType.PK_FK, dim, derivedCol);
                     }
                 }
+                /** disable this code as we don't need fk be derived from pk
                 for (int i = 0; i < pk.length; i++) {
                     int find = ArrayUtils.indexOf(hostCols, pk[i]);
                     if (find >= 0) {
@@ -525,6 +526,7 @@ public class CubeDesc extends RootPersistentEntity {
                         initDerivedMap(hostCols[find], DeriveType.PK_FK, dim, derivedCol);
                     }
                 }
+                 */
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/80cccad5/metadata/src/main/java/org/apache/kylin/metadata/model/PartitionDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/model/PartitionDesc.java b/metadata/src/main/java/org/apache/kylin/metadata/model/PartitionDesc.java
index cb60c6a..7ae234c 100644
--- a/metadata/src/main/java/org/apache/kylin/metadata/model/PartitionDesc.java
+++ b/metadata/src/main/java/org/apache/kylin/metadata/model/PartitionDesc.java
@@ -146,4 +146,43 @@ public class PartitionDesc {
         }
 
     }
+
+
+    /**
+     * Another implementation of IPartitionConditionBuilder, for the fact tables which have three partition columns "YEAR", "MONTH", and "DAY"; This
+     * class will concat the three columns into yyyy-MM-dd format for query hive;
+     */
+    public static class YearMonthDayPartitionConditionBuilder implements PartitionDesc.IPartitionConditionBuilder {
+
+        @Override
+        public String buildDateRangeCondition(PartitionDesc partDesc, long startInclusive, long endExclusive, Map<String, String> tableAlias) {
+
+            String partitionColumnName = partDesc.getPartitionDateColumn();
+            String partitionTableName;
+
+            // convert to use table alias
+            int indexOfDot = partitionColumnName.lastIndexOf(".");
+            if (indexOfDot > 0) {
+                partitionTableName = partitionColumnName.substring(0, indexOfDot).toUpperCase();
+            } else {
+                throw new IllegalStateException("The partitionColumnName is invalid: " + partitionColumnName);
+            }
+
+            if (tableAlias.containsKey(partitionTableName)) {
+                partitionTableName = tableAlias.get(partitionTableName);
+            }
+
+            String concatField = String.format("CONCAT(%s.YEAR,'-',%s.MONTH,'-',%s.DAY)", partitionTableName, partitionTableName, partitionTableName);
+            StringBuilder builder = new StringBuilder();
+
+            if (startInclusive > 0) {
+                builder.append(concatField + " >= '" + DateFormat.formatToDateStr(startInclusive) + "' ");
+                builder.append("AND ");
+            }
+            builder.append(concatField + " < '" + DateFormat.formatToDateStr(endExclusive) + "'");
+
+
+            return builder.toString();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/80cccad5/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java b/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java
index 6610186..441c26b 100644
--- a/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java
+++ b/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java
@@ -179,7 +179,6 @@ public class CubeController extends BasicController {
      *
      * @param cubeName Cube ID
      * @return
-     * @throws SchedulerException
      * @throws IOException
      */
     @RequestMapping(value = "/{cubeName}/rebuild", method = { RequestMethod.PUT })