Perform filter pushdown.
318112 {
318113 for (
idx_t child_idx = 0; child_idx < op->children.size(); child_idx++) {
318114 op->children[child_idx] =
Rewrite(std::move(op->children[child_idx]));
318115 }
318116
318117 if (op->type != LogicalOperatorType::LOGICAL_FILTER) {
318118 return op;
318119 }
318120
318121 auto new_filter = make_uniq<LogicalFilter>();
318122
318123 for (auto &expr : op->expressions) {
318124 if (expr->GetExpressionType() == ExpressionType::BOUND_FUNCTION) {
318125 auto &func = expr->Cast<BoundFunctionExpression>();
318126 if (func.function.name != "regexp_full_match" || func.children.size() != 2) {
318127 continue;
318128 }
318129 auto &info = func.bind_info->Cast<RegexpMatchesBindData>();
318130 if (!info.range_success) {
318131 continue;
318132 }
318133 auto filter_left = make_uniq<BoundComparisonExpression>(
318134 ExpressionType::COMPARE_GREATERTHANOREQUALTO, func.children[0]->Copy(),
318135 make_uniq<BoundConstantExpression>(Value::BLOB_RAW(info.range_min)));
318136 auto filter_right = make_uniq<BoundComparisonExpression>(
318137 ExpressionType::COMPARE_LESSTHANOREQUALTO, func.children[0]->Copy(),
318138 make_uniq<BoundConstantExpression>(Value::BLOB_RAW(info.range_max)));
318139 auto filter_expr = make_uniq<BoundConjunctionExpression>(ExpressionType::CONJUNCTION_AND,
318140 std::move(filter_left), std::move(filter_right));
318141
318142 new_filter->expressions.push_back(std::move(filter_expr));
318143 }
318144 }
318145
318146 if (!new_filter->expressions.empty()) {
318147 new_filter->children = std::move(op->children);
318148 op->children.clear();
318149 op->children.push_back(std::move(new_filter));
318150 }
318151
318152 return op;
318153}
unique_ptr< LogicalOperator > Rewrite(unique_ptr< LogicalOperator > op)
Perform filter pushdown.
Definition duckdb.cpp:318112
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237