[opt] use correct column label when execute query in FE (#25372)

SET @a = '4';
SELECT @a;

previous:
+-----+
| '4' |
+-----+
| 4   |
+-----+

current:
+----+
| @a |
+----+
| 4  |
+----+
This commit is contained in:
morrySnow
2023-10-16 15:03:33 +08:00
committed by GitHub
parent 292ccaeda8
commit 1a27ac8d56
3 changed files with 5 additions and 4 deletions

View File

@ -510,7 +510,7 @@ public class BuiltinScalarFunctions implements FunctionHelper {
scalar(CurrentDate.class, "curdate", "current_date"),
scalar(CurrentTime.class, "curtime", "current_time"),
scalar(CurrentUser.class, "current_user"),
scalar(Database.class, "database"),
scalar(Database.class, "database", "schema"),
scalar(Date.class, "date"),
scalar(DateDiff.class, "datediff"),
scalar(DateFormat.class, "date_format"),

View File

@ -450,10 +450,11 @@ public class NereidsPlanner extends Planner {
List<String> data = Lists.newArrayList();
for (int i = 0; i < physicalOneRowRelation.getProjects().size(); i++) {
NamedExpression item = physicalOneRowRelation.getProjects().get(i);
NamedExpression output = physicalPlan.getOutput().get(i);
Expression expr = item.child(0);
if (expr instanceof Literal) {
LiteralExpr legacyExpr = ((Literal) expr).toLegacyLiteral();
columns.add(new Column(item.getName(), item.getDataType().toCatalogDataType()));
columns.add(new Column(output.getName(), output.getDataType().toCatalogDataType()));
super.handleLiteralInFe(legacyExpr, data);
} else {
return Optional.empty();

View File

@ -22,7 +22,7 @@ import org.apache.doris.nereids.trees.expressions.functions.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.shape.LeafExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.StringType;
import com.google.common.collect.ImmutableList;
@ -35,7 +35,7 @@ public class CurrentUser extends ScalarFunction
implements LeafExpression, ExplicitlyCastableSignature, AlwaysNotNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args()
FunctionSignature.ret(StringType.INSTANCE).args()
);
public CurrentUser() {