Skip to content
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
2 changes: 0 additions & 2 deletions be/src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1084,8 +1084,6 @@ DEFINE_mInt32(tablet_schema_cache_recycle_interval, "86400");

DEFINE_Bool(exit_on_exception, "false")

DEFINE_Bool(ignore_always_true_predicate_for_segment, "true");

// clang-format off
#ifdef BE_TEST
// test s3
Expand Down
3 changes: 0 additions & 3 deletions be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1141,9 +1141,6 @@ DECLARE_mInt32(tablet_schema_cache_recycle_interval);
// Use `LOG(FATAL)` to replace `throw` when true
DECLARE_mBool(exit_on_exception);

// Remove predicate that is always true for a segment.
DECLARE_Bool(ignore_always_true_predicate_for_segment);

#ifdef BE_TEST
// test s3
DECLARE_String(test_s3_resource);
Expand Down
4 changes: 0 additions & 4 deletions be/src/olap/column_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,6 @@ class ColumnPredicate {
return true;
}

virtual bool is_always_true(const std::pair<WrapperField*, WrapperField*>& statistic) const {
return false;
}

virtual bool evaluate_del(const std::pair<WrapperField*, WrapperField*>& statistic) const {
return false;
}
Expand Down
25 changes: 0 additions & 25 deletions be/src/olap/comparison_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ class ComparisonPredicateBase : public ColumnPredicate {
return _operator(*reinterpret_cast<const T*>(statistic.ELE->cell_ptr()), _value); \
}

using WarpperFieldType = std::conditional_t<Type == TYPE_DATE, uint24_t, T>;

bool evaluate_and(const std::pair<WrapperField*, WrapperField*>& statistic) const override {
if (statistic.first->is_null()) {
return true;
Expand Down Expand Up @@ -204,29 +202,6 @@ class ComparisonPredicateBase : public ColumnPredicate {
}
}

bool is_always_true(const std::pair<WrapperField*, WrapperField*>& statistic) const override {
if (statistic.first->is_null() || statistic.second->is_null()) {
return false;
}

T tmp_min_value {};
T tmp_max_value {};
memcpy((char*)(&tmp_min_value), statistic.first->cell_ptr(), sizeof(WarpperFieldType));
memcpy((char*)(&tmp_max_value), statistic.second->cell_ptr(), sizeof(WarpperFieldType));

if constexpr (PT == PredicateType::LT) {
return _value > tmp_max_value;
} else if constexpr (PT == PredicateType::LE) {
return _value >= tmp_max_value;
} else if constexpr (PT == PredicateType::GT) {
return _value < tmp_min_value;
} else if constexpr (PT == PredicateType::GE) {
return _value <= tmp_min_value;
}

return false;
}

bool evaluate_del(const std::pair<WrapperField*, WrapperField*>& statistic) const override {
if (statistic.first->is_null() || statistic.second->is_null()) {
return false;
Expand Down
26 changes: 0 additions & 26 deletions be/src/olap/rowset/segment_v2/column_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "io/fs/file_reader.h"
#include "olap/block_column_predicate.h"
#include "olap/column_predicate.h"
#include "olap/comparison_predicate.h"
#include "olap/decimal12.h"
#include "olap/inverted_index_parser.h"
#include "olap/iterators.h"
Expand Down Expand Up @@ -340,31 +339,6 @@ bool ColumnReader::match_condition(const AndBlockColumnPredicate* col_predicates
col_predicates);
}

bool ColumnReader::prune_predicates_by_zone_map(std::vector<ColumnPredicate*>& predicates,
const int column_id) const {
if (_zone_map_index == nullptr) {
return false;
}

FieldType type = _type_info->type();
std::unique_ptr<WrapperField> min_value(WrapperField::create_by_type(type, _meta_length));
std::unique_ptr<WrapperField> max_value(WrapperField::create_by_type(type, _meta_length));
_parse_zone_map(*_segment_zone_map, min_value.get(), max_value.get());

auto pruned = false;
for (auto it = predicates.begin(); it != predicates.end();) {
auto predicate = *it;
if (predicate->column_id() == column_id &&
predicate->is_always_true({min_value.get(), max_value.get()})) {
pruned = true;
it = predicates.erase(it);
} else {
++it;
}
}
return pruned;
}

void ColumnReader::_parse_zone_map(const ZoneMapPB& zone_map, WrapperField* min_value_container,
WrapperField* max_value_container) const {
// min value and max value are valid if has_not_null is true
Expand Down
3 changes: 0 additions & 3 deletions be/src/olap/rowset/segment_v2/column_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@ class ColumnReader {

bool is_empty() const { return _num_rows == 0; }

bool prune_predicates_by_zone_map(std::vector<ColumnPredicate*>& predicates,
const int column_id) const;

CompressionTypePB get_compression() const { return _meta_compression; }

uint64_t num_rows() const { return _num_rows; }
Expand Down
20 changes: 1 addition & 19 deletions be/src/olap/rowset/segment_v2/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Status Segment::new_iterator(SchemaSPtr schema, const StorageReadOptions& read_o
return Status::OK();
}
}

if (read_options.use_topn_opt) {
auto query_ctx = read_options.runtime_state->get_query_ctx();
auto runtime_predicate = query_ctx->get_runtime_predicate().get_predictate();
Expand Down Expand Up @@ -174,25 +175,6 @@ Status Segment::new_iterator(SchemaSPtr schema, const StorageReadOptions& read_o
iter->reset(new SegmentIterator(this->shared_from_this(), schema));
}

if (config::ignore_always_true_predicate_for_segment &&
read_options.io_ctx.reader_type == ReaderType::READER_QUERY &&
!read_options.column_predicates.empty()) {
auto pruned_predicates = read_options.column_predicates;
auto pruned = false;
for (auto& it : _column_readers) {
if (it.second->prune_predicates_by_zone_map(pruned_predicates, it.first)) {
pruned = true;
}
}

if (pruned) {
auto options_with_pruned_predicates = read_options;
options_with_pruned_predicates.column_predicates = pruned_predicates;
LOG(INFO) << "column_predicates pruned from " << read_options.column_predicates.size()
<< " to " << pruned_predicates.size();
return iter->get()->init(options_with_pruned_predicates);
}
}
return iter->get()->init(read_options);
}

Expand Down
25 changes: 0 additions & 25 deletions regression-test/data/query_p0/test_select_with_predicate_prune.out

This file was deleted.

This file was deleted.