wangyum commented on code in PR #36921:
URL: https://github.com/apache/spark/pull/36921#discussion_r906056598


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/InferFiltersFromConstraintsSuite.scala:
##########
@@ -151,9 +151,9 @@ class InferFiltersFromConstraintsSuite extends PlanTest {
       .join(t2, Inner, Some("t.a".attr === "t2.a".attr && "t.int_col".attr === 
"t2.a".attr))
       .analyze
     val correctAnswer = t1
-      .where(IsNotNull($"a") && IsNotNull(Coalesce(Seq($"a", $"b"))) &&
-        $"a" === Coalesce(Seq($"a", $"b")))
-      .select($"a", Coalesce(Seq($"a", $"b")).as("int_col")).as("t")
+      .where(IsNotNull($"a"))
+      .select($"a", Coalesce(Seq($"a", $"b")).as("int_col"))
+      .where('int_col.isNotNull && 'int_col === 'a).as("t")

Review Comment:
   Before this PR:
   ```
   == Optimized Logical Plan ==
   Project [key#2L, value#3L]
   +- Join Inner, (key#2L = id#6L)
      :- Project [(id#0L % 10) AS key#2L, id#0L AS value#3L]
      :  +- Filter ((id#0L > scalar-subquery#8 []) AND isnotnull((id#0L % 10)))
      :     :  +- Aggregate [max(id#11L) AS max(id)#10L]
      :     :     +- Range (0, 10, step=1, splits=Some(2))
      :     +- Range (0, 100, step=1, splits=Some(2))
      +- Range (0, 10, step=1, splits=Some(2))
   ```
   
   After this PR:
   ```
   == Optimized Logical Plan ==
   Project [key#2L, value#3L]
   +- Join Inner, (key#2L = id#6L)
      :- Filter isnotnull(key#2L)
      :  +- Project [(id#0L % 10) AS key#2L, id#0L AS value#3L]
      :     +- Filter (id#0L > scalar-subquery#8 [])
      :        :  +- Aggregate [max(id#11L) AS max(id)#10L]
      :        :     +- Range (0, 10, step=1, splits=Some(2))
      :        +- Range (0, 100, step=1, splits=Some(2))
      +- Range (0, 10, step=1, splits=Some(2))
   ```



-- 
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]

Reply via email to