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 2019/10/02 23:02:12 UTC

[GitHub] [calcite] hsyuan commented on a change in pull request #1437: [CALCITE-3318] Preserving CAST of STRING operands in comparison operator

hsyuan commented on a change in pull request #1437: [CALCITE-3318] Preserving CAST of STRING operands in comparison operator
URL: https://github.com/apache/calcite/pull/1437#discussion_r330807340
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/sql/dialect/BigQuerySqlDialect.java
 ##########
 @@ -89,6 +94,22 @@ public BigQuerySqlDialect(SqlDialect.Context context) {
     return emulateNullDirectionWithIsNull(node, nullsFirst, desc);
   }
 
+  @Override public boolean castRequiredForStringOperand(RexCall node) {
+    if (super.castRequiredForStringOperand(node)) {
+      return true;
+    }
+    RexNode operand = node.getOperands().get(0);
+    RelDataType castType = node.type;
+    if (operand instanceof RexLiteral) {
+      if (SqlTypeFamily.NUMERIC.contains(castType)) {
+        return true;
+      }
+      return false;
+    } else {
+      return true;
+    }
 
 Review comment:
   
   How about this?
   ```
   return !(operand instanceof RexLiteral)
       || SqlTypeFamily.NUMERIC.contains(node.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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services