[ 
https://issues.apache.org/jira/browse/KYLIN-3665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16700480#comment-16700480
 ] 

ASF GitHub Bot commented on KYLIN-3665:
---------------------------------------

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:
us...@infra.apache.org


> Partition time column may never be added
> ----------------------------------------
>
>                 Key: KYLIN-3665
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3665
>             Project: Kylin
>          Issue Type: Bug
>            Reporter: Chao Long
>            Assignee: Feng Liang
>            Priority: Major
>             Fix For: v2.6.0
>
>
> The partition time column will never be added to the WHERE clause if the 
> partition date column is type of int or bigint and the date format is 
> "yyyyMMdd", "yyyyMMddHH", "yyyyMMddHHmm" or "yyyyMMddHHmmss".
> Let’s say I have a fact table with two date partition column: day as the 
> format of integer (yyyyMMdd) and minute as the format of string (HHmm). I 
> have models created based on it and set the Partition Date Column to be “day” 
> with the format of yyyyMMdd and the Partition Time Column to be “minute” with 
> the format of HHmm. When I build the cube built on top of that model, I set 
> the Start Date to be 2018-11-01 00:00:00 and the End Date to be 2018-11-01 
> 01:00:00. The building process is supposed to retrieve the data from the fact 
> table in the range of “day = 20181101 and minute>=’0000’ and minute<’0100’”. 
> However, it retrieves the data in the range of “WHERE 1=1 AND (DAY >= 
> 20181101 AND DAY < 20181101), so no data are actually retrieved.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to