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 2022/09/16 04:30:52 UTC

[GitHub] [doris] englefly opened a new pull request, #12663: [improve](nereids) literal promotion cast

englefly opened a new pull request, #12663:
URL: https://github.com/apache/doris/pull/12663

   # Proposed changes
   Instead of add a cast function on literal, we directly change the literal type. This change could save cast execution time and memory.
   For example:
   `case when l_orderkey > 0 then ...`
   `0` is a TinyIntLiteral. 
   before this pr: `case when l_orderkey > cast (TinyIntLiteral(0) as int)` 
   with this pr:  `case when l_orderkey > IntegerLiteral(0) ` 
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [ ] No
       - [ ] I don't know
   2. Has unit tests been added:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   3. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   4. Does it need to update dependencies:
       - [ ] Yes
       - [ ] No
   5. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [ ] No
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto: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] [doris] morrySnow commented on a diff in pull request #12663: [improve](nereids) literal promotion cast

Posted by GitBox <gi...@apache.org>.
morrySnow commented on code in PR #12663:
URL: https://github.com/apache/doris/pull/12663#discussion_r974842323


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java:
##########
@@ -49,6 +54,26 @@ public abstract class DataType implements AbstractDataType {
             .put(FloatType.class, () -> DoubleType.INSTANCE)
             .build();
 
+    /**
+     * create a specific Literal for a given dataType
+     */
+    public static Literal promoteNumberLiteral(Object value, DataType dataType) {
+        if (! (value instanceof Number)) {
+            return null;
+        }
+
+        if (dataType.equals(SmallIntType.INSTANCE)) {
+            return new SmallIntLiteral(((Number) value).shortValue());

Review Comment:
   should handle overflow?



-- 
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] [doris] morrySnow merged pull request #12663: [enhancement](nereids) use Literal promotion to avoid unnecessary cast

Posted by GitBox <gi...@apache.org>.
morrySnow merged PR #12663:
URL: https://github.com/apache/doris/pull/12663


-- 
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] [doris] englefly commented on a diff in pull request #12663: [enhancement](nereids) use Literal promotion to avoid unnecessary cast

Posted by GitBox <gi...@apache.org>.
englefly commented on code in PR #12663:
URL: https://github.com/apache/doris/pull/12663#discussion_r974846943


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java:
##########
@@ -49,6 +54,26 @@ public abstract class DataType implements AbstractDataType {
             .put(FloatType.class, () -> DoubleType.INSTANCE)
             .build();
 
+    /**
+     * create a specific Literal for a given dataType
+     */
+    public static Literal promoteNumberLiteral(Object value, DataType dataType) {
+        if (! (value instanceof Number)) {
+            return null;
+        }
+
+        if (dataType.equals(SmallIntType.INSTANCE)) {
+            return new SmallIntLiteral(((Number) value).shortValue());

Review Comment:
   offline discussed. done
   we need another pr to do down-cast



-- 
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] [doris] englefly commented on pull request #12663: [improve](nereids) literal promotion cast

Posted by GitBox <gi...@apache.org>.
englefly commented on PR #12663:
URL: https://github.com/apache/doris/pull/12663#issuecomment-1248907366

   @morrySnow @jackwener @Kikyou1997 please review


-- 
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