kosiew commented on code in PR #27192:
URL: https://github.com/apache/datafusion/pull/27192#discussion_r4739016218
##########
datafusion/substrait/tests/cases/roundtrip_logical_plan.rs:
##########
@@ -1298,6 +1298,39 @@ async fn roundtrip_left_join() -> Result<()> {
roundtrip("SELECT data.a FROM data LEFT JOIN data2 ON data.a =
data2.a").await
}
+#[tokio::test]
+async fn roundtrip_left_join_with_same_side_equality() -> Result<()> {
+ let ctx = SessionContext::new();
+ let sql = "SELECT l.a, l.b, r.a AS ra \
+ FROM (VALUES (1, 1), (2, 3), (3, 3)) l(a, b) \
+ LEFT JOIN (VALUES (1), (2), (3)) r(a) \
+ ON r.a = l.a AND l.a = l.b \
+ ORDER BY l.a";
+
+ let plans = [
+ ctx.sql(sql).await?.into_unoptimized_plan(),
+ ctx.sql(sql).await?.into_optimized_plan()?,
+ ];
+ for plan in plans {
Review Comment:
Nit: use `DataFusionError::context` to distinguish optimized and unoptimized
plans when round-trip or collection errors occur.
##########
datafusion/substrait/src/logical_plan/consumer/rel/join_rel.rs:
##########
@@ -245,11 +286,29 @@ mod tests {
None,
)
.eq(col("b"));
-
- let (keys, _, filter) =
- split_eq_and_noneq_join_predicate_with_nulls_equality(expr);
+ let (keys, _, filter) = split(expr);
assert!(keys.is_empty());
assert_eq!(filter.unwrap().to_string(), "Utf8(\"x\") = b");
}
+
+ #[test]
+ fn split_same_side_indistinct_comparison_to_filter() {
Review Comment:
Could we add coverage for `a = a_l AND a IS NOT DISTINCT FROM b`, asserting
that the first comparison remains a filter, the second becomes the only join
key, and the mode is `NullEqualsNull`?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]