Github user viirya commented on a diff in the pull request: https://github.com/apache/spark/pull/14327#discussion_r72002405 --- Diff: sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala --- @@ -422,6 +422,32 @@ class DatasetSuite extends QueryTest with SharedSQLContext { 3, 17, 27, 58, 62) } + test("SPARK-16686: Dataset.sample with seed results shouldn't depend on downstream usage") { + val udfOne = spark.udf.register("udfOne", (n: Int) => { + require(n != 1, "udfOne shouldn't see swid=1!") + 1 + }) + + val d = Seq( + (0, "string0"), + (1, "string1"), + (2, "string2"), + (3, "string3"), + (4, "string4"), + (5, "string5"), + (6, "string6"), + (7, "string7"), + (8, "string8"), + (9, "string9") + ) + val df = spark.createDataFrame(d).toDF("swid", "stringData") + val sampleDF = df.sample(false, 0.7, 50) + // After sampling, sampleDF doesn't contain swid=1. + assert(!sampleDF.select("swid").collect.contains(1)) + // udfOne should not encounter swid=1. + sampleDF.select(udfOne($"swid")).collect --- End diff -- `Sample` will filter out the returned value of `swid=1`. So I simply call `collect` to verify if the exception will be thrown or not.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org