diff --git a/be/src/format/reader/column_mapper.cpp b/be/src/format/reader/column_mapper.cpp index f161a4063e9ea0..7aeb9bd929eafa 100644 --- a/be/src/format/reader/column_mapper.cpp +++ b/be/src/format/reader/column_mapper.cpp @@ -718,6 +718,7 @@ Status TableColumnMapper::localize_filters(const std::vector& table file_request->conjuncts.push_back( VExprContext::create_shared(rewrite_table_expr_to_file_expr( table_filter.conjunct->root(), table_column_to_file_slot))); + table_filter.conjunct->clone_fn_contexts(file_request->conjuncts.back().get()); } } for (const auto& [table_column_id, predicates] : table_column_predicates) { diff --git a/be/src/format/reader/table_reader.cpp b/be/src/format/reader/table_reader.cpp index c05ef0ac5bedc9..2aebcada1454e1 100644 --- a/be/src/format/reader/table_reader.cpp +++ b/be/src/format/reader/table_reader.cpp @@ -52,26 +52,21 @@ void collect_table_slot_ids(const VExprSPtr& expr, std::set* slot_ids) { } } -void build_table_filters_from_conjunct(const VExprSPtr& conjunct, - std::vector* table_filters) { +Status build_table_filters_from_conjunct(const VExprContextSPtr& conjunct, RuntimeState* state, + std::vector* table_filters) { if (conjunct == nullptr) { - return; - } - if (conjunct->node_type() == TExprNodeType::COMPOUND_PRED && - conjunct->op() == TExprOpcode::COMPOUND_AND) { - for (const auto& child : conjunct->children()) { - build_table_filters_from_conjunct(child, table_filters); - } - return; + return Status::OK(); } std::set slot_ids; - collect_table_slot_ids(conjunct, &slot_ids); + collect_table_slot_ids(conjunct->root(), &slot_ids); if (!slot_ids.empty()) { TableFilter table_filter; - table_filter.conjunct = VExprContext::create_shared(conjunct); + table_filter.conjunct = nullptr; + RETURN_IF_ERROR(conjunct->clone(state, table_filter.conjunct)); table_filter.slot_ids.assign(slot_ids.begin(), slot_ids.end()); table_filters->push_back(std::move(table_filter)); } + return Status::OK(); } Status parse_deletion_vector(const char* buf, size_t buffer_size, DeleteFileDesc::Format format, @@ -169,7 +164,8 @@ Status TableReader::init(TableReadOptions&& options) { Status TableReader::_build_table_filters_from_conjuncts() { _table_filters.clear(); for (const auto& conjunct : _conjuncts) { - build_table_filters_from_conjunct(conjunct->root(), &_table_filters); + RETURN_IF_ERROR( + build_table_filters_from_conjunct(conjunct, _runtime_state, &_table_filters)); } return Status::OK(); }