github-actions[bot] commented on code in PR #61918: URL: https://github.com/apache/doris/pull/61918#discussion_r3025520483
########## fe/fe-core/src/main/java/org/apache/doris/analysis/ExprToExprNameVisitor.java: ########## @@ -0,0 +1,65 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.analysis; + +import org.apache.doris.common.NameFormatUtils; + +/** + * Visitor that computes the "expr name" for an {@link Expr} tree. + * + * <p>The expr name is a short, normalized identifier used for column labels + * and other metadata — it is <b>not</b> a full SQL representation. + * + * <ul> + * <li>{@link SlotRef} → raw column name</li> + * <li>{@link FunctionCallExpr} → normalized function name</li> + * <li>{@link ColumnRefExpr} → normalized column name</li> + * <li>{@link LiteralExpr} (all subtypes) → {@code "literal"}</li> + * <li>Everything else → normalized simple class name</li> + * </ul> + */ +public class ExprToExprNameVisitor extends ExprVisitor<String, Void> { + + public static final ExprToExprNameVisitor INSTANCE = new ExprToExprNameVisitor(); + + private ExprToExprNameVisitor() { + } + + @Override + public String visit(Expr expr, Void context) { + if (expr instanceof LiteralExpr) { + return "literal"; + } + return NameFormatUtils.normalizeName(expr.getClass().getSimpleName(), Expr.DEFAULT_EXPR_NAME); + } + + @Override + public String visitSlotRef(SlotRef expr, Void context) { + return expr.getCol(); + } + + @Override + public String visitFunctionCallExpr(FunctionCallExpr expr, Void context) { Review Comment: This no longer preserves the old `FunctionCallExpr.getExprName()` behavior for `LambdaFunctionCallExpr`. `LambdaFunctionCallExpr.accept()` dispatches to `visitLambdaFunctionCallExpr()`, but this visitor only overrides `visitFunctionCallExpr()`. Because `ExprVisitor.visitLambdaFunctionCallExpr()` falls back to `visit()`, the result becomes `lambda_function_call_expr` instead of the normalized function name. Before this refactor, `LambdaFunctionCallExpr` inherited `FunctionCallExpr.getExprName()`, so the two behaviors were equivalent. This replacement breaks any function-name-based dispatch that runs on lambda or high-order function expressions. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
