You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/07/17 09:56:40 UTC

[GitHub] [calcite] chunweilei opened a new pull request #2072: [CALCITE-4118] RexSimplify might remove CAST from RexNode incorrectly

chunweilei opened a new pull request #2072:
URL: https://github.com/apache/calcite/pull/2072


   JIRA: https://issues.apache.org/jira/browse/CALCITE-4118


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

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



[GitHub] [calcite] danny0405 commented on a change in pull request #2072: [CALCITE-4118] RexSimplify might remove CAST from RexNode incorrectly

Posted by GitBox <gi...@apache.org>.
danny0405 commented on a change in pull request #2072:
URL: https://github.com/apache/calcite/pull/2072#discussion_r461311453



##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -1917,7 +1918,9 @@ private RexNode simplifyCast(RexCall e) {
       if (RexUtil.isLosslessCast(intExpr.getType(), operand.getType())
           && (e.getType().getSqlTypeName() == operand.getType().getSqlTypeName()
           || e.getType().getSqlTypeName() == SqlTypeName.CHAR
-          || operand.getType().getSqlTypeName() != SqlTypeName.CHAR)) {
+          || operand.getType().getSqlTypeName() != SqlTypeName.CHAR)
+          && SqlTypeAssignmentRule.instance()
+          .canApplyFrom(intExpr.getType().getSqlTypeName(), e.getType().getSqlTypeName())) {
         return rexBuilder.makeCast(e.getType(), intExpr);

Review comment:
       Should be `SqlTypeCoercionRule` ?

##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -1917,7 +1918,9 @@ private RexNode simplifyCast(RexCall e) {
       if (RexUtil.isLosslessCast(intExpr.getType(), operand.getType())
           && (e.getType().getSqlTypeName() == operand.getType().getSqlTypeName()
           || e.getType().getSqlTypeName() == SqlTypeName.CHAR
-          || operand.getType().getSqlTypeName() != SqlTypeName.CHAR)) {
+          || operand.getType().getSqlTypeName() != SqlTypeName.CHAR)
+          && SqlTypeAssignmentRule.instance()
+          .canApplyFrom(intExpr.getType().getSqlTypeName(), e.getType().getSqlTypeName())) {
         return rexBuilder.makeCast(e.getType(), intExpr);

Review comment:
       See the java doc which already gave good explanation.




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

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



[GitHub] [calcite] chunweilei commented on a change in pull request #2072: [CALCITE-4118] RexSimplify might remove CAST from RexNode incorrectly

Posted by GitBox <gi...@apache.org>.
chunweilei commented on a change in pull request #2072:
URL: https://github.com/apache/calcite/pull/2072#discussion_r461325918



##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -1917,7 +1918,9 @@ private RexNode simplifyCast(RexCall e) {
       if (RexUtil.isLosslessCast(intExpr.getType(), operand.getType())
           && (e.getType().getSqlTypeName() == operand.getType().getSqlTypeName()
           || e.getType().getSqlTypeName() == SqlTypeName.CHAR
-          || operand.getType().getSqlTypeName() != SqlTypeName.CHAR)) {
+          || operand.getType().getSqlTypeName() != SqlTypeName.CHAR)
+          && SqlTypeAssignmentRule.instance()
+          .canApplyFrom(intExpr.getType().getSqlTypeName(), e.getType().getSqlTypeName())) {
         return rexBuilder.makeCast(e.getType(), intExpr);

Review comment:
       It seems you're right. BYW, what's the difference between `SqlTypeCoercionRule ` and `SqlTypeAssignmentRule `?

##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -1917,7 +1918,9 @@ private RexNode simplifyCast(RexCall e) {
       if (RexUtil.isLosslessCast(intExpr.getType(), operand.getType())
           && (e.getType().getSqlTypeName() == operand.getType().getSqlTypeName()
           || e.getType().getSqlTypeName() == SqlTypeName.CHAR
-          || operand.getType().getSqlTypeName() != SqlTypeName.CHAR)) {
+          || operand.getType().getSqlTypeName() != SqlTypeName.CHAR)
+          && SqlTypeAssignmentRule.instance()
+          .canApplyFrom(intExpr.getType().getSqlTypeName(), e.getType().getSqlTypeName())) {
         return rexBuilder.makeCast(e.getType(), intExpr);

Review comment:
       It seems you're right. BTW, what's the difference between `SqlTypeCoercionRule ` and `SqlTypeAssignmentRule `?




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

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



[GitHub] [calcite] chunweilei merged pull request #2072: [CALCITE-4118] RexSimplify might remove CAST from RexNode incorrectly

Posted by GitBox <gi...@apache.org>.
chunweilei merged pull request #2072:
URL: https://github.com/apache/calcite/pull/2072


   


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

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