gatorsmile commented on a change in pull request #24774: [SPARK-27899][SQL] 
Make HiveMetastoreClient.getTableObjectsByName available in 
ExternalCatalog/SessionCatalog API
URL: https://github.com/apache/spark/pull/24774#discussion_r291037843
 
 

 ##########
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
 ##########
 @@ -1091,6 +1114,38 @@ private[hive] object HiveClientImpl {
       stats = readHiveStats(properties))
   }
 
+  /**
+   * This is the same process copied from the method `getTable()`
+   * of [[org.apache.hadoop.hive.ql.metadata.Hive]] to do some extra fixes for 
non-views.
+   * Methods of extracting multiple [[HiveTable]] like `getRawTablesByName()`
+   * should invoke this before return.
+   */
+  def extraFixesForNonView(tTable: MetaStoreApiTable): MetaStoreApiTable = {
+    // For non-views, we need to do some extra fixes
+    if (!(HiveTableType.VIRTUAL_VIEW.toString == tTable.getTableType)) {
+      // Fix the non-printable chars
+      val parameters: JMap[String, String] = tTable.getSd.getParameters
+      val sf: String = parameters.get(serdeConstants.SERIALIZATION_FORMAT)
+      if (sf != null) {
+        val b: Array[Char] = sf.toCharArray
+        if ((b.length == 1) && (b(0) < 10)) { // ^A, ^B, ^C, ^D, \t
+          parameters.put(serdeConstants.SERIALIZATION_FORMAT, 
Integer.toString(b(0)))
+        }
+      }
+      // Use LazySimpleSerDe for MetadataTypedColumnsetSerDe.
+      // NOTE: LazySimpleSerDe does not support tables with a single column of 
col
+      // of type "array<string>". This happens when the table is created using
+      // an earlier version of Hive.
+      if (classOf[MetadataTypedColumnsetSerDe].getName
+            == tTable.getSd.getSerdeInfo.getSerializationLib
 
 Review comment:
   4-space indent 
   
   == needs to be moved to the line 1139

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


With regards,
Apache Git Services

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

Reply via email to