Skip to content
Snippets Groups Projects
Commit 8a4f228d authored by Kazuaki Ishizaki's avatar Kazuaki Ishizaki Committed by gatorsmile
Browse files

[SPARK-21946][TEST] fix flaky test: "alter table: rename cached table" in InMemoryCatalogedDDLSuite

## What changes were proposed in this pull request?

This PR fixes flaky test `InMemoryCatalogedDDLSuite "alter table: rename cached table"`.
Since this test validates distributed DataFrame, the result should be checked by using `checkAnswer`. The original version used `df.collect().Seq` method that does not guaranty an order of each element of the result.

## How was this patch tested?

Use existing test case

Author: Kazuaki Ishizaki <ishizaki@jp.ibm.com>

Closes #19159 from kiszk/SPARK-21946.
parent 0dfc1ec5
No related branches found
No related tags found
No related merge requests found
......@@ -783,7 +783,7 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
val df = (1 to 2).map { i => (i, i.toString) }.toDF("age", "name")
df.write.insertInto("students")
spark.catalog.cacheTable("students")
assume(spark.table("students").collect().toSeq == df.collect().toSeq, "bad test: wrong data")
checkAnswer(spark.table("students"), df)
assume(spark.catalog.isCached("students"), "bad test: table was not cached in the first place")
sql("ALTER TABLE students RENAME TO teachers")
sql("CREATE TABLE students (age INT, name STRING) USING parquet")
......@@ -792,7 +792,7 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
assert(!spark.catalog.isCached("students"))
assert(spark.catalog.isCached("teachers"))
assert(spark.table("students").collect().isEmpty)
assert(spark.table("teachers").collect().toSeq == df.collect().toSeq)
checkAnswer(spark.table("teachers"), df)
}
test("rename temporary table - destination table with database name") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment