File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed
core/src/main/scala/org/apache/spark/sql/execution/command
hive/src/test/scala/org/apache/spark/sql/hive/execution Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -252,7 +252,7 @@ case class LoadDataCommand(
252252 val fileSystem = FileSystems .getDefault
253253 val pathPattern = fileSystem.getPath(filePath)
254254 val dir = pathPattern.getParent.toString
255- val filePattern = pathPattern.getName(pathPattern.getNameCount - 1 ) .toString
255+ val filePattern = pathPattern.getFileName .toString
256256 if (dir.contains(" *" )) {
257257 throw new AnalysisException (
258258 s " LOAD DATA input path allows only filename wildcard: $path" )
Original file line number Diff line number Diff line change 1818package org .apache .spark .sql .hive .execution
1919
2020import java .io .{File , PrintWriter }
21+ import java .nio .charset .StandardCharsets
2122import java .sql .{Date , Timestamp }
2223
2324import scala .sys .process .{Process , ProcessLogger }
2425import scala .util .Try
2526
27+ import com .google .common .io .Files
2628import org .apache .hadoop .fs .Path
2729
2830import org .apache .spark .sql ._
@@ -1890,14 +1892,10 @@ class SQLQuerySuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
18901892 test(" SPARK-17796 Support wildcard character in filename for LOAD DATA LOCAL INPATH" ) {
18911893 withTempDir { dir =>
18921894 for (i <- 1 to 3 ) {
1893- val writer = new PrintWriter (new File (s " $dir/part-r-0000 $i" ))
1894- writer.write(s " $i" )
1895- writer.close()
1895+ Files .write(s " $i" , new File (s " $dir/part-r-0000 $i" ), StandardCharsets .UTF_8 )
18961896 }
18971897 for (i <- 5 to 7 ) {
1898- val writer = new PrintWriter (new File (s " $dir/part-s-0000 $i" ))
1899- writer.write(s " $i" )
1900- writer.close()
1898+ Files .write(s " $i" , new File (s " $dir/part-s-0000 $i" ), StandardCharsets .UTF_8 )
19011899 }
19021900
19031901 withTable(" load_t" ) {
You can’t perform that action at this time.
0 commit comments