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

[Improvement](scan) Remove redundant predicates on scan node #23374

Merged
merged 3 commits into from
Aug 25, 2023
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
7 changes: 5 additions & 2 deletions be/src/pipeline/exec/olap_scan_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,12 @@ Status OlapScanLocalState::_should_push_down_function_filter(
}

bool OlapScanLocalState::_should_push_down_common_expr() {
return state()->enable_common_expr_pushdown() && _storage_no_merge();
}

bool OlapScanLocalState::_storage_no_merge() {
auto& p = _parent->cast<OlapScanOperatorX>();
return state()->enable_common_expr_pushdown() &&
(p._olap_scan_node.keyType == TKeysType::DUP_KEYS ||
return (p._olap_scan_node.keyType == TKeysType::DUP_KEYS ||
(p._olap_scan_node.keyType == TKeysType::UNIQUE_KEYS &&
p._olap_scan_node.__isset.enable_unique_key_merge_on_write &&
p._olap_scan_node.enable_unique_key_merge_on_write));
Expand Down
2 changes: 2 additions & 0 deletions be/src/pipeline/exec/olap_scan_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class OlapScanLocalState final : public ScanLocalState {

bool _should_push_down_common_expr() override;

bool _storage_no_merge() override;

Status _init_scanners(std::list<vectorized::VScannerSPtr>* scanners) override;

void add_filter_info(int id, const PredicateFilterInfo& info);
Expand Down
2 changes: 1 addition & 1 deletion be/src/pipeline/exec/scan_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ Status ScanLocalState::_normalize_predicate(const vectorized::VExprSPtr& conjunc
}

if (pdt == vectorized::VScanNode::PushDownType::ACCEPTABLE &&
_is_key_column(slot->col_name())) {
(_is_key_column(slot->col_name()) || _storage_no_merge())) {
output_expr = nullptr;
return Status::OK();
} else {
Expand Down
5 changes: 3 additions & 2 deletions be/src/pipeline/exec/scan_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ScanLocalState : public PipelineXLocalState, public vectorized::RuntimeFil
ENABLE_FACTORY_CREATOR(ScanLocalState);
ScanLocalState(RuntimeState* state, OperatorXBase* parent);

virtual Status init(RuntimeState* state, LocalStateInfo& info) override;
Status init(RuntimeState* state, LocalStateInfo& info) override;

bool ready_to_read();

Expand Down Expand Up @@ -89,8 +89,9 @@ class ScanLocalState : public PipelineXLocalState, public vectorized::RuntimeFil
RETURN_IF_ERROR(_normalize_conjuncts());
return Status::OK();
}

virtual bool _should_push_down_common_expr() { return false; }

virtual bool _storage_no_merge() { return true; }
virtual bool _is_key_column(const std::string& col_name) { return false; }
virtual vectorized::VScanNode::PushDownType _should_push_down_bloom_filter() {
return vectorized::VScanNode::PushDownType::UNACCEPTABLE;
Expand Down
10 changes: 1 addition & 9 deletions be/src/vec/exec/scan/new_olap_scan_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,6 @@ Status NewOlapScanNode::_should_push_down_function_filter(VectorizedFnCall* fn_c
return Status::OK();
}

bool NewOlapScanNode::_should_push_down_common_expr() {
return _state->enable_common_expr_pushdown() &&
(_olap_scan_node.keyType == TKeysType::DUP_KEYS ||
(_olap_scan_node.keyType == TKeysType::UNIQUE_KEYS &&
_olap_scan_node.__isset.enable_unique_key_merge_on_write &&
_olap_scan_node.enable_unique_key_merge_on_write));
}

// PlanFragmentExecutor will call this method to set scan range
// Doris scan range is defined in thrift file like this
// struct TPaloScanRange {
Expand Down Expand Up @@ -434,7 +426,7 @@ Status NewOlapScanNode::_init_scanners(std::list<VScannerSPtr>* scanners) {
message += conjunct->root()->debug_string();
}
}
_runtime_profile->add_info_string("RemainedDownPredicates", message);
_runtime_profile->add_info_string("RemainedPredicates", message);
}

if (!_olap_scan_node.output_column_unique_ids.empty()) {
Expand Down
11 changes: 10 additions & 1 deletion be/src/vec/exec/scan/new_olap_scan_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,16 @@ class NewOlapScanNode : public VScanNode {

PushDownType _should_push_down_is_null_predicate() override { return PushDownType::ACCEPTABLE; }

bool _should_push_down_common_expr() override;
bool _should_push_down_common_expr() override {
return _state->enable_common_expr_pushdown() && _storage_no_merge();
}

bool _storage_no_merge() override {
return (_olap_scan_node.keyType == TKeysType::DUP_KEYS ||
(_olap_scan_node.keyType == TKeysType::UNIQUE_KEYS &&
_olap_scan_node.__isset.enable_unique_key_merge_on_write &&
_olap_scan_node.enable_unique_key_merge_on_write));
}

Status _init_scanners(std::list<VScannerSPtr>* scanners) override;

Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/exec/scan/vscan_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,8 @@ Status VScanNode::_normalize_predicate(const VExprSPtr& conjunct_expr_root, VExp
return Status::OK();
}

if (pdt == PushDownType::ACCEPTABLE && _is_key_column(slot->col_name())) {
if (pdt == PushDownType::ACCEPTABLE &&
(_is_key_column(slot->col_name()) || _storage_no_merge())) {
output_expr = nullptr;
return Status::OK();
} else {
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/exec/scan/vscan_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ class VScanNode : public ExecNode, public RuntimeFilterConsumer {

virtual bool _should_push_down_common_expr() { return false; }

virtual bool _storage_no_merge() { return false; }

virtual PushDownType _should_push_down_bloom_filter() { return PushDownType::UNACCEPTABLE; }

virtual PushDownType _should_push_down_bitmap_filter() { return PushDownType::UNACCEPTABLE; }
Expand Down