Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
nameexhaustion committed Nov 27, 2023
1 parent 327f4fd commit c53acca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ impl<'a> PredicatePushDown<'a> {
let input = inputs[inputs.len() - 1];
let input_schema = lp_arena.get(input).schema(lp_arena);

let (pushdown_eligibility, alias_rename_map) =
let (eligibility, alias_rename_map) =
pushdown_eligibility(input_schema.as_ref(), &exprs, &acc_predicates, expr_arena)?;

let local_predicates = match pushdown_eligibility {
PushdownEligibility::FullPushdown => vec![],
PushdownEligibility::PartialPushdown(allowed) => {
let local_predicates = match eligibility {
PushdownEligibility::Full => vec![],
PushdownEligibility::Partial(allowed) => {
let mut out = Vec::<Node>::with_capacity(allowed.len());
for key in allowed {
out.push(acc_predicates.remove(&key).unwrap());
Expand Down Expand Up @@ -255,8 +255,8 @@ impl<'a> PredicatePushDown<'a> {
// contexts. Note boundary projections are handled elsewhere.

let local_predicates = match pushdown_eligibility(lp.schema(lp_arena).as_ref(), &vec![], &acc_predicates, expr_arena)?.0 {
PushdownEligibility::FullPushdown => vec![],
PushdownEligibility::PartialPushdown(allowed) => {
PushdownEligibility::Full => vec![],
PushdownEligibility::Partial(allowed) => {
let mut out = Vec::<Node>::with_capacity(allowed.len());
for key in allowed {
out.push(acc_predicates.remove(&key).unwrap());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,12 @@ fn get_maybe_aliased_projection_to_input_name_map(
}

pub enum PushdownEligibility {
FullPushdown,
PartialPushdown(Vec<Arc<str>>),
Full,
Partial(Vec<Arc<str>>),
NoPushdown,
}

#[allow(clippy::type_complexity)]
pub fn pushdown_eligibility(
input_schema: &Schema,
projection_nodes: &Vec<Node>,
Expand Down Expand Up @@ -408,7 +409,7 @@ pub fn pushdown_eligibility(
debug_assert!(!common_window_inputs.is_empty() || !has_window);

if !has_window && projection_nodes.is_empty() {
return Ok((PushdownEligibility::FullPushdown, alias_to_col_map));
return Ok((PushdownEligibility::Full, alias_to_col_map));
}

// Note: has_window is constant.
Expand All @@ -422,7 +423,7 @@ pub fn pushdown_eligibility(

let allowed_predicates = acc_predicates
.iter()
.filter_map(|(&ref key, &node)| {
.filter_map(|(key, &node)| {
debug_assert!(ae_nodes_stack.is_empty());

ae_nodes_stack.push(node);
Expand Down Expand Up @@ -456,11 +457,9 @@ pub fn pushdown_eligibility(

match allowed_predicates.len() {
0 => Ok((PushdownEligibility::NoPushdown, alias_to_col_map)),
len if len == acc_predicates.len() => {
Ok((PushdownEligibility::FullPushdown, alias_to_col_map))
},
len if len == acc_predicates.len() => Ok((PushdownEligibility::Full, alias_to_col_map)),
_ => Ok((
PushdownEligibility::PartialPushdown(allowed_predicates),
PushdownEligibility::Partial(allowed_predicates),
alias_to_col_map,
)),
}
Expand Down

0 comments on commit c53acca

Please sign in to comment.