danny0405 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_r335992408
##########
File path:
core/src/main/java/org/apache/calcite/sql/dialect/BigQuerySqlDialect.java
##########
@@ -99,6 +103,14 @@ public BigQuerySqlDialect(SqlDialect.Context context) {
return emulateNullDirectionWithIsNull(node, nullsFirst, desc);
}
+ @Override public boolean supportsImplicitTypeCoercion(RexCall node) {
+ if (!super.supportsImplicitTypeCoercion(node)) {
+ return false;
+ }
+ RexNode operand = node.getOperands().get(0);
+ return operand instanceof RexLiteral &&
!SqlTypeFamily.NUMERIC.contains(node.type);
+ }
+
Review comment:
From this code, you mean we can strip the cast for BigQuery only if:
- The first operand is a STRING literal
- The second operand is not a NUMERIC
This is weird, can you please conform the type coercion rules ? Especially
for the operators we strip the cast from: `>` `>=` `<` `<=` `IS NOT DISTINCT
FROM` `<>`
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services