Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[opt](Nereids) use 1 instead narrowest column when do column pruning #41548

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions be/src/pipeline/exec/table_function_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,6 @@ TableFunctionOperatorX::TableFunctionOperatorX(ObjectPool* pool, const TPlanNode

Status TableFunctionOperatorX::_prepare_output_slot_ids(const TPlanNode& tnode) {
// Prepare output slot ids
if (tnode.table_function_node.outputSlotIds.empty()) {
return Status::InternalError("Output slots of table function node is empty");
}
SlotId max_id = -1;
for (auto slot_id : tnode.table_function_node.outputSlotIds) {
if (slot_id > max_id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.expressions.functions.NoneMovableFunction;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Uuid;
import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.PlanType;
import org.apache.doris.nereids.trees.plans.algebra.Project;
Expand Down Expand Up @@ -85,7 +86,7 @@ private LogicalProject(List<NamedExpression> projects, boolean isDistinct,
Preconditions.checkArgument(!projects.isEmpty() || !(child instanceof Unbound),
"projects can not be empty when child plan is unbound");
this.projects = projects.isEmpty()
? ImmutableList.of(ExpressionUtils.selectMinimumColumn(child.get(0).getOutput()))
? ImmutableList.of(new Alias(new TinyIntLiteral((byte) 1)))
: projects;
this.projectsSet = Suppliers.memoize(() -> ImmutableSet.copyOf(this.projects));
this.isDistinct = isDistinct;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ void testCountStarProject() {
logicalAggregate(
logicalProject().when(
project -> project.getProjects().size() == 1
&& project.getProjects().get(0) instanceof SlotReference
&& "o_orderdate".equals(project.getProjects().get(0).toSql()))))
&& !(project.getProjects().get(0) instanceof SlotReference)
)))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
package org.apache.doris.nereids.rules.rewrite;

import org.apache.doris.nereids.trees.expressions.NamedExpression;
import org.apache.doris.nereids.trees.expressions.SlotReference;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
import org.apache.doris.nereids.types.DoubleType;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.TinyIntType;
import org.apache.doris.nereids.util.MemoPatternMatchSupported;
import org.apache.doris.nereids.util.PlanChecker;
import org.apache.doris.utframe.TestWithFeService;
Expand Down Expand Up @@ -188,7 +189,7 @@ public void pruneCountStarStmt() {
logicalAggregate(
logicalProject(
logicalOlapScan()
).when(p -> p.getProjects().get(0).getDataType().equals(IntegerType.INSTANCE)
).when(p -> p.getProjects().get(0).getDataType().equals(TinyIntType.INSTANCE)
&& p.getProjects().size() == 1)
)
);
Expand All @@ -203,7 +204,7 @@ public void pruneCountConstantStmt() {
logicalAggregate(
logicalProject(
logicalOlapScan()
).when(p -> p.getProjects().get(0).getDataType().equals(IntegerType.INSTANCE)
).when(p -> p.getProjects().get(0).getDataType().equals(TinyIntType.INSTANCE)
&& p.getProjects().size() == 1)
)
);
Expand All @@ -218,7 +219,7 @@ public void pruneCountConstantAndSumConstantStmt() {
logicalAggregate(
logicalProject(
logicalOlapScan()
).when(p -> p.getProjects().get(0).getDataType().equals(IntegerType.INSTANCE)
).when(p -> p.getProjects().get(0).getDataType().equals(TinyIntType.INSTANCE)
&& p.getProjects().size() == 1)
)
);
Expand All @@ -233,7 +234,7 @@ public void pruneCountStarAndSumConstantStmt() {
logicalAggregate(
logicalProject(
logicalOlapScan()
).when(p -> p.getProjects().get(0).getDataType().equals(IntegerType.INSTANCE)
).when(p -> p.getProjects().get(0).getDataType().equals(TinyIntType.INSTANCE)
&& p.getProjects().size() == 1)
)
);
Expand Down Expand Up @@ -283,9 +284,7 @@ public void pruneColumnForOneSideOnCrossJoin() {
"internal.test.student.id",
"internal.test.student.name"))),
logicalProject(logicalRelation())
.when(p -> getOutputQualifiedNames(p)
.containsAll(ImmutableList.of(
"internal.test.score.sid")))
.when(p -> p.getProjects().stream().noneMatch(SlotReference.class::isInstance))
)
)
);
Expand Down
Loading
Loading