kylin-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] shaofengshi closed pull request #360: KYLIN-3665 Partition time column may never be added
Date Tue, 27 Nov 2018 14:16:23 GMT
shaofengshi closed pull request #360: KYLIN-3665 Partition time column may never be added
URL: https://github.com/apache/kylin/pull/360
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 dcb37ecdad..56ededb995 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
@@ -200,8 +200,12 @@ public String buildDateRangeCondition(PartitionDesc partDesc, ISegment
seg, Segm
             StringBuilder builder = new StringBuilder();
 
             if (partDesc.partitionColumnIsYmdInt()) {
-                buildSingleColumnRangeCondAsYmdInt(builder, partitionDateColumn, startInclusive,
endExclusive,
-                        partDesc.getPartitionDateFormat());
+                if (partitionTimeColumn == null) {
+                    buildSingleColumnRangeCondAsYmdInt(builder, partitionDateColumn, startInclusive,
endExclusive, partDesc.getPartitionDateFormat());
+                } else {
+                    buildMultipleColumnRangeCondition(builder, partitionDateColumn, partitionTimeColumn,
startInclusive,
+                            endExclusive, partDesc.getPartitionDateFormat(), partDesc.getPartitionTimeFormat(),
true);
+                }
             } else if (partDesc.partitionColumnIsTimeMillis()) {
                 buildSingleColumnRangeCondAsTimeMillis(builder, partitionDateColumn, startInclusive,
endExclusive);
             } else if (partitionDateColumn != null && partitionTimeColumn == null)
{
@@ -212,14 +216,14 @@ public String buildDateRangeCondition(PartitionDesc partDesc, ISegment
seg, Segm
                         partDesc.getPartitionTimeFormat());
             } else if (partitionDateColumn != null && partitionTimeColumn != null)
{
                 buildMultipleColumnRangeCondition(builder, partitionDateColumn, partitionTimeColumn,
startInclusive,
-                        endExclusive, partDesc.getPartitionDateFormat(), partDesc.getPartitionTimeFormat());
+                        endExclusive, partDesc.getPartitionDateFormat(), partDesc.getPartitionTimeFormat(),
false);
             }
 
             return builder.toString();
         }
 
         private static void buildSingleColumnRangeCondAsTimeMillis(StringBuilder builder,
TblColRef partitionColumn,
-                long startInclusive, long endExclusive) {
+                                                                   long startInclusive, long
endExclusive) {
             String partitionColumnName = partitionColumn.getIdentity();
             builder.append(partitionColumnName + " >= " + startInclusive);
             builder.append(" AND ");
@@ -227,7 +231,7 @@ private static void buildSingleColumnRangeCondAsTimeMillis(StringBuilder
builder
         }
 
         private static void buildSingleColumnRangeCondAsYmdInt(StringBuilder builder, TblColRef
partitionColumn,
-                long startInclusive, long endExclusive, String partitionColumnDateFormat)
{
+                                                               long startInclusive, long
endExclusive, String partitionColumnDateFormat) {
             String partitionColumnName = partitionColumn.getIdentity();
             builder.append(partitionColumnName + " >= "
                     + DateFormat.formatToDateStr(startInclusive, partitionColumnDateFormat));
@@ -237,7 +241,7 @@ private static void buildSingleColumnRangeCondAsYmdInt(StringBuilder builder,
Tb
         }
 
         private static void buildSingleColumnRangeCondition(StringBuilder builder, TblColRef
partitionColumn,
-                long startInclusive, long endExclusive, String partitionColumnDateFormat)
{
+                                                            long startInclusive, long endExclusive,
String partitionColumnDateFormat) {
             String partitionColumnName = partitionColumn.getIdentity();
 
             if (endExclusive <= startInclusive) {
@@ -261,36 +265,37 @@ private static void buildSingleColumnRangeCondition(StringBuilder builder,
TblCo
         }
 
         private static void buildMultipleColumnRangeCondition(StringBuilder builder, TblColRef
partitionDateColumn,
-                TblColRef partitionTimeColumn, long startInclusive, long endExclusive, String
partitionColumnDateFormat,
-                String partitionColumnTimeFormat) {
+                                                              TblColRef partitionTimeColumn,
long startInclusive, long endExclusive, String partitionColumnDateFormat,
+                                                              String partitionColumnTimeFormat,
boolean partitionDateColumnIsYmdInt) {
             String partitionDateColumnName = partitionDateColumn.getIdentity();
             String partitionTimeColumnName = partitionTimeColumn.getIdentity();
+            String singleQuotation = partitionDateColumnIsYmdInt ? "" : "'";
             builder.append("(");
             builder.append("(");
-            builder.append(partitionDateColumnName + " = '"
-                    + DateFormat.formatToDateStr(startInclusive, partitionColumnDateFormat)
+ "'").append(" AND ")
+            builder.append(partitionDateColumnName + " = " + singleQuotation
+                    + DateFormat.formatToDateStr(startInclusive, partitionColumnDateFormat)
+ singleQuotation).append(" AND ")
                     .append(partitionTimeColumnName + " >= '"
                             + DateFormat.formatToDateStr(startInclusive, partitionColumnTimeFormat)
+ "'");
             builder.append(")");
             builder.append(" OR ");
             builder.append("(");
-            builder.append(partitionDateColumnName + " > '"
-                    + DateFormat.formatToDateStr(startInclusive, partitionColumnDateFormat)
+ "'");
+            builder.append(partitionDateColumnName + " > " + singleQuotation
+                    + DateFormat.formatToDateStr(startInclusive, partitionColumnDateFormat)
+ singleQuotation);
             builder.append(")");
             builder.append(")");
             builder.append(" AND ");
 
             builder.append("(");
             builder.append("(");
-            builder.append(partitionDateColumnName + " = '"
-                    + DateFormat.formatToDateStr(endExclusive, partitionColumnDateFormat)
+ "'").append(" AND ")
+            builder.append(partitionDateColumnName + " = " + singleQuotation
+                    + DateFormat.formatToDateStr(endExclusive, partitionColumnDateFormat)
+ singleQuotation).append(" AND ")
                     .append(partitionTimeColumnName + " < '"
                             + DateFormat.formatToDateStr(endExclusive, partitionColumnTimeFormat)
+ "'");
             builder.append(")");
             builder.append(" OR ");
             builder.append("(");
-            builder.append(partitionDateColumnName + " < '"
-                    + DateFormat.formatToDateStr(endExclusive, partitionColumnDateFormat)
+ "'");
+            builder.append(partitionDateColumnName + " < " + singleQuotation
+                    + DateFormat.formatToDateStr(endExclusive, partitionColumnDateFormat)
+ singleQuotation);
             builder.append(")");
             builder.append(")");
         }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message