Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/6570#discussion_r31492468
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala ---
@@ -453,6 +454,44 @@ class ColumnExpressionSuite extends QueryTest {
assert(row.getDouble(1) <= 1.0)
assert(row.getDouble(1) >= 0.0)
}
+
+ def checkNumProjects(df: DataFrame, expectedNumProjects: Int): Unit = {
+ val projects = df.queryExecution.executedPlan.collect {
+ case project: Project => project
+ }
+ assert(projects.size === expectedNumProjects)
+ }
+
+ // We first create a plan with two Projects.
+ // Project [rand + 1 AS rand1, rand - 1 AS rand2]
+ // Project [key, Rand 5 AS rand]
+ // LogicalRDD [key, value]
+ // Because Rand function is not deterministic, the column rand is not
deterministic.
+ // So, in the optimizer, we will not collapse Project [rand + 1 AS
rand1, rand - 1 AS rand2]
+ // and Project [key, Rand 5 AS rand]. The final plan still has two
Projects.
+ val dfWithTwoProjects =
+ testData
+ .select('key, rand(5L).as("rand"))
--- End diff --
let's make the base
(rand(5L) + 1)
to make sure we can catch nested nondeterministic things.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]