MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / plan

Function plan

src/transform/src/join_implementation.rs:593–668  ·  view source on GitHub ↗

Creates a delta query plan, and any predicates that need to be lifted. It also returns the number of new arrangements necessary for this plan. The method returns `Err` if any errors occur during planning.

(
        join: &MirRelationExpr,
        input_mapper: &JoinInputMapper,
        available: &[Vec<Vec<MirScalarExpr>>],
        unique_keys: &[Vec<Vec<usize>>],
        cardinalities: &[Option<usize>

Source from the content-addressed store, hash-verified

591 ///
592 /// The method returns `Err` if any errors occur during planning.
593 pub fn plan(
594 join: &MirRelationExpr,
595 input_mapper: &JoinInputMapper,
596 available: &[Vec<Vec<MirScalarExpr>>],
597 unique_keys: &[Vec<Vec<usize>>],
598 cardinalities: &[Option<usize>],
599 filters: &[FilterCharacteristics],
600 optimizer_features: &OptimizerFeatures,
601 ) -> Result<(MirRelationExpr, usize), TransformError> {
602 let mut new_join = join.clone();
603
604 if let MirRelationExpr::Join {
605 inputs,
606 equivalences,
607 implementation,
608 } = &mut new_join
609 {
610 // Determine a viable order for each relation, or return `Err` if none found.
611 let orders = super::optimize_orders(
612 equivalences,
613 available,
614 unique_keys,
615 cardinalities,
616 filters,
617 input_mapper,
618 optimizer_features.enable_join_prioritize_arranged,
619 )?;
620
621 // Count new arrangements.
622 let new_arrangements: usize = orders
623 .iter()
624 .flat_map(|o| {
625 o.iter().skip(1).filter_map(|(c, key, input)| {
626 if c.arranged() {
627 None
628 } else {
629 Some((input, key))
630 }
631 })
632 })
633 .collect::<BTreeSet<_>>()
634 .len();
635
636 // Convert the order information into specific (input, key, characteristics) information.
637 let mut orders = orders
638 .into_iter()
639 .map(|o| {
640 o.into_iter()
641 .skip(1)
642 .map(|(c, key, r)| (r, key, Some(c)))
643 .collect::<Vec<_>>()
644 })
645 .collect::<Vec<_>>();
646
647 // Implement arrangements in each of the inputs.
648 let (lifted_mfp, lifted_projections) =
649 super::implement_arrangements(inputs, available, orders.iter().flatten());
650

Callers 1

actionMethod · 0.70

Calls 15

optimize_ordersFunction · 0.85
implement_arrangementsFunction · 0.85
permute_orderFunction · 0.85
install_lifted_mfpFunction · 0.85
arrangedMethod · 0.80
filtersMethod · 0.80
minMethod · 0.80
unwrapMethod · 0.80
saturating_subMethod · 0.80
cloneMethod · 0.45
lenMethod · 0.45
flat_mapMethod · 0.45

Tested by

no test coverage detected