-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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](hive)opt select count(*) stmt push down agg on parquet in hive . #22115
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d5e00d0
[opt](hive)opt select count(*) stmt push down agg on hive
hubgeter e8a593f
[opt](hive)opt select count(*) stmt push down agg on hive
hubgeter 16312f0
[opt](hive)opt select count(*) stmt push down agg on hive
hubgeter 686fabc
[opt](hive)opt select count(*) stmt push down agg on hive
hubgeter b53dc2d
[opt](hive)opt select count(*) stmt push down agg on hive
hubgeter ca0f80f
[opt](hive)opt select count(*) stmt push down agg on hive
hubgeter 886440d
[opt](hive)opt select count(*) stmt push down agg on parquet in hive .
hubgeter 83fc5dc
[opt](hive)opt select count(*) stmt push down agg on parquet in hive .
hubgeter 28317dc
[opt](hive)opt select count(*) stmt push down agg on parquet in hive .
hubgeter 0d9e4bf
[opt](hive)opt select count(*) stmt push down agg on parquet in hive .
hubgeter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,6 +113,19 @@ Status VScanNode::init(const TPlanNode& tnode, RuntimeState* state) { | |
} else { | ||
_max_pushdown_conditions_per_column = config::max_pushdown_conditions_per_column; | ||
} | ||
|
||
// tnode.olap_scan_node.push_down_agg_type_opt field is deprecated | ||
// Introduced a new field : tnode.push_down_agg_type_opt | ||
// | ||
// make it compatible here | ||
if (tnode.__isset.push_down_agg_type_opt) { | ||
_push_down_agg_type = tnode.push_down_agg_type_opt; | ||
} else if (tnode.olap_scan_node.__isset.push_down_agg_type_opt) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add some comment in code to explain these compatibility work |
||
_push_down_agg_type = tnode.olap_scan_node.push_down_agg_type_opt; | ||
|
||
} else { | ||
_push_down_agg_type = TPushAggOp::type::NONE; | ||
} | ||
return Status::OK(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,8 +55,11 @@ | |
import org.apache.doris.nereids.trees.plans.Plan; | ||
import org.apache.doris.nereids.trees.plans.algebra.Project; | ||
import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate; | ||
import org.apache.doris.nereids.trees.plans.logical.LogicalFileScan; | ||
import org.apache.doris.nereids.trees.plans.logical.LogicalOlapScan; | ||
import org.apache.doris.nereids.trees.plans.logical.LogicalProject; | ||
import org.apache.doris.nereids.trees.plans.logical.LogicalRelation; | ||
import org.apache.doris.nereids.trees.plans.physical.PhysicalFileScan; | ||
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashAggregate; | ||
import org.apache.doris.nereids.trees.plans.physical.PhysicalOlapScan; | ||
import org.apache.doris.nereids.trees.plans.physical.PhysicalStorageLayerAggregate; | ||
|
@@ -115,6 +118,20 @@ public List<Rule> buildRules() { | |
return storageLayerAggregate(agg, project, olapScan, ctx.cascadesContext); | ||
}) | ||
), | ||
RuleType.STORAGE_LAYER_AGGREGATE_WITH_PROJECT.build( | ||
logicalAggregate( | ||
logicalProject( | ||
logicalFileScan() | ||
) | ||
) | ||
.when(agg -> agg.isNormalized() && enablePushDownNoGroupAgg()) | ||
.thenApply(ctx -> { | ||
LogicalAggregate<LogicalProject<LogicalFileScan>> agg = ctx.root; | ||
LogicalProject<LogicalFileScan> project = agg.child(); | ||
LogicalFileScan fileScan = project.child(); | ||
return storageLayerAggregate(agg, project, fileScan, ctx.cascadesContext); | ||
}) | ||
), | ||
RuleType.ONE_PHASE_AGGREGATE_WITHOUT_DISTINCT.build( | ||
basePattern | ||
.when(agg -> agg.getDistinctArguments().size() == 0) | ||
|
@@ -190,14 +207,19 @@ && couldConvertToMulti(agg)) | |
private LogicalAggregate<? extends Plan> storageLayerAggregate( | ||
LogicalAggregate<? extends Plan> aggregate, | ||
@Nullable LogicalProject<? extends Plan> project, | ||
LogicalOlapScan olapScan, CascadesContext cascadesContext) { | ||
LogicalRelation logicalScan, CascadesContext cascadesContext) { | ||
final LogicalAggregate<? extends Plan> canNotPush = aggregate; | ||
|
||
KeysType keysType = olapScan.getTable().getKeysType(); | ||
if (keysType != KeysType.AGG_KEYS && keysType != KeysType.DUP_KEYS) { | ||
if (!(logicalScan instanceof LogicalOlapScan) && !(logicalScan instanceof LogicalFileScan)) { | ||
return canNotPush; | ||
} | ||
|
||
if (logicalScan instanceof LogicalOlapScan) { | ||
KeysType keysType = ((LogicalOlapScan) logicalScan).getTable().getKeysType(); | ||
if (keysType != KeysType.AGG_KEYS && keysType != KeysType.DUP_KEYS) { | ||
return canNotPush; | ||
} | ||
} | ||
List<Expression> groupByExpressions = aggregate.getGroupByExpressions(); | ||
if (!groupByExpressions.isEmpty() || !aggregate.getDistinctArguments().isEmpty()) { | ||
return canNotPush; | ||
|
@@ -213,8 +235,11 @@ private LogicalAggregate<? extends Plan> storageLayerAggregate( | |
if (!supportedAgg.keySet().containsAll(functionClasses)) { | ||
return canNotPush; | ||
} | ||
if (functionClasses.contains(Count.class) && keysType != KeysType.DUP_KEYS) { | ||
return canNotPush; | ||
if (logicalScan instanceof LogicalOlapScan) { | ||
KeysType keysType = ((LogicalOlapScan) logicalScan).getTable().getKeysType(); | ||
if (functionClasses.contains(Count.class) && keysType != KeysType.DUP_KEYS) { | ||
return canNotPush; | ||
} | ||
} | ||
if (aggregateFunctions.stream().anyMatch(fun -> fun.arity() > 1)) { | ||
return canNotPush; | ||
|
@@ -281,12 +306,15 @@ private LogicalAggregate<? extends Plan> storageLayerAggregate( | |
ExpressionUtils.collect(argumentsOfAggregateFunction, SlotReference.class::isInstance); | ||
|
||
List<SlotReference> usedSlotInTable = (List<SlotReference>) (List) Project.findProject(aggUsedSlots, | ||
(List<NamedExpression>) (List) olapScan.getOutput()); | ||
(List<NamedExpression>) (List) logicalScan.getOutput()); | ||
|
||
for (SlotReference slot : usedSlotInTable) { | ||
Column column = slot.getColumn().get(); | ||
if (keysType == KeysType.AGG_KEYS && !column.isKey()) { | ||
return canNotPush; | ||
if (logicalScan instanceof LogicalOlapScan) { | ||
KeysType keysType = ((LogicalOlapScan) logicalScan).getTable().getKeysType(); | ||
if (keysType == KeysType.AGG_KEYS && !column.isKey()) { | ||
return canNotPush; | ||
} | ||
} | ||
// The zone map max length of CharFamily is 512, do not | ||
// over the length: https://github.com/apache/doris/pull/6293 | ||
|
@@ -310,19 +338,41 @@ private LogicalAggregate<? extends Plan> storageLayerAggregate( | |
} | ||
} | ||
|
||
PhysicalOlapScan physicalOlapScan = (PhysicalOlapScan) new LogicalOlapScanToPhysicalOlapScan() | ||
.build() | ||
.transform(olapScan, cascadesContext) | ||
.get(0); | ||
if (project != null) { | ||
return aggregate.withChildren(ImmutableList.of( | ||
if (logicalScan instanceof LogicalOlapScan) { | ||
PhysicalOlapScan physicalScan = (PhysicalOlapScan) new LogicalOlapScanToPhysicalOlapScan() | ||
.build() | ||
.transform((LogicalOlapScan) logicalScan, cascadesContext) | ||
.get(0); | ||
|
||
if (project != null) { | ||
return aggregate.withChildren(ImmutableList.of( | ||
project.withChildren( | ||
ImmutableList.of(new PhysicalStorageLayerAggregate(physicalOlapScan, mergeOp))) | ||
)); | ||
ImmutableList.of(new PhysicalStorageLayerAggregate(physicalScan, mergeOp))) | ||
)); | ||
} else { | ||
return aggregate.withChildren(ImmutableList.of( | ||
new PhysicalStorageLayerAggregate(physicalScan, mergeOp) | ||
)); | ||
} | ||
|
||
} else if (logicalScan instanceof LogicalFileScan) { | ||
PhysicalFileScan physicalScan = (PhysicalFileScan) new LogicalFileScanToPhysicalFileScan() | ||
.build() | ||
.transform((LogicalFileScan) logicalScan, cascadesContext) | ||
.get(0); | ||
if (project != null) { | ||
return aggregate.withChildren(ImmutableList.of( | ||
project.withChildren( | ||
ImmutableList.of(new PhysicalStorageLayerAggregate(physicalScan, mergeOp))) | ||
)); | ||
} else { | ||
return aggregate.withChildren(ImmutableList.of( | ||
new PhysicalStorageLayerAggregate(physicalScan, mergeOp) | ||
)); | ||
} | ||
|
||
} else { | ||
return aggregate.withChildren(ImmutableList.of( | ||
new PhysicalStorageLayerAggregate(physicalOlapScan, mergeOp) | ||
)); | ||
return canNotPush; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you want PhysicalOlapScan physicalScan;
if (logicalScan instanceof LogicalOlapScan) {
physicalScan = (PhysicalOlapScan) new LogicalOlapScanToPhysicalOlapScan()
.build()
.transform((LogicalOlapScan) logicalScan, cascadesContext)
.get(0);
} else if (logicalScan instanceof LogicalFileScan) {
physicalScan = (PhysicalFileScan) new LogicalFileScanToPhysicalFileScan()
.build()
.transform((LogicalFileScan) logicalScan, cascadesContext)
.get(0);
} else {
return canNotPush;
}
if (project != null) {
return aggregate.withChildren(ImmutableList.of(
project.withChildren(
ImmutableList.of(new PhysicalStorageLayerAggregate(physicalScan, mergeOp)))
));
} else {
return aggregate.withChildren(ImmutableList.of(
new PhysicalStorageLayerAggregate(physicalScan, mergeOp)
));
} you will get this:
😭😤😭 |
||
} | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate with line 1388