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>
| 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 |
no test coverage detected