Skip to content

Commit

Permalink
[Bug] Fix bug push value predicate of unique table when have sequence…
Browse files Browse the repository at this point in the history
… column (#10060)

Co-authored-by: lihaopeng <[email protected]>
  • Loading branch information
HappenLee and lihaopeng authored Jun 14, 2022
1 parent 59b3023 commit 14bc971
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions be/src/olap/rowset/beta_rowset_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ Status BetaRowsetReader::init(RowsetReaderContext* read_context) {
read_context->predicates->begin(),
read_context->predicates->end());
}
// if unique table with rowset [0-x] or [0-1] [2-y] [...],
// value column predicates can be pushdown on rowset [0-x] or [2-y]
if (_rowset->keys_type() == UNIQUE_KEYS &&
(_rowset->start_version() == 0 || _rowset->start_version() == 2)) {

if (_should_push_down_value_predicates()) {
if (read_context->value_predicates != nullptr) {
read_options.column_predicates.insert(read_options.column_predicates.end(),
read_context->value_predicates->begin(),
Expand Down Expand Up @@ -237,4 +235,12 @@ Status BetaRowsetReader::next_block(vectorized::Block* block) {
return Status::OK();
}

bool BetaRowsetReader::_should_push_down_value_predicates() const {
// if unique table with rowset [0-x] or [0-1] [2-y] [...],
// value column predicates can be pushdown on rowset [0-x] or [2-y], [2-y] must be compaction and not overlapping
return _rowset->keys_type() == UNIQUE_KEYS &&
(_rowset->start_version() == 0 || _rowset->start_version() == 2) &&
!_rowset->_rowset_meta->is_segments_overlapping();
}

} // namespace doris
2 changes: 2 additions & 0 deletions be/src/olap/rowset/beta_rowset_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class BetaRowsetReader : public RowsetReader {
RowsetTypePB type() const override { return RowsetTypePB::BETA_ROWSET; }

private:
bool _should_push_down_value_predicates() const;

std::unique_ptr<Schema> _schema;
RowsetReaderContext* _context;
BetaRowsetSharedPtr _rowset;
Expand Down

0 comments on commit 14bc971

Please sign in to comment.