Skip to content

Commit

Permalink
Support =, <, <=, >, >=, !=, is distinct from, `is not …
Browse files Browse the repository at this point in the history
…distinct from` for `BooleanArray` (#1163)

* Support `=`, `<`, `<=`, `>`, `>=`, `!=`, `is distinct from`, `is not distinct from` for `BooleanArray`

* Update datafusion/src/physical_plan/expressions/binary.rs

Co-authored-by: rdettai <[email protected]>

* Apply suggestions from code review

Co-authored-by: Jiayu Liu <[email protected]>

Co-authored-by: rdettai <[email protected]>
Co-authored-by: Jiayu Liu <[email protected]>
  • Loading branch information
3 people authored Nov 20, 2021
1 parent a6980a0 commit 00850a4
Show file tree
Hide file tree
Showing 5 changed files with 592 additions and 25 deletions.
24 changes: 6 additions & 18 deletions datafusion/src/physical_optimizer/pruning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1374,36 +1374,24 @@ mod tests {

#[test]
fn prune_bool_column_eq_true() {
let (schema, statistics, _, _) = bool_setup();
let (schema, statistics, expected_true, _) = bool_setup();

// b1 = true
let expr = col("b1").eq(lit(true));
let p = PruningPredicate::try_new(&expr, schema).unwrap();
let result = p.prune(&statistics).unwrap_err();
assert!(
result.to_string().contains(
"Data type Boolean not supported for scalar operation 'lt_eq' on dyn array"
),
"{}",
result
)
let result = p.prune(&statistics).unwrap();
assert_eq!(result, expected_true);
}

#[test]
fn prune_bool_not_column_eq_true() {
let (schema, statistics, _, _) = bool_setup();
let (schema, statistics, _, expected_false) = bool_setup();

// !b1 = true
let expr = col("b1").not().eq(lit(true));
let p = PruningPredicate::try_new(&expr, schema).unwrap();
let result = p.prune(&statistics).unwrap_err();
assert!(
result.to_string().contains(
"Data type Boolean not supported for scalar operation 'lt_eq' on dyn array"
),
"{}",
result
)
let result = p.prune(&statistics).unwrap();
assert_eq!(result, expected_false);
}

/// Creates setup for int32 chunk pruning
Expand Down
Loading

0 comments on commit 00850a4

Please sign in to comment.