Skip to content

Commit

Permalink
update format
Browse files Browse the repository at this point in the history
  • Loading branch information
xzhseh committed Mar 13, 2024
1 parent aea6d9c commit ddd2385
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/frontend/src/optimizer/rule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/optimizer/rule/stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand All @@ -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(),
))
}
}

Expand Down Expand Up @@ -146,8 +146,20 @@ fn check_special_pattern(e1: ExprImpl, e2: ExprImpl, op: ExprType) -> Option<boo
return None;
};
match op {
ExprType::Or => 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,
}
}
Expand Down Expand Up @@ -235,4 +247,4 @@ impl ExprRewriter for StreamFilterExpressionSimplifyRewriter {
expr
}
}
}
}
7 changes: 3 additions & 4 deletions src/frontend/src/utils/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down

0 comments on commit ddd2385

Please sign in to comment.