[opt](nereids) disable infer column name when query (#27450)
Disable infer column name when query, because it cause some errors when using BI tools This feature is firstly developed by #26055
This commit is contained in:
@ -554,11 +554,14 @@ public class SelectStmt extends QueryStmt {
|
||||
}
|
||||
resultExprs.add(rewriteQueryExprByMvColumnExpr(item.getExpr(), analyzer));
|
||||
String columnLabel = null;
|
||||
// Infer column name when item is expr, both query and ddl
|
||||
columnLabel = item.toColumnLabel(i);
|
||||
Class<? extends StatementBase> statementClazz = analyzer.getRootStatementClazz();
|
||||
if (statementClazz != null
|
||||
&& (!QueryStmt.class.isAssignableFrom(statementClazz) || hasOutFileClause())) {
|
||||
// Infer column name when item is expr
|
||||
columnLabel = item.toColumnLabel(i);
|
||||
}
|
||||
if (columnLabel == null) {
|
||||
// column label without position is applicative for query and do not infer
|
||||
// column name when item is expr
|
||||
// use original column label
|
||||
columnLabel = item.toColumnLabel();
|
||||
}
|
||||
SlotRef aliasRef = new SlotRef(null, columnLabel);
|
||||
|
||||
@ -70,6 +70,7 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
|
||||
import org.apache.doris.nereids.trees.plans.logical.LogicalRepeat;
|
||||
import org.apache.doris.nereids.trees.plans.logical.LogicalResultSink;
|
||||
import org.apache.doris.nereids.trees.plans.logical.LogicalSetOperation;
|
||||
import org.apache.doris.nereids.trees.plans.logical.LogicalSink;
|
||||
import org.apache.doris.nereids.trees.plans.logical.LogicalSort;
|
||||
import org.apache.doris.nereids.trees.plans.logical.LogicalSubQueryAlias;
|
||||
import org.apache.doris.nereids.trees.plans.logical.LogicalTVFRelation;
|
||||
@ -581,8 +582,15 @@ public class BindExpression implements AnalysisRuleFactory {
|
||||
})
|
||||
),
|
||||
RuleType.BINDING_RESULT_SINK.build(
|
||||
unboundResultSink().then(sink -> {
|
||||
|
||||
unboundResultSink().thenApply(ctx -> {
|
||||
LogicalSink<Plan> sink = ctx.root;
|
||||
if (ctx.connectContext.getState().isQuery()) {
|
||||
List<NamedExpression> outputExprs = sink.child().getOutput().stream()
|
||||
.map(NamedExpression.class::cast)
|
||||
.collect(ImmutableList.toImmutableList());
|
||||
return new LogicalResultSink<>(outputExprs, sink.child());
|
||||
}
|
||||
// Should infer column name for expression when query command
|
||||
final ImmutableListMultimap.Builder<ExprId, Integer> exprIdToIndexMapBuilder =
|
||||
ImmutableListMultimap.builder();
|
||||
List<Slot> childOutput = sink.child().getOutput();
|
||||
|
||||
Reference in New Issue
Block a user