morrySnow commented on code in PR #29601: URL: https://github.com/apache/doris/pull/29601#discussion_r1442634223
########## fe/fe-core/src/main/java/org/apache/doris/nereids/util/TypeCoercionUtils.java: ########## @@ -505,11 +505,30 @@ public static <T extends BinaryOperator> T processCharacterLiteralInBinaryOperat && !left.getDataType().isStringLikeType()) { right = TypeCoercionUtils.characterLiteralTypeCoercion( ((Literal) right).getStringValue(), left.getDataType()).orElse(right); - } return (T) op.withChildren(left, right); } + /** + * change target type to StringType when literal cast to target type failed + */ + public static DataType processCharacterLiteralInBinaryOperatorWithTargetType(Expression left, Expression right, + DataType target) { + if (left instanceof Literal && ((Literal) left).isStringLikeLiteral()) { + if (!TypeCoercionUtils.characterLiteralTypeCoercion(((Literal) left).getStringValue(), target) + .isPresent()) { + return StringType.INSTANCE; + } + } + if (right instanceof Literal && ((Literal) right).isStringLikeLiteral()) { Review Comment: this change will lead to behavior diff between literal and data in table. -- 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-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org