Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14864#discussion_r77438939
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/DataSourceScanExec.scala 
---
    @@ -156,24 +155,57 @@ case class FileSourceScanExec(
         false
       }
     
    -  override val outputPartitioning: Partitioning = {
    +  @transient private lazy val selectedPartitions = 
relation.location.listFiles(partitionFilters)
    +
    +  override val (outputPartitioning, outputOrdering): (Partitioning, 
Seq[SortOrder]) = {
         val bucketSpec = if 
(relation.sparkSession.sessionState.conf.bucketingEnabled) {
           relation.bucketSpec
         } else {
           None
         }
    -    bucketSpec.map { spec =>
    -      val numBuckets = spec.numBuckets
    -      val bucketColumns = spec.bucketColumnNames.flatMap { n =>
    -        output.find(_.name == n)
    -      }
    -      if (bucketColumns.size == spec.bucketColumnNames.size) {
    -        HashPartitioning(bucketColumns, numBuckets)
    -      } else {
    -        UnknownPartitioning(0)
    -      }
    -    }.getOrElse {
    -      UnknownPartitioning(0)
    +    bucketSpec match {
    +      case Some(spec) =>
    +        val numBuckets = spec.numBuckets
    +
    +        def toAttribute(colName: String, columnType: String): Attribute =
    +          output.find(_.name == colName).getOrElse {
    +            throw new AnalysisException(s"Could not find $columnType 
column $colName for " +
    --- End diff --
    
    My concern is that, if a table has 3 columns:`i`, `j`, `k`, and is bucketed 
by `i` and `j`, sorted by `j` and `k`. Now we wanna read `i` and `j` from this 
table, then the generated RDD should be bucketed, i.e. the number of partitions 
of this RDD should be equal to the number of buckets. For each RDD partition, 
can we treat it as sorted by `j`?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to