Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/3827#discussion_r22360456
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveTableScanSuite.scala
---
@@ -76,4 +76,19 @@ class HiveTableScanSuite extends HiveComparisonTest {
=== Array(Row(java.sql.Timestamp.valueOf("2014-12-11
00:00:00")),Row(null)))
TestHive.sql("DROP TABLE timestamp_query_null")
}
+
+ test("Spark-4963: SchemaRDD sample on mutable row return wrong result") {
+ TestHive.sql("CREATE TABLE IF NOT EXISTS src (key INT, value STRING)")
+ val location =
+ Utils.getSparkClassLoader.getResource("data/files/kv1.txt").getFile()
+ TestHive.sql(s"LOAD DATA LOCAL INPATH '$location' INTO TABLE src")
+ TestHive.sql("SELECT * FROM src WHERE key % 2 = 0")
+ .sample(withReplacement = false, fraction = 0.3)
+ .registerTempTable("sampled")
+ assert((1 to 10)
--- End diff --
Use `checkAnswer` instead here as it give better output when there is an
exception or the answer is wrong.
```scala
(1 to 10).foreach { i =>
checkAnswer(
sql("SELECT * FROM sampled WHERE key % 2 = 1"),
Seq.empty)
}
```
---
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]