cloud-fan commented on code in PR #52950:
URL: https://github.com/apache/spark/pull/52950#discussion_r2532506081
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala:
##########
@@ -895,6 +895,50 @@ class FilterPushdownSuite extends PlanTest {
comparePlans(optimized, correctAnswer)
}
+
+ test("SPARK-47031 + SPARK-13473 union - non-deterministic") {
+ val testRelation2 = LocalRelation($"d".int, $"e".int, $"f".int)
+
+ // in subq1 j is deterministic
+ val subq1 = testRelation.select(
+ Literal(1.0).as("j")
+ )
+
+ // j is non-deterministic
+ val subq2 = testRelation2.select(
+ Rand(10).as("j")
+ )
+
+ // not deterministic in first sub-query
+ val originalQuery = Union(Seq(subq2, subq1))
+ .where($"j" > 5L)
Review Comment:
In theory, `Filter(cond, Union(children))` should be the same as
`Union(children.map(Filter(cond, _)))`. Physically, the condition is still
evaluated N times where N is the number of input rows.
--
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]