-
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
Conversation
clang-tidy review says "All clean, LGTM! 👍" |
//fill one column is enough | ||
auto cols = block->mutate_columns(); | ||
for (auto& col : cols) { | ||
col->resize(rows); |
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.
The rows
maybe too large for the resize?
Normally, a block only return 4096 rows. But here you may return unlimited rows.
I think it should be splitted in batch?
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.
good idea
@@ -31,6 +31,12 @@ class Block; | |||
class GenericReader { | |||
public: | |||
virtual Status get_next_block(Block* block, size_t* read_rows, bool* eof) = 0; | |||
|
|||
virtual Status get_next_block(Block* block, size_t* read_rows, bool* eof, |
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.
How about merge these 2 methods?
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.
good idea , but i need append parameter TPushAggOp::type push_down_agg_type_opt
to all get_next_block
functions
|
||
if (_parent->push_down_agg_type_opt != TPushAggOp::type ::NONE) { | ||
//Prevent FE misjudging the "select count/min/max ..." statement | ||
if (Status::OK() == _cur_reader->get_next_block(_src_block_ptr, &read_rows, |
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.
So if here _cur_reader->get_next_block
return error, it will go on calling another get_next_block()
, just like a retry?
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.
I suggest that we should make sure FE give the right plan, and here we just use if...else
.
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.
Yes, because FE
needs to add a lot of redundant code to determine the file type in order to obtain the correct plan 。
gensrc/thrift/PlanNodes.thrift
Outdated
15: optional set<i32> output_column_unique_ids | ||
16: optional list<i32> distribute_column_ids | ||
17: optional i32 schema_version | ||
12: optional bool use_topn_opt |
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.
You can't modify the origin structure of thrift, or it will cause problem when upgrading.
You can mark the old push_down_agg_type_opt
as Deprecated
, and make some compatibility
when visiting this field
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.
good idea
be/src/vec/exec/scan/vscan_node.h
Outdated
@@ -351,6 +351,9 @@ class VScanNode : public ExecNode, public RuntimeFilterConsumer { | |||
std::unordered_map<std::string, int> _colname_to_slot_id; | |||
std::vector<int> _col_distribute_ids; | |||
|
|||
public: | |||
TPushAggOp::type push_down_agg_type_opt; |
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.
Better not using public to define a field
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.
OK
if (pushDownAggNoGroupingOp != null) { | ||
msg.olap_scan_node.setPushDownAggTypeOpt(pushDownAggNoGroupingOp); | ||
if (pushDownAggNoGroupingOp != TPushAggOp.NONE) { | ||
msg.setPushDownAggTypeOpt(pushDownAggNoGroupingOp); |
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.
I think we can ALWAYS set this field
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.
OK
} | ||
textParams.setColumnSeparator(hmsTable.getRemoteTable().getSd().getSerdeInfo().getParameters() | ||
.getOrDefault(PROP_FIELD_DELIMITER, DEFAULT_FIELD_DELIMITER)); | ||
textParams.setLineDelimiter(DEFAULT_LINE_DELIMITER); |
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.
Why changing this?
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.
I made a mistake 。There's no need to change here。
} | ||
|
||
String aggFunctionName = aggExpr.getFnName().getFunction(); | ||
if (aggFunctionName.equalsIgnoreCase("COUNT") && fileFormatType == TFileFormatType.FORMAT_PARQUET) { |
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.
Need to implement orc too
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.
OK
} | ||
|
||
@Override | ||
public boolean pushDownAggNoGroupingCheckCol(FunctionCallExpr aggExpr, Column col) { |
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.
For external table, always return false.
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.
when you use select count(*)
statement ,pushDownAggNoGroupingCheckCol
will not be executed .
if you use select count(a)
statement , pushDownAggNoGroupingCheckCol
will check col a.
clang-tidy review says "All clean, LGTM! 👍" |
1 similar comment
clang-tidy review says "All clean, LGTM! 👍" |
return aggregate.withChildren(ImmutableList.of( | ||
new PhysicalStorageLayerAggregate(physicalOlapScan, mergeOp) | ||
)); | ||
return canNotPush; |
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.
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:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project fe-core: Compilation failure: Compilation failure:
[ERROR] /mnt/datadisk1/changyuwei/doris2/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java:[345,72] incompatible types: org.apache.doris.nereids.trees.plans.physical.PhysicalRelation cannot be converted to org.apache.doris.nereids.trees.plans.physical.PhysicalCatalogRelation
[ERROR] /mnt/datadisk1/changyuwei/doris2/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java:[349,51] incompatible types: org.apache.doris.nereids.trees.plans.physical.PhysicalRelation cannot be converted to org.apache.doris.nereids.trees.plans.physical.PhysicalCatalogRelation
😭😤😭
col->resize(rows); | ||
} | ||
|
||
*read_rows = rows; |
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
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Add some comment in code to explain these compatibility work
Please add some test cases |
clang-tidy review says "All clean, LGTM! 👍" |
1 similar comment
clang-tidy review says "All clean, LGTM! 👍" |
clang-tidy review says "All clean, LGTM! 👍" |
1 similar comment
clang-tidy review says "All clean, LGTM! 👍" |
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.
LGTM
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
run buildall |
run buildall |
clang-tidy review says "All clean, LGTM! 👍" |
(From new machine)TeamCity pipeline, clickbench performance test result: |
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.
LGTM
PR approved by at least one committer and no changes requested. |
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.
LGTM
apache#22115) Optimization "select count(*) from table" stmtement , push down "count" type to BE. support file type : parquet ,orc in hive . 1. 4kfiles , 60kwline num before: 1 min 37.70 sec after: 50.18 sec 2. 50files , 60kwline num before: 1.12 sec after: 0.82 sec
apache#22115) Optimization "select count(*) from table" stmtement , push down "count" type to BE. support file type : parquet ,orc in hive . 1. 4kfiles , 60kwline num before: 1 min 37.70 sec after: 50.18 sec 2. 50files , 60kwline num before: 1.12 sec after: 0.82 sec
#22115) Optimization "select count(*) from table" stmtement , push down "count" type to BE. support file type : parquet ,orc in hive . 1. 4kfiles , 60kwline num before: 1 min 37.70 sec after: 50.18 sec 2. 50files , 60kwline num before: 1.12 sec after: 0.82 sec
apache#22115) Optimization "select count(*) from table" stmtement , push down "count" type to BE. support file type : parquet ,orc in hive . 1. 4kfiles , 60kwline num before: 1 min 37.70 sec after: 50.18 sec 2. 50files , 60kwline num before: 1.12 sec after: 0.82 sec
… with only one column. (apache#25222) after pr apache#22115 . Fixed the bug that when selecting count(*) from table, if the table has only one column, the aggregate count is not pushed down.
Proposed changes
after pr : #14827 and #12803
Optimization "select count(*) from table" stmtement , push down "count" type to
be
.support file type : parquet ,orc in hive .
4kfiles , 60kwline num
before: 1 min 37.70 sec
after: 50.18 sec
50files , 60kwline num
before: 1.12 sec
after: 0.82 sec
Further comments
If this is a relatively large or complex change, kick off the discussion at [email protected] by explaining why you chose the solution you did and what alternatives you considered, etc...