Skip to content

Commit 34340ee

Browse files
committed
address comments.
1 parent 8773c03 commit 34340ee

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

sql/hive/src/test/scala/org/apache/spark/sql/hive/InsertIntoHiveTableSuite.scala

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -167,25 +167,26 @@ class InsertIntoHiveTableSuite extends QueryTest with TestHiveSingleton with Bef
167167
}
168168

169169
test("Delete the temporary staging directory and files after each insert") {
170-
withTable("tab") {
171-
val tmpDir = Utils.createTempDir()
172-
sql(
173-
s"""
174-
|CREATE TABLE tab(c1 string)
175-
|location '${tmpDir.toURI.toString}'
176-
""".stripMargin)
177-
178-
(1 to 3).map { i =>
179-
sql(s"INSERT OVERWRITE TABLE tab SELECT '$i'")
180-
}
181-
def listFiles(path: File): List[String] = {
182-
val dir = path.listFiles()
183-
val folders = dir.filter(_.isDirectory).toList
184-
val filePaths = dir.map(_.getName).toList
185-
filePaths ::: folders.flatMap(listFiles)
170+
withTempDir { tmpDir =>
171+
withTable("tab") {
172+
sql(
173+
s"""
174+
|CREATE TABLE tab(c1 string)
175+
|location '${tmpDir.toURI.toString}'
176+
""".stripMargin)
177+
178+
(1 to 3).map { i =>
179+
sql(s"INSERT OVERWRITE TABLE tab SELECT '$i'")
180+
}
181+
def listFiles(path: File): List[String] = {
182+
val dir = path.listFiles()
183+
val folders = dir.filter(_.isDirectory).toList
184+
val filePaths = dir.map(_.getName).toList
185+
filePaths ::: folders.flatMap(listFiles)
186+
}
187+
val expectedFiles = ".part-00000.crc" :: "part-00000" :: Nil
188+
assert(listFiles(tmpDir).sortBy(_.toString) == expectedFiles)
186189
}
187-
val expectedFiles = ".part-00000.crc" :: "part-00000" :: Nil
188-
assert(listFiles(tmpDir).sortBy(_.toString) == expectedFiles)
189190
}
190191
}
191192

0 commit comments

Comments
 (0)