alamb commented on code in PR #16762: URL: https://github.com/apache/datafusion/pull/16762#discussion_r2219635481
########## datafusion/physical-expr/src/utils/guarantee.rs: ########## @@ -824,13 +894,87 @@ mod test { ); } + #[test] + fn test_disjunction_and_conjunction_multi_column() { + // (a = "foo" AND b = 1) OR (a = "bar" AND b = 2) + test_analyze( + (col("a").eq(lit("foo")).and(col("b").eq(lit(1)))) + .or(col("a").eq(lit("bar")).and(col("b").eq(lit(2)))), + vec![in_guarantee("a", ["foo", "bar"]), in_guarantee("b", [1, 2])], + ); + // (a = "foo" AND b = 1) OR (a = "bar" AND b = 2) OR (b = 3) + test_analyze( + (col("a").eq(lit("foo")).and(col("b").eq(lit(1)))) + .or(col("a").eq(lit("bar")).and(col("b").eq(lit(2)))) + .or(col("b").eq(lit(3))), + vec![in_guarantee("b", [1, 2, 3])], + ); + // (a = "foo" AND b = 1) OR (a = "bar" AND b = 2) OR (c = 3) + test_analyze( + (col("a").eq(lit("foo")).and(col("b").eq(lit(1)))) + .or(col("a").eq(lit("bar")).and(col("b").eq(lit(2)))) + .or(col("c").eq(lit(3))), + vec![], + ); + // (a = "foo" AND b = 1) OR (a != "bar" AND b = 2) + test_analyze( + (col("a").eq(lit("foo")).and(col("b").eq(lit(1)))) + .or(col("a").not_eq(lit("bar")).and(col("b").eq(lit(2)))), + vec![in_guarantee("b", [1, 2])], + ); + // (a = "foo" AND b > 1) OR (a = "bar" AND b = 2) + test_analyze( + (col("a").eq(lit("foo")).and(col("b").gt(lit(1)))) + .or(col("a").eq(lit("bar")).and(col("b").eq(lit(2)))), + vec![in_guarantee("a", ["foo", "bar"])], + ); + // (a = "foo" AND b = 1) OR (b = 1 AND c = 2) OR (c = 3 AND a = "bar") + test_analyze( + (col("a").eq(lit("foo")).and(col("b").eq(lit(1)))) + .or(col("b").eq(lit(1)).and(col("c").eq(lit(2)))) + .or(col("c").eq(lit(3)).and(col("a").eq(lit("bar")))), + vec![], + ); + // (a = "foo" AND a = "bar") OR (a = "good" AND b = 1) + // TODO: this should be `a IN ("good") AND b IN (1)` Review Comment: No need to remove it -- I just wanted to point it out -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org