[fix](Nereids) Make the case sensitivity of the result labels compatible with MySQL (#31510)

SQL: SELECT iD FROM t1
before the label was: id
after this PR the label will be: iD
This commit is contained in:
morrySnow
2024-02-28 18:33:42 +08:00
committed by yiguolei
parent ddb37d7371
commit 153c775b37
5 changed files with 45 additions and 28 deletions

View File

@ -107,9 +107,9 @@ public class CheckAfterRewrite extends OneAnalysisRuleFactory {
.collect(Collectors.toSet());
notFromChildren = removeValidSlotsNotFromChildren(notFromChildren, childrenOutput);
if (!notFromChildren.isEmpty()) {
if (plan.child(0) instanceof LogicalAggregate) {
if (plan.arity() != 0 && plan.child(0) instanceof LogicalAggregate) {
throw new AnalysisException(String.format("%s not in agg's output", notFromChildren
.stream().map(slot -> slot.getName()).collect(Collectors.joining(", "))));
.stream().map(NamedExpression::getName).collect(Collectors.joining(", "))));
} else {
throw new AnalysisException(String.format(
"Input slot(s) not in child's output: %s in plan: %s,"

View File

@ -307,7 +307,9 @@ public class SlotBinder extends SubExprAnalyzer {
//TODO: handle name parts more than three.
throw new AnalysisException("Not supported name: "
+ StringUtils.join(nameParts, "."));
}).collect(Collectors.toList());
})
.map(s -> s.withName(unboundSlot.getNameParts().get(unboundSlot.getNameParts().size() - 1)))
.collect(Collectors.toList());
}
public static boolean compareDbName(String boundedDbName, String unBoundDbName) {

View File

@ -150,6 +150,16 @@ public class ArrayItemReference extends NamedExpression implements ExpectsInputT
return new ArrayItemSlot(exprId, name, dataType, nullable);
}
@Override
public ArrayItemSlot withName(String name) {
return new ArrayItemSlot(exprId, name, dataType, nullable);
}
@Override
public SlotReference withNullable(boolean newNullable) {
return new ArrayItemSlot(exprId, name, dataType, nullable);
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitArrayItemSlot(this, context);

View File

@ -73,4 +73,9 @@ public class MarkJoinSlotReference extends SlotReference implements SlotNotFromC
public MarkJoinSlotReference withExprId(ExprId exprId) {
return new MarkJoinSlotReference(exprId, name, existsHasAgg);
}
@Override
public SlotReference withName(String name) {
return new MarkJoinSlotReference(exprId, name, existsHasAgg);
}
}