◆ CaseSimplificationRule()
319768
319769 auto op = make_uniq<CaseExpressionMatcher>();
319770 root = std::move(op);
319771}
ExpressionRewriter & rewriter
The expression rewriter this rule belongs to.
Definition duckdb.cpp:69564
unique_ptr< ExpressionMatcher > root
The expression matcher of the rule.
Definition duckdb.cpp:69566
◆ Apply()
Implements duckdb::Rule.
319774 {
319775 auto &
root = bindings[0].get().Cast<BoundCaseExpression>();
319776 for (
idx_t i = 0; i <
root.case_checks.size(); i++) {
319777 auto &case_check =
root.case_checks[i];
319778 if (case_check.when_expr->IsFoldable()) {
319779
319780
319782
319783
319784 auto condition = constant_value.DefaultCastAs(LogicalType::BOOLEAN);
319785 if (condition.IsNull() || !BooleanValue::Get(condition)) {
319786
319787 root.case_checks.erase_at(i);
319788 i--;
319789 } else {
319790
319791
319792 root.else_expr = std::move(case_check.then_expr);
319793
319794 root.case_checks.erase(
root.case_checks.begin() + NumericCast<int64_t>(i),
root.case_checks.end());
319795 break;
319796 }
319797 }
319798 }
319799 if (
root.case_checks.empty()) {
319800
319801 return std::move(
root.else_expr);
319802 }
319803 return nullptr;
319804}
static DUCKDB_API Value EvaluateScalar(ClientContext &context, const Expression &expr, bool allow_unfoldable=false)
Evaluate a scalar expression and fold it into a single value.
Definition duckdb.cpp:149993
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
The documentation for this class was generated from the following file: