lowka commented on code in PR #4034: URL: https://github.com/apache/ignite-3/pull/4034#discussion_r1669629075
########## modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/IgniteTypeCoercion.java: ########## @@ -91,6 +95,34 @@ public boolean binaryComparisonCoercion(SqlCallBinding binding) { } } + static @Nullable SqlLiteral extractLiteral(SqlCall call, SqlValidator validator) { + if (call.getOperator().getKind() == SqlKind.CAST) { + SqlNode lit = call.getOperandList().get(0); + SqlDataTypeSpec type = (SqlDataTypeSpec) call.getOperandList().get(1); + RelDataType derived = type.deriveType(validator); + if (lit instanceof SqlNumericLiteral && SqlTypeUtil.isCharacter(derived)) { + return (SqlNumericLiteral) lit; + } else { + return null; + } + } + + if (SqlKind.BINARY_COMPARISON.contains(call.getOperator().getKind()) && call.getOperandList().size() == 2) { + for (SqlNode node : call.getOperandList()) { + if (node instanceof SqlCharStringLiteral) { + return (SqlCharStringLiteral) node; + } else if (node.getKind() == SqlKind.CAST) { + SqlNode lit = ((SqlCall) node).getOperandList().get(0); + if (lit instanceof SqlNumericLiteral) { Review Comment: > if (call.getOperator().getKind() == SqlKind.CAST) { Returns a numeric literal if a target type is a character type. But this one always returns a numeric literal and does not check a target type. Is this intentional? -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org