alamb commented on code in PR #3380:
URL: https://github.com/apache/arrow-datafusion/pull/3380#discussion_r972104978
##########
datafusion/expr/src/expr_fn.rs:
##########
@@ -698,4 +730,56 @@ mod test {
combine_filters(&[filter1.clone(), filter2.clone(),
filter3.clone()]);
assert_eq!(result, Some(and(and(filter1, filter2), filter3)));
}
+
+ fn assert_predicates(actual: Vec<Expr>, expected: Vec<Expr>) {
+ assert_eq!(
+ actual.len(),
+ expected.len(),
+ "Predicates are not equal, found {} predicates but expected {}",
+ actual.len(),
+ expected.len()
+ );
+
+ for expr in expected.into_iter() {
+ assert!(
+ actual.contains(&expr),
+ "Predicates are not equal, predicate {:?} not found in {:?}",
+ expr,
+ actual
+ );
+ }
+ }
+
+ #[test]
+ fn test_uncombine_filter() {
+ let _schema = Schema::new(vec![
+ Field::new("a", DataType::Utf8, true),
+ Field::new("b", DataType::Utf8, true),
+ Field::new("c", DataType::Utf8, true),
+ ]);
+
+ let expr = col("a").eq(lit("s"));
+ let actual = uncombine_filter(expr);
+
+ assert_predicates(actual, vec![col("a").eq(lit("s"))]);
+ }
+
+ #[test]
+ fn test_uncombine_filter_recursively() {
+ let _schema = Schema::new(vec![
+ Field::new("a", DataType::Utf8, true),
+ Field::new("b", DataType::Utf8, true),
+ Field::new("c", DataType::Utf8, true),
+ ]);
+
+ let expr = and(col("a"), col("b"));
+ let actual = uncombine_filter(expr);
+
+ assert_predicates(actual, vec![col("a"), col("b")]);
+
+ let expr = col("a").and(col("b")).or(col("c"));
Review Comment:
Could you be a more specific @liukun4515 -- I am not sure if you are
pointing out a potential bug . This line makes the predicate `(a AND b) OR c` I
believe. What do you mean by `c or a and b`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]