File tree Expand file tree Collapse file tree 1 file changed +19
-18
lines changed
sql/hive/src/test/scala/org/apache/spark/sql/hive Expand file tree Collapse file tree 1 file changed +19
-18
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments