You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "wangyum (via GitHub)" <gi...@apache.org> on 2023/07/25 03:45:34 UTC

[GitHub] [spark] wangyum commented on a diff in pull request #42033: [SPARK-44454][SQL][HIVE] HiveShim getTablesByType support fallback

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


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1634,8 +1634,21 @@ 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'")) {
+          throw QueryExecutionErrors.getTablesByTypeUnsupportedByHiveVersionError()

Review Comment:
   Could you add a comment here? The exception should be align with https://github.com/apache/spark/blob/c5a23e9c23f7bd7066060d0791f290ad38fca76f/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala#L835



-- 
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: reviews-unsubscribe@spark.apache.org

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