You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/11/08 08:47:23 UTC

[GitHub] [incubator-doris] BiteTheDDDDt opened a new pull request #7045: [Feature] make BinaryPredicate do not cast date to datetime/varchar

BiteTheDDDDt opened a new pull request #7045:
URL: https://github.com/apache/incubator-doris/pull/7045


   
   ## Proposed changes
   
   #7044 
   
   ## Types of changes
   
   What types of changes does your code introduce to Doris?
   _Put an `x` in the boxes that apply_
   
   - [ ] Bugfix (non-breaking change which fixes an issue)
   - [x] New feature (non-breaking change which adds functionality)
   - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
   - [ ] Documentation Update (if none of the other choices apply)
   - [ ] Code refactor (Modify the code structure, format the code, etc...)
   - [ ] Optimization. Including functional usability improvements and performance improvements.
   - [ ] Dependency. Such as changes related to third-party components.
   - [ ] Other.
   
   ## Checklist
   
   _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._
   
   - [x] I have created an issue on (Fix #7044) and described the bug/feature there in detail
   - [x] Compiling and unit tests pass locally with my changes
   - [ ] I have added tests that prove my fix is effective or that my feature works
   - [ ] If these changes need document changes, I have updated the document
   - [ ] Any dependent changes have been merged
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] HappenLee commented on a change in pull request #7045: [Feature] make BinaryPredicate do not cast date to datetime/varchar

Posted by GitBox <gi...@apache.org>.
HappenLee commented on a change in pull request #7045:
URL: https://github.com/apache/incubator-doris/pull/7045#discussion_r746303304



##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java
##########
@@ -1022,30 +1027,42 @@ public static Type getCmpType(Type t1, Type t2) {
         }
 
         // int family type and char family type should cast to char family type
