[SPARK-24176][SQL] LOAD DATA can't identify wildcard in the hdfs file path #21285
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
When the wildcard characters (like "?") were in the LOAD DATA command's path name, the Path related API (hadoop and URI) couldn't parse it correctly. For example:
val srcPath = new Path(hdfsUri)
in thetables.scala
, returned wrong result for the following cases:hdfsUri
=file: /user/testdemo1/user1/t??eddata60.txt
,srcPath
=file:/user/testdemo1/user1/t
hdfsUri
=file:/user/testdemo1/user1/?eddata60.txt'
,srcPath
=file:/user/testdemo1/user1/
(the same problem exists at
val uriPath = uri.getPath()
)The LOAD DATA LOCAL works because the local case called a utility
Utils.resolveURI
to replaced the "?" to "%3F", then the PATH API will not truncate the file name.This fix uses
Utils.resolveURI
method for both local and non-local cases.I did similar test on hive, it seems the hive has the same behavior.
hive> load data inpath 'hdfs:/tmp/?evin.txt' into table foo1; FAILED: SemanticException Line 1:17 Invalid path ''hdfs:/tmp/?evin.txt'': No files matching path hdfs://stcindia-node-6.fyre.ibm.com:8020/tmp/%3Fevin.txt hive> load data inpath 'hdfs:/tmp/k?evin.txt' into table foo1; FAILED: SemanticException Line 1:17 Invalid path ''hdfs:/tmp/k?evin.txt'': No files matching path hdfs://stcindia-node-6.fyre.ibm.com:8020/tmp/k%3Fevin.txt hive>
How was this patch tested?
Did the unit test locally, and added new test cases.