diff --git a/src/frontend/src/optimizer/rule/mod.rs b/src/frontend/src/optimizer/rule/mod.rs index 187c86759e274..7b899a1fab435 100644 --- a/src/frontend/src/optimizer/rule/mod.rs +++ b/src/frontend/src/optimizer/rule/mod.rs @@ -92,8 +92,8 @@ pub use stream::bushy_tree_join_ordering_rule::*; pub use stream::filter_with_now_to_join_rule::*; pub use stream::split_now_and_rule::*; pub use stream::split_now_or_rule::*; -pub use stream::stream_project_merge_rule::*; pub use stream::stream_filter_expression_simplify_rule::*; +pub use stream::stream_project_merge_rule::*; mod trivial_project_to_values_rule; pub use trivial_project_to_values_rule::*; mod union_input_values_merge_rule; diff --git a/src/frontend/src/optimizer/rule/stream/mod.rs b/src/frontend/src/optimizer/rule/stream/mod.rs index 07933c3177bf7..de40660145dbc 100644 --- a/src/frontend/src/optimizer/rule/stream/mod.rs +++ b/src/frontend/src/optimizer/rule/stream/mod.rs @@ -16,5 +16,5 @@ pub(crate) mod bushy_tree_join_ordering_rule; pub(crate) mod filter_with_now_to_join_rule; pub(crate) mod split_now_and_rule; pub(crate) mod split_now_or_rule; +pub(crate) mod stream_filter_expression_simplify_rule; pub(crate) mod stream_project_merge_rule; -pub(crate) mod stream_filter_expression_simplify_rule; \ No newline at end of file diff --git a/src/frontend/src/optimizer/rule/stream/stream_filter_expression_simplify_rule.rs b/src/frontend/src/optimizer/rule/stream/stream_filter_expression_simplify_rule.rs index 7bfc7bdc60bb3..0cbc8cf6c5ef4 100644 --- a/src/frontend/src/optimizer/rule/stream/stream_filter_expression_simplify_rule.rs +++ b/src/frontend/src/optimizer/rule/stream/stream_filter_expression_simplify_rule.rs @@ -16,13 +16,10 @@ use fixedbitset::FixedBitSet; use risingwave_common::types::ScalarImpl; use risingwave_connector::source::DataType; -use crate::expr::{ - Expr, ExprImpl, ExprRewriter, FunctionCall, -}; -use crate::expr::ExprType; +use crate::expr::{Expr, ExprImpl, ExprRewriter, ExprType, FunctionCall}; use crate::optimizer::plan_expr_visitor::strong::Strong; use crate::optimizer::plan_node::{ExprRewritable, LogicalFilter, LogicalShare, PlanTreeNodeUnary}; -use crate::optimizer::rule::{Rule, BoxedRule}; +use crate::optimizer::rule::{BoxedRule, Rule}; use crate::optimizer::PlanRef; pub struct StreamFilterExpressionSimplifyRule {} @@ -39,7 +36,10 @@ impl Rule for StreamFilterExpressionSimplifyRule { let share: &LogicalShare = logical_share_plan.as_logical_share()?; let input = share.input().rewrite_exprs(&mut rewriter); share.replace_input(input); - Some(LogicalFilter::create(share.clone().into(), filter.predicate().clone())) + Some(LogicalFilter::create( + share.clone().into(), + filter.predicate().clone(), + )) } } @@ -146,8 +146,20 @@ fn check_special_pattern(e1: ExprImpl, e2: ExprImpl, op: ExprType) -> Option if scalar == ScalarImpl::Bool(true) { Some(true) } else { None } - ExprType::And => if scalar == ScalarImpl::Bool(false) { Some(false) } else { None } + ExprType::Or => { + if scalar == ScalarImpl::Bool(true) { + Some(true) + } else { + None + } + } + ExprType::And => { + if scalar == ScalarImpl::Bool(false) { + Some(false) + } else { + None + } + } _ => None, } } @@ -235,4 +247,4 @@ impl ExprRewriter for StreamFilterExpressionSimplifyRewriter { expr } } -} \ No newline at end of file +} diff --git a/src/frontend/src/utils/condition.rs b/src/frontend/src/utils/condition.rs index 6e8952be36b75..b1db9d7846c49 100644 --- a/src/frontend/src/utils/condition.rs +++ b/src/frontend/src/utils/condition.rs @@ -26,10 +26,9 @@ use risingwave_common::util::scan_range::{is_full_range, ScanRange}; use crate::error::Result; use crate::expr::{ - collect_input_refs, factorization_expr, fold_boolean_constant, push_down_not, - to_conjunctions, try_get_bool_constant, ExprDisplay, - ExprImpl, ExprMutator, ExprRewriter, ExprType, ExprVisitor, FunctionCall, InequalityInputPair, - InputRef, + collect_input_refs, factorization_expr, fold_boolean_constant, push_down_not, to_conjunctions, + try_get_bool_constant, ExprDisplay, ExprImpl, ExprMutator, ExprRewriter, ExprType, ExprVisitor, + FunctionCall, InequalityInputPair, InputRef, }; use crate::utils::condition::cast_compare::{ResultForCmp, ResultForEq};