[][src]Module transform::fusion::filter

Fuses multiple Filter operators into one; deduplicates predicates.

use expr::{RelationExpr, ScalarExpr};
use repr::{ColumnType, Datum, RelationType, ScalarType};

use transform::fusion::filter::Filter;

let input = RelationExpr::constant(vec![], RelationType::new(vec![
    ScalarType::Bool.nullable(false),
]));

let predicate0 = ScalarExpr::Column(0);
let predicate1 = ScalarExpr::Column(0);
let predicate2 = ScalarExpr::Column(0);

let mut expr =
input
    .clone()
    .filter(vec![predicate0.clone()])
    .filter(vec![predicate1.clone()])
    .filter(vec![predicate2.clone()]);

// .transform() will deduplicate any predicates
use transform::{Transform, TransformArgs};
Filter.transform(&mut expr, TransformArgs {
  id_gen: &mut Default::default(),
  indexes: &std::collections::HashMap::new(),
});

let correct = input.filter(vec![predicate0]);

assert_eq!(expr, correct);

Structs

Filter

Fuses multiple Filter operators into one and deduplicates predicates.