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
49 changes: 7 additions & 42 deletions be/src/pipeline/exec/scan_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,32 +302,28 @@ Status ScanLocalState<Derived>::_normalize_predicate(vectorized::VExprContext* c
static constexpr auto is_leaf = [](auto&& expr) { return !expr->is_and_expr(); };
auto in_predicate_checker = [&](const vectorized::VExprSPtrs& children,
SlotDescriptor** slot_desc, ColumnValueRangeType** range) {
if (children.empty() || vectorized::VExpr::expr_without_cast(children[0])->node_type() !=
TExprNodeType::SLOT_REF) {
if (children.empty() || children[0]->node_type() != TExprNodeType::SLOT_REF) {
// not a slot ref(column)
return false;
}
std::shared_ptr<vectorized::VSlotRef> slot =
std::dynamic_pointer_cast<vectorized::VSlotRef>(
vectorized::VExpr::expr_without_cast(children[0]));
std::dynamic_pointer_cast<vectorized::VSlotRef>(children[0]);
*slot_desc =
_parent->cast<typename Derived::Parent>()._slot_id_to_slot_desc[slot->slot_id()];
return _is_predicate_acting_on_slot(slot, children[0], range);
return _is_predicate_acting_on_slot(slot, range);
};
auto eq_predicate_checker = [&](const vectorized::VExprSPtrs& children,
SlotDescriptor** slot_desc, ColumnValueRangeType** range) {
if (children.empty() || vectorized::VExpr::expr_without_cast(children[0])->node_type() !=
TExprNodeType::SLOT_REF) {
if (children.empty() || children[0]->node_type() != TExprNodeType::SLOT_REF) {
// not a slot ref(column)
return false;
}
std::shared_ptr<vectorized::VSlotRef> slot =
std::dynamic_pointer_cast<vectorized::VSlotRef>(
vectorized::VExpr::expr_without_cast(children[0]));
std::dynamic_pointer_cast<vectorized::VSlotRef>(children[0]);
CHECK(slot != nullptr);
*slot_desc =
_parent->cast<typename Derived::Parent>()._slot_id_to_slot_desc[slot->slot_id()];
return _is_predicate_acting_on_slot(slot, children[0], range);
return _is_predicate_acting_on_slot(slot, range);
};

if (expr_root != nullptr) {
Expand Down Expand Up @@ -528,39 +524,19 @@ Status ScanLocalState<Derived>::_normalize_function_filters(vectorized::VExprCon

template <typename Derived>
bool ScanLocalState<Derived>::_is_predicate_acting_on_slot(
const std::shared_ptr<vectorized::VSlotRef>& slot_ref,
const vectorized::VExprSPtr& child_contains_slot, ColumnValueRangeType** range) {
const std::shared_ptr<vectorized::VSlotRef>& slot_ref, ColumnValueRangeType** range) {
auto entry = _slot_id_to_predicates.find(slot_ref->slot_id());
if (_slot_id_to_predicates.end() == entry) {
return false;
}
if (is_complex_type(slot_ref->data_type()->get_primitive_type())) {
return false;
}
auto& p = _parent->cast<typename Derived::Parent>();
auto sid_to_range = _slot_id_to_value_range.find(slot_ref->slot_id());
if (_slot_id_to_value_range.end() == sid_to_range) {
return false;
}
*range = &(sid_to_range->second);
SlotDescriptor* src_slot_desc = p._slot_id_to_slot_desc[slot_ref->slot_id()];
DCHECK(child_contains_slot != nullptr);
if (child_contains_slot->data_type()->get_primitive_type() !=
src_slot_desc->type()->get_primitive_type() ||
child_contains_slot->data_type()->get_precision() !=
src_slot_desc->type()->get_precision() ||
child_contains_slot->data_type()->get_scale() != src_slot_desc->type()->get_scale()) {
return _ignore_cast(src_slot_desc, child_contains_slot.get());
}
if ((child_contains_slot->data_type()->get_primitive_type() == PrimitiveType::TYPE_DATETIME ||
child_contains_slot->data_type()->get_primitive_type() == PrimitiveType::TYPE_DATETIMEV2 ||
child_contains_slot->data_type()->get_primitive_type() ==
PrimitiveType::TYPE_TIMESTAMPTZ) &&
child_contains_slot->node_type() == doris::TExprNodeType::CAST_EXPR) {
// Expr `CAST(CAST(datetime_col AS DATE) AS DATETIME) = datetime_literal` should not be
// push down.
return false;
}
return true;
}

Expand All @@ -581,17 +557,6 @@ std::string ScanLocalState<Derived>::debug_string(int indentation_level) const {
return fmt::to_string(debug_string_buffer);
}

template <typename Derived>
bool ScanLocalState<Derived>::_ignore_cast(SlotDescriptor* slot, vectorized::VExpr* expr) {
// only one level cast expr could push down for variant type
// check if expr is cast and it's children is slot
if (slot->type()->get_primitive_type() == PrimitiveType::TYPE_VARIANT) {
return expr->node_type() == TExprNodeType::CAST_EXPR &&
expr->children().at(0)->is_slot_ref();
}
return false;
}

template <typename Derived>
Status ScanLocalState<Derived>::_eval_const_conjuncts(vectorized::VExprContext* expr_ctx,
PushDownType* pdt) {
Expand Down
3 changes: 0 additions & 3 deletions be/src/pipeline/exec/scan_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ class ScanLocalState : public ScanLocalStateBase {
PushDownType* pdt);

bool _is_predicate_acting_on_slot(const std::shared_ptr<vectorized::VSlotRef>& slot_ref,
const vectorized::VExprSPtr& child_contains_slot,
ColumnValueRangeType** range);

template <PrimitiveType T>
Expand All @@ -286,8 +285,6 @@ class ScanLocalState : public ScanLocalStateBase {
std::vector<std::shared_ptr<ColumnPredicate>>& predicates,
ColumnValueRange<T>& range, PushDownType* pdt);

bool _ignore_cast(SlotDescriptor* slot, vectorized::VExpr* expr);

template <bool IsFixed, PrimitiveType PrimitiveType, typename ChangeFixedValueRangeFunc>
Status _change_value_range(ColumnValueRange<PrimitiveType>& range, const void* value,
const ChangeFixedValueRangeFunc& func, const std::string& fn_name,
Expand Down
Loading