Function mz_expr::canonicalize::canonicalize_equivalence_classes

source ยท
pub fn canonicalize_equivalence_classes(
    equivalences: &mut Vec<Vec<MirScalarExpr>>,
)
Expand description

Canonicalize only the equivalence classes of a join.

This function:

  • ensures the same expression appears in only one equivalence class.
  • ensures the equivalence classes are sorted and dedupped.
use mz_expr::MirScalarExpr;
use mz_expr::canonicalize::canonicalize_equivalence_classes;

let mut equivalences = vec![
    vec![MirScalarExpr::Column(1), MirScalarExpr::Column(4)],
    vec![MirScalarExpr::Column(3), MirScalarExpr::Column(5)],
    vec![MirScalarExpr::Column(0), MirScalarExpr::Column(3)],
    vec![MirScalarExpr::Column(2), MirScalarExpr::Column(2)],
];
let expected = vec![
    vec![MirScalarExpr::Column(0),
        MirScalarExpr::Column(3),
        MirScalarExpr::Column(5)],
    vec![MirScalarExpr::Column(1), MirScalarExpr::Column(4)],
];
canonicalize_equivalence_classes(&mut equivalences);
assert_eq!(expected, equivalences)