You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/05/28 03:33:11 UTC

[GitHub] [spark] wangyum commented on a change in pull request #32675: [SPARK-35531][SQL] Can not insert into hive bucket table if create table with upper case schema

wangyum commented on a change in pull request #32675:
URL: https://github.com/apache/spark/pull/32675#discussion_r641220214



##########
File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
##########
@@ -1092,14 +1092,28 @@ private[hive] object HiveClientImpl extends Logging {
       hiveTable.setViewExpandedText(t)
     }
 
+    // hive may convert schema into lower cases while bucketSpec will not
+    // only convert if case not match
+    def convertColumnNames(schema: StructType, names: Seq[String]): Seq[String] = {
+      names.map(name => {
+        val s = schema.find(col => col.name.equalsIgnoreCase(name))
+        if (s.isDefined) {
+          s.get.name
+        } else {
+          name
+        }
+      })
+    }

Review comment:
       Rewrite `convertColumnNames`?
   ```scala
       def restoreHiveBucketSpecColNames(schema: StructType, names: Seq[String]): Seq[String] = {
         names.map { name =>
           schema.find(col => SQLConf.get.resolver(col.name, name)).map(_.name).getOrElse(name)
         }
       }
   ```




-- 
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:
users@infra.apache.org



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