[][src]Module transform::predicate_pushdown

Pushes predicates down through other operators.

This action generally improves the quality of the query, in that selective per-record filters reduce the volume of data before they arrive at more expensive operators.

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

use transform::predicate_pushdown::PredicatePushdown;

let input1 = RelationExpr::constant(vec![], RelationType::new(vec![
    ScalarType::Bool.nullable(false),
]));
let input2 = RelationExpr::constant(vec![], RelationType::new(vec![
    ScalarType::Bool.nullable(false),
]));
let input3 = RelationExpr::constant(vec![], RelationType::new(vec![
    ScalarType::Bool.nullable(false),
]));
let join = RelationExpr::join(
    vec![input1.clone(), input2.clone(), input3.clone()],
    vec![vec![(0, 0), (2, 0)].into_iter().collect()],
);

let predicate0 = ScalarExpr::column(0);
let predicate1 = ScalarExpr::column(1);
let predicate01 = ScalarExpr::column(0).call_binary(ScalarExpr::column(2), BinaryFunc::AddInt64);
let predicate012 = ScalarExpr::literal_ok(Datum::False, ScalarType::Bool.nullable(false));

let mut expr = join.filter(
   vec![
       predicate0.clone(),
       predicate1.clone(),
       predicate01.clone(),
       predicate012.clone(),
   ]);

use transform::{Transform, TransformArgs};
PredicatePushdown.transform(&mut expr, TransformArgs {
  id_gen: &mut Default::default(),
  indexes: &std::collections::HashMap::new(),
});

Structs

PredicatePushdown

Pushes predicates down through other operators.