xuanyuanking commented on a change in pull request #31638:
URL: https://github.com/apache/spark/pull/31638#discussion_r601526083
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/FileStreamSink.scala
##########
@@ -40,17 +41,35 @@ object FileStreamSink extends Logging {
* be read.
*/
def hasMetadata(path: Seq[String], hadoopConf: Configuration, sqlConf:
SQLConf): Boolean = {
- path match {
- case Seq(singlePath) =>
- val hdfsPath = new Path(singlePath)
- val fs = hdfsPath.getFileSystem(hadoopConf)
- if (fs.isDirectory(hdfsPath)) {
- val metadataPath = getMetadataLogPath(fs, hdfsPath, sqlConf)
- fs.exists(metadataPath)
- } else {
- false
- }
- case _ => false
+ if (sqlConf.getConf(SQLConf.FILE_SINK_FORMAT_CHECK_ENABLED)) {
+ path match {
+ case Seq(singlePath) =>
+ val hdfsPath = new Path(singlePath)
+ if (SparkHadoopUtil.get.isGlobPath(hdfsPath)) {
+ // Since file streaming sink doesn't support glob path, we can
assume there is no
+ // metadata directory.
+ return false
+ }
+ try {
+ val fs = hdfsPath.getFileSystem(hadoopConf)
+ if (fs.isDirectory(hdfsPath)) {
+ val metadataPath = getMetadataLogPath(fs, hdfsPath, sqlConf)
+ fs.exists(metadataPath)
+ } else {
+ false
+ }
+ } catch {
+ case NonFatal(e) =>
+ logError(s"Error while looking for metadata directory in the
path: $singlePath. " +
+ "If we want to skip the check and assume the path is not
generated by the file " +
Review comment:
Sure, done in 11f6bf0.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]