-        if ((t1ResultType.isFixedPointType() && t2ResultType.isCharFamily()) ||
-                (t2ResultType.isFixedPointType() && t1ResultType.isCharFamily())) {
-            return t1.isStringType() ?  t1 : t2;
+        if ((t1ResultType.isFixedPointType() && t2ResultType.isCharFamily())
+                || (t2ResultType.isFixedPointType() && t1ResultType.isCharFamily())) {
+            return t1.isStringType() ? t1 : t2;
         }
 
         if (t1ResultType == PrimitiveType.BIGINT && t2ResultType == PrimitiveType.BIGINT) {
             return getAssignmentCompatibleType(t1, t2, false);
         }
-        if ((t1ResultType == PrimitiveType.BIGINT
-                || t1ResultType == PrimitiveType.DECIMALV2)
-                && (t2ResultType == PrimitiveType.BIGINT
-                || t2ResultType == PrimitiveType.DECIMALV2)) {
+        if ((t1ResultType == PrimitiveType.BIGINT || t1ResultType == PrimitiveType.DECIMALV2)
+                && (t2ResultType == PrimitiveType.BIGINT || t2ResultType == PrimitiveType.DECIMALV2)) {
             return Type.DECIMALV2;
         }
-        if ((t1ResultType == PrimitiveType.BIGINT
-                || t1ResultType == PrimitiveType.LARGEINT)
-                && (t2ResultType == PrimitiveType.BIGINT
-                || t2ResultType == PrimitiveType.LARGEINT)) {
+        if ((t1ResultType == PrimitiveType.BIGINT || t1ResultType == PrimitiveType.LARGEINT)
+                && (t2ResultType == PrimitiveType.BIGINT || t2ResultType == PrimitiveType.LARGEINT)) {
             return Type.LARGEINT;
         }
         return Type.DOUBLE;
     }
 
     public static boolean canCompareDate(PrimitiveType t1, PrimitiveType t2) {
+        if (t1 == PrimitiveType.DATE) {
+            if (t2 == PrimitiveType.DATE || t2.isStringType() || t2.isIntegerType()) {

Review comment:
       Int compare date shoule cast int, because int are 4byte, date is 16byte。 int is more chance to SIMD




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] EmmyMiao87 commented on a change in pull request #7045: [Feature] make BinaryPredicate do not cast date to datetime/varchar

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on a change in pull request #7045:
URL: https://github.com/apache/incubator-doris/pull/7045#discussion_r749063395



##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java
##########
@@ -1022,30 +1027,42 @@ public static Type getCmpType(Type t1, Type t2) {
         }
 
         // int family type and char family type should cast to char family type
-        if ((t1ResultType.isFixedPointType() && t2ResultType.isCharFamily()) ||
-                (t2ResultType.isFixedPointType() && t1ResultType.isCharFamily())) {
-            return t1.isStringType() ?  t1 : t2;
+        if ((t1ResultType.isFixedPointType() && t2ResultType.isCharFamily())
+                || (t2ResultType.isFixedPointType() && t1ResultType.isCharFamily())) {
+            return t1.isStringType() ? t1 : t2;
         }
 
         if (t1ResultType == PrimitiveType.BIGINT && t2ResultType == PrimitiveType.BIGINT) {
             return getAssignmentCompatibleType(t1, t2, false);
         }
-        if ((t1ResultType == PrimitiveType.BIGINT
-                || t1ResultType == PrimitiveType.DECIMALV2)
-                && (t2ResultType == PrimitiveType.BIGINT
-                || t2ResultType == PrimitiveType.DECIMALV2)) {
+        if ((t1ResultType == PrimitiveType.BIGINT || t1ResultType == PrimitiveType.DECIMALV2)
+                && (t2ResultType == PrimitiveType.BIGINT || t2ResultType == PrimitiveType.DECIMALV2)) {
             return Type.DECIMALV2;
         }
-        if ((t1ResultType == PrimitiveType.BIGINT
-                || t1ResultType == PrimitiveType.LARGEINT)
-                && (t2ResultType == PrimitiveType.BIGINT
-                || t2ResultType == PrimitiveType.LARGEINT)) {
+        if ((t1ResultType == PrimitiveType.BIGINT || t1ResultType == PrimitiveType.LARGEINT)
+                && (t2ResultType == PrimitiveType.BIGINT || t2ResultType == PrimitiveType.LARGEINT)) {
             return Type.LARGEINT;
         }
         return Type.DOUBLE;
     }
 
     public static boolean canCompareDate(PrimitiveType t1, PrimitiveType t2) {
+        if (t1 == PrimitiveType.DATE) {
+            if (t2 == PrimitiveType.DATE || t2.isStringType() || t2.isIntegerType()) {

Review comment:
       I create a issue to deal with redundant castExpr. It will be fixed later.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] EmmyMiao87 commented on a change in pull request #7045: [Feature] make BinaryPredicate do not cast date to datetime/varchar

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on a change in pull request #7045:
URL: https://github.com/apache/incubator-doris/pull/7045#discussion_r744635142



##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
##########
@@ -294,29 +291,39 @@ private Type getCmpType() throws AnalysisException {
             }
         }
 
-        if (canCompareDate(getChild(0).getType().getPrimitiveType(), getChild(1).getType().getPrimitiveType())) {
+        Type t1 = getChild(0).getType();
+        Type t2 = getChild(1).getType();
+
+        if(t1.getPrimitiveType() == PrimitiveType.DATE && t2.getPrimitiveType() == PrimitiveType.DATE) {
+            return Type.DATE;

Review comment:
       Maybe following is better ?
   ```
   if (canCompareDtat()) {
       return t1.type();
   }
   ```

##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java
##########
@@ -1005,12 +1005,17 @@ public static Type getCmpType(Type t1, Type t2) {
             return t1;
         }
 
-        PrimitiveType t1ResultType = t1.getResultType().getPrimitiveType();
-        PrimitiveType t2ResultType = t2.getResultType().getPrimitiveType();
+        if (t1.getPrimitiveType() == PrimitiveType.DATE && t2.getPrimitiveType() == PrimitiveType.DATE) {

Review comment:
       same as above

##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
##########
@@ -294,29 +291,39 @@ private Type getCmpType() throws AnalysisException {
             }
         }
 
-        if (canCompareDate(getChild(0).getType().getPrimitiveType(), getChild(1).getType().getPrimitiveType())) {
+        Type t1 = getChild(0).getType();
+        Type t2 = getChild(1).getType();
+
+        if(t1.getPrimitiveType() == PrimitiveType.DATE && t2.getPrimitiveType() == PrimitiveType.DATE) {

Review comment:
       notice code format

##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
##########
@@ -294,29 +291,39 @@ private Type getCmpType() throws AnalysisException {
             }
         }
 
-        if (canCompareDate(getChild(0).getType().getPrimitiveType(), getChild(1).getType().getPrimitiveType())) {
+        Type t1 = getChild(0).getType();
+        Type t2 = getChild(1).getType();
+
+        if(t1.getPrimitiveType() == PrimitiveType.DATE && t2.getPrimitiveType() == PrimitiveType.DATE) {
+            return Type.DATE;
+        }
+
+        if (canCompareDate(t1.getPrimitiveType(), t2.getPrimitiveType())) {
             return Type.DATETIME;
         }
 
+        PrimitiveType t1ResultType = t1.getResultType().getPrimitiveType();

Review comment:
       So, why we need to check the result type rather than origin type?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] BiteTheDDDDt commented on a change in pull request #7045: [Feature] make BinaryPredicate do not cast date to datetime/varchar

Posted by GitBox <gi...@apache.org>.
BiteTheDDDDt commented on a change in pull request #7045:
URL: https://github.com/apache/incubator-doris/pull/7045#discussion_r744638152



##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
##########
@@ -294,29 +291,39 @@ private Type getCmpType() throws AnalysisException {
             }
         }
 
-        if (canCompareDate(getChild(0).getType().getPrimitiveType(), getChild(1).getType().getPrimitiveType())) {
+        Type t1 = getChild(0).getType();
+        Type t2 = getChild(1).getType();
+
+        if(t1.getPrimitiveType() == PrimitiveType.DATE && t2.getPrimitiveType() == PrimitiveType.DATE) {
+            return Type.DATE;

Review comment:
       When t1=DATE t2=DATETIME, it should be return DATETIME.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman merged pull request #7045: [Feature] make BinaryPredicate do not cast date to datetime/varchar

Posted by GitBox <gi...@apache.org>.
morningman merged pull request #7045:
URL: https://github.com/apache/incubator-doris/pull/7045


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] github-actions[bot] commented on pull request #7045: [Feature] make BinaryPredicate do not cast date to datetime/varchar

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #7045:
URL: https://github.com/apache/incubator-doris/pull/7045#issuecomment-1000383207


   PR approved by at least one committer and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] github-actions[bot] commented on pull request #7045: [Feature] make BinaryPredicate do not cast date to datetime/varchar

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #7045:
URL: https://github.com/apache/incubator-doris/pull/7045#issuecomment-968610627






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org