Github user harsha2010 commented on a diff in the pull request:
https://github.com/apache/spark/pull/5714#discussion_r29155350
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
---
@@ -71,6 +71,26 @@ class SQLQuerySuite extends QueryTest with
BeforeAndAfterAll {
)
}
+ test("SPARK-7158 collect and take return different results") {
+ import java.util.UUID
+ import org.apache.spark.sql.types._
+ val rdd = sparkContext.parallelize(List(1,2,3), 2)
+ val schema = StructType(List(StructField("index",IntegerType,true)))
+ val df = createDataFrame(rdd.map(p => Row(p)), schema)
+ def id:() => String = () => {UUID.randomUUID().toString()}
+ def square:Int => Int = (x: Int) => {x * x}
+ //expect the ID to have materialized at this point
+ val dfWithId = df.withColumn("id",callUDF(id, StringType)).cache()
+ val d1 = dfWithId.collect()
+
+ // ID should not be changed, as we will take the data from the cache
directly
--- End diff --
this test could be simpler... no need for the additional dfWithIdAndSquare
column or the square function...
if we were not reading from cache, two consecutive invocations of
dfWithId.collect will yield different IDs.
Makes the test simpler.
---
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]