Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10604#discussion_r49822542
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/sources/interfaces.scala ---
    @@ -664,6 +669,35 @@ abstract class HadoopFsRelation private[sql](
         })
       }
     
    +  /**
    +   * Groups the input files by bucket id, if bucketing is enabled and this 
data source is bucketed.
    +   * Returns None if there exists any malformed bucket files.
    +   */
    +  private def groupBucketFiles(
    +      files: Array[FileStatus]): Option[scala.collection.Map[Int, 
Array[FileStatus]]] = {
    +    if (getBucketSpec.isDefined) {
    +      val groupedBucketFiles = mutable.HashMap.empty[Int, 
mutable.ArrayBuffer[FileStatus]]
    +      var i = 0
    +      malformedBucketFile = false
    +      while (!malformedBucketFile && i < files.length) {
    +        val bucketId = BucketingUtils.getBucketId(files(i).getPath.getName)
    +        if (bucketId.isEmpty) {
    +          logError(s"File ${files(i).getPath} is expected to be a bucket 
file, but there is no " +
    +            "bucket id information in file name. Fall back to 
non-bucketing mode.")
    +          malformedBucketFile = true
    +        } else {
    +          val bucketFiles =
    +            groupedBucketFiles.getOrElseUpdate(bucketId.get, 
mutable.ArrayBuffer.empty)
    +          bucketFiles += files(i)
    +        }
    +        i += 1
    +      }
    +      Some(groupedBucketFiles.mapValues(_.toArray))
    --- End diff --
    
    we should return None if malformedBucketFile is true, no?



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to