You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by bl...@apache.org on 2019/11/12 20:09:39 UTC
[flink] branch release-1.9 updated: [FLINK-14673][hive] Shouldn't
expect HMS client to throw NoSuchObjectException for non-existing function
This is an automated email from the ASF dual-hosted git repository.
bli pushed a commit to branch release-1.9
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.9 by this push:
new aaae2d5 [FLINK-14673][hive] Shouldn't expect HMS client to throw NoSuchObjectException for non-existing function
aaae2d5 is described below
commit aaae2d51d21c2e93c07a03125592019c8a74746f
Author: Rui Li <li...@apache.org>
AuthorDate: Mon Nov 11 11:48:02 2019 +0800
[FLINK-14673][hive] Shouldn't expect HMS client to throw NoSuchObjectException for non-existing function
this closes #10145.
---
.../hive/client/HiveMetastoreClientWrapper.java | 15 +++++++++++++--
.../flink/table/catalog/hive/client/HiveShim.java | 14 --------------
.../flink/table/catalog/hive/client/HiveShimV1.java | 19 -------------------
.../flink/table/catalog/hive/client/HiveShimV2.java | 7 -------
4 files changed, 13 insertions(+), 42 deletions(-)
diff --git a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveMetastoreClientWrapper.java b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveMetastoreClientWrapper.java
index e1b25e6..a71b549 100644
--- a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveMetastoreClientWrapper.java
+++ b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveMetastoreClientWrapper.java
@@ -226,8 +226,19 @@ public class HiveMetastoreClientWrapper implements AutoCloseable {
}
public Function getFunction(String databaseName, String functionName) throws MetaException, TException {
- HiveShim hiveShim = HiveShimLoader.loadHiveShim(hiveVersion);
- return hiveShim.getFunction(client, databaseName, functionName);
+ try {
+ // Hive may not throw NoSuchObjectException if function doesn't exist, instead it throws a MetaException
+ return client.getFunction(databaseName, functionName);
+ } catch (MetaException e) {
+ // need to check the cause and message of this MetaException to decide whether it should actually be a NoSuchObjectException
+ if (e.getCause() instanceof NoSuchObjectException) {
+ throw (NoSuchObjectException) e.getCause();
+ }
+ if (e.getMessage().startsWith(NoSuchObjectException.class.getSimpleName())) {
+ throw new NoSuchObjectException(e.getMessage());
+ }
+ throw e;
+ }
}
public void alter_table(String databaseName, String tableName, Table table)
diff --git a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShim.java b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShim.java
index 812ece1..6c2ad7e 100644
--- a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShim.java
+++ b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShim.java
@@ -23,10 +23,8 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
-import org.apache.hadoop.hive.metastore.api.Function;
import org.apache.hadoop.hive.metastore.api.InvalidOperationException;
import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.hadoop.hive.metastore.api.UnknownDBException;
import org.apache.hadoop.hive.ql.udf.generic.SimpleGenericUDAFParameterInfo;
@@ -61,18 +59,6 @@ public interface HiveShim {
List<String> getViews(IMetaStoreClient client, String databaseName) throws UnknownDBException, TException;
/**
- * Gets a function from a database with the given HMS client.
- *
- * @param client the Hive Metastore client
- * @param dbName name of the database
- * @param functionName name of the function
- * @return the Function under the specified name
- * @throws NoSuchObjectException if the function doesn't exist
- * @throws TException for any other generic exceptions caused by Thrift
- */
- Function getFunction(IMetaStoreClient client, String dbName, String functionName) throws NoSuchObjectException, TException;
-
- /**
* Moves a particular file or directory to trash.
* The file/directory can potentially be deleted (w/o going to trash) if purge is set to true, or if it cannot
* be moved properly.
diff --git a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV1.java b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV1.java
index 6afcf5a..314fe26 100644
--- a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV1.java
+++ b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV1.java
@@ -28,10 +28,8 @@ import org.apache.hadoop.hive.common.StatsSetupConst;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
import org.apache.hadoop.hive.metastore.RetryingMetaStoreClient;
-import org.apache.hadoop.hive.metastore.api.Function;
import org.apache.hadoop.hive.metastore.api.InvalidOperationException;
import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.hadoop.hive.metastore.api.UnknownDBException;
import org.apache.hadoop.hive.ql.udf.generic.SimpleGenericUDAFParameterInfo;
@@ -79,23 +77,6 @@ public class HiveShimV1 implements HiveShim {
}
@Override
- public Function getFunction(IMetaStoreClient client, String dbName, String functionName) throws NoSuchObjectException, TException {
- try {
- // hive-1.x doesn't throw NoSuchObjectException if function doesn't exist, instead it throws a MetaException
- return client.getFunction(dbName, functionName);
- } catch (MetaException e) {
- // need to check the cause and message of this MetaException to decide whether it should actually be a NoSuchObjectException
- if (e.getCause() instanceof NoSuchObjectException) {
- throw (NoSuchObjectException) e.getCause();
- }
- if (e.getMessage().startsWith(NoSuchObjectException.class.getSimpleName())) {
- throw new NoSuchObjectException(e.getMessage());
- }
- throw e;
- }
- }
-
- @Override
public boolean moveToTrash(FileSystem fs, Path path, Configuration conf, boolean purge) throws IOException {
try {
Method method = FileUtils.class.getDeclaredMethod("moveToTrash", FileSystem.class, Path.class, Configuration.class);
diff --git a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV2.java b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV2.java
index 2510497..9825734 100644
--- a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV2.java
+++ b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV2.java
@@ -28,10 +28,8 @@ import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
import org.apache.hadoop.hive.metastore.RetryingMetaStoreClient;
import org.apache.hadoop.hive.metastore.TableType;
-import org.apache.hadoop.hive.metastore.api.Function;
import org.apache.hadoop.hive.metastore.api.InvalidOperationException;
import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.hadoop.hive.metastore.api.UnknownDBException;
import org.apache.hadoop.hive.ql.udf.generic.SimpleGenericUDAFParameterInfo;
@@ -78,11 +76,6 @@ public class HiveShimV2 implements HiveShim {
}
@Override
- public Function getFunction(IMetaStoreClient client, String dbName, String functionName) throws NoSuchObjectException, TException {
- return client.getFunction(dbName, functionName);
- }
-
- @Override
public boolean moveToTrash(FileSystem fs, Path path, Configuration conf, boolean purge) throws IOException {
try {
Method method = FileUtils.class.getDeclaredMethod("moveToTrash", FileSystem.class, Path.class,