morrySnow commented on code in PR #49167: URL: https://github.com/apache/doris/pull/49167#discussion_r2005119512
########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java: ########## @@ -1019,19 +1021,26 @@ private void generatedColumnCheck(ConnectContext ctx) { Expression boundSlotExpression = SlotReplacer.INSTANCE.replace(parsedExpression, columnToSlotReference); Scope scope = new Scope(slots); ExpressionAnalyzer analyzer = new ExpressionAnalyzer(null, scope, cascadesContext, false, false); - Expression expr; + Expression expression; try { - expr = analyzer.analyze(boundSlotExpression, new ExpressionRewriteContext(cascadesContext)); + expression = analyzer.analyze(boundSlotExpression, new ExpressionRewriteContext(cascadesContext)); } catch (AnalysisException e) { throw new AnalysisException("In generated column '" + column.getName() + "', " + Utils.convertFirstChar(e.getMessage())); } - checkExpressionInGeneratedColumn(expr, column, nameToColumnDefinition); - TypeCoercionUtils.checkCanCastTo(expr.getDataType(), column.getType()); + checkExpressionInGeneratedColumn(expression, column, nameToColumnDefinition); + TypeCoercionUtils.checkCanCastTo(expression.getDataType(), column.getType()); ExpressionToExpr translator = new ExpressionToExpr(i, translateMap); - Expr e = expr.accept(translator, planTranslatorContext); - info.get().setExpr(e); - exprAndnames.add(new GeneratedColumnUtil.ExprAndname(e.clone(), column.getName())); + Expr expr = expression.accept(translator, planTranslatorContext); + info.get().setExpr(expr); + Expression expressionForLoad = expression.rewriteDownShortCircuit(e -> { + if (e instanceof SlotReference && !(e.getDataType() instanceof CharacterType)) { + return new Cast(e, e.getDataType()); + } + return e; + }); Review Comment: add comment to explain why need cast e to itself's 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. 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