This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new c3e4f0c4023 [fix](Nereids) remove useless substr of string like type cast (#29997) c3e4f0c4023 is described below commit c3e4f0c402358a402d1e05a20b5358ea7fe58d5b Author: morrySnow <101034200+morrys...@users.noreply.github.com> AuthorDate: Tue Jan 16 20:16:53 2024 +0800 [fix](Nereids) remove useless substr of string like type cast (#29997) --- .../java/org/apache/doris/nereids/rules/analysis/BindSink.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSink.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSink.java index 4ce7350cf2d..7dbb6b3e1e1 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSink.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSink.java @@ -297,10 +297,13 @@ public class BindSink implements AnalysisRuleFactory { DataType inputType = expr.getDataType(); DataType targetType = DataType.fromCatalogType(table.getFullSchema().get(i).getType()); Expression castExpr = expr; - if (isSourceAndTargetStringLikeType(inputType, targetType)) { + // TODO move string like type logic into TypeCoercionUtils#castIfNotSameType + if (isSourceAndTargetStringLikeType(inputType, targetType) && !inputType.equals(targetType)) { int sourceLength = ((CharacterType) inputType).getLen(); int targetLength = ((CharacterType) targetType).getLen(); - if (sourceLength >= targetLength && targetLength >= 0) { + if (sourceLength == targetLength) { + castExpr = TypeCoercionUtils.castIfNotSameType(castExpr, targetType); + } else if (sourceLength > targetLength && targetLength >= 0) { castExpr = new Substring(castExpr, Literal.of(1), Literal.of(targetLength)); } else if (targetType.isStringType()) { castExpr = new Cast(castExpr, StringType.INSTANCE); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org