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

    https://github.com/apache/spark/pull/17644#discussion_r114785533
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala 
---
    @@ -374,10 +375,39 @@ private[hive] class HiveClientImpl(
         Option(client.getTable(dbName, tableName, false)).map { h =>
           // Note: Hive separates partition columns and the schema, but for us 
the
           // partition columns are part of the schema
    +      val cols = h.getCols.asScala.map(fromHiveColumn)
           val partCols = h.getPartCols.asScala.map(fromHiveColumn)
    -      val schema = StructType(h.getCols.asScala.map(fromHiveColumn) ++ 
partCols)
    +      val schema = StructType(cols ++ partCols)
    +
    +      val bucketSpec = if (h.getNumBuckets > 0) {
    +        val sortColumnOrders = h.getSortCols.asScala
    +        // Currently Spark only supports columns to be sorted in ascending 
order
    +        // but Hive can support both ascending and descending order. If 
all the columns
    +        // are sorted in ascending order, only then propagate the 
sortedness information
    +        // to downstream processing / optimizations in Spark
    +        // TODO: In future we can have Spark support columns sorted in 
descending order
    +        val allAscendingSorted = sortColumnOrders.forall(_.getOrder == 
HIVE_COLUMN_ORDER_ASC)
    +
    +        val sortColumnNames = if (allAscendingSorted) {
    +          sortColumnOrders.map { sortOrder =>
    +            val columnName = sortOrder.getCol
    +
    +            if (!cols.exists(_.name.equalsIgnoreCase(columnName))) {
    --- End diff --
    
    why do we need to check this? Doesn't hive metastore already guarantees 
this?


---
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