Skip to content
Snippets Groups Projects
Commit d2383fb5 authored by Yin Huai's avatar Yin Huai Committed by Michael Armbrust
Browse files

[SQL] Handle special characters in the authority of a Path's URI.

Author: Yin Huai <yhuai@databricks.com>

Closes #5381 from yhuai/parquetPath2 and squashes the following commits:

fe296b4 [Yin Huai] Create new Path to take care special characters in the authority of a Path's URI.
parent 352a5da4
No related branches found
No related tags found
No related merge requests found
...@@ -432,7 +432,10 @@ private[sql] case class ParquetRelation2( ...@@ -432,7 +432,10 @@ private[sql] case class ParquetRelation2(
// FileInputFormat cannot handle empty lists. // FileInputFormat cannot handle empty lists.
if (selectedFiles.nonEmpty) { if (selectedFiles.nonEmpty) {
FileInputFormat.setInputPaths(job, selectedFiles.map(_.getPath): _*) // In order to encode the authority of a Path containning special characters such as /,
// we need to use the string retruned by the URI of the path to create a new Path.
val selectedPaths = selectedFiles.map(status => new Path(status.getPath.toUri.toString))
FileInputFormat.setInputPaths(job, selectedPaths: _*)
} }
// Try to push down filters when filter push-down is enabled. // Try to push down filters when filter push-down is enabled.
...@@ -484,10 +487,31 @@ private[sql] case class ParquetRelation2( ...@@ -484,10 +487,31 @@ private[sql] case class ParquetRelation2(
val cacheMetadata = useCache val cacheMetadata = useCache
@transient @transient
val cachedStatus = selectedFiles val cachedStatus = selectedFiles.map { st =>
// In order to encode the authority of a Path containning special characters such as /,
// we need to use the string retruned by the URI of the path to create a new Path.
val newPath = new Path(st.getPath.toUri.toString)
new FileStatus(
st.getLen,
st.isDir,
st.getReplication,
st.getBlockSize,
st.getModificationTime,
st.getAccessTime,
st.getPermission,
st.getOwner,
st.getGroup,
newPath)
}
@transient @transient
val cachedFooters = selectedFooters val cachedFooters = selectedFooters.map { f =>
// In order to encode the authority of a Path containning special characters such as /,
// we need to use the string retruned by the URI of the path to create a new Path.
new Footer(new Path(f.getFile.toUri.toString), f.getParquetMetadata)
}
// Overridden so we can inject our own cached files statuses. // Overridden so we can inject our own cached files statuses.
override def getPartitions: Array[SparkPartition] = { override def getPartitions: Array[SparkPartition] = {
......
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