wangyum commented on code in PR #42033:
URL: https://github.com/apache/spark/pull/42033#discussion_r1273007684


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1634,8 +1634,24 @@ private[client] class Shim_v2_3 extends Shim_v2_1 {
       pattern: String,
       tableType: TableType): Seq[String] = {
     recordHiveCall()
-    getTablesByTypeMethod.invoke(hive, dbName, pattern, tableType)
-      .asInstanceOf[JList[String]].asScala.toSeq
+    try {
+      getTablesByTypeMethod.invoke(hive, dbName, pattern, tableType)
+        .asInstanceOf[JList[String]].asScala.toSeq
+    } catch {
+      case ex: InvocationTargetException if 
ex.getCause.isInstanceOf[HiveException] =>
+        val cause = ex.getCause.getCause
+        if (cause != null && cause.isInstanceOf[MetaException] &&
+          cause.getMessage != null &&
+          cause.getMessage.contains("Invalid method name: 
'get_tables_by_type'")) {
+          // SparkUnsupportedOperationException (inherited from 
UnsupportedOperationException)
+          // is thrown when the Shim_v2_3#getTablesByType call returns no 
get_tables_by_type method.
+          // HiveClientImpl#listTablesByType will have fallback processing.
+          throw 
QueryExecutionErrors.getTablesByTypeUnsupportedByHiveVersionError()
+        }
+        else {
+          throw ex
+        }

Review Comment:
   ```suggestion
           } else {
             throw ex
           }
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to