nrg4878 commented on a change in pull request #2037:
URL: https://github.com/apache/hive/pull/2037#discussion_r601601931
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
##########
@@ -846,6 +847,110 @@ public void alterTable(String catName, String dbName,
String tblName, Table newT
}
}
+ /**
+ * Create a dataconnector
+ * @param connector
+ * @param ifNotExist if true, will ignore AlreadyExistsException exception
+ * @throws AlreadyExistsException
+ * @throws HiveException
+ */
+ public void createDataConnector(DataConnector connector, boolean ifNotExist)
+ throws AlreadyExistsException, HiveException {
+ try {
+ getMSC().createDataConnector(connector);
+ } catch (AlreadyExistsException e) {
+ if (!ifNotExist) {
+ throw e;
+ }
+ } catch (Exception e) {
+ throw new HiveException(e);
+ }
+ }
+
+ /**
+ * Create a DataConnector. Raise an error if a dataconnector with the same
name already exists.
+ * @param connector
+ * @throws AlreadyExistsException
+ * @throws HiveException
+ */
+ public void createDataConnector(DataConnector connector) throws
AlreadyExistsException, HiveException {
+ createDataConnector(connector, false);
+ }
+
+ /**
+ * Drop a dataconnector.
+ * @param name
+ * @throws NoSuchObjectException
+ * @throws HiveException
+ * @see
org.apache.hadoop.hive.metastore.HiveMetaStoreClient#dropDataConnector(java.lang.String,
boolean, boolean)
+ */
+ public void dropDataConnector(String name, boolean ifNotExists) throws
HiveException, NoSuchObjectException {
+ dropDataConnector(name, ifNotExists, true);
+ }
+
+ /**
+ * Drop a dataconnector
+ * @param name
+ * @param checkReferences drop only if there are no dbs referencing this
connector
+ * @throws HiveException
+ * @throws NoSuchObjectException
+ */
+ public void dropDataConnector(String name, boolean ifNotExists, boolean
checkReferences)
+ throws HiveException, NoSuchObjectException {
+ try {
+ getMSC().dropDataConnector(name, ifNotExists, checkReferences);
+ } catch (NoSuchObjectException e) {
+ if (!ifNotExists)
+ throw e;
+ } catch (Exception e) {
+ throw new HiveException(e);
+ }
+ }
+
+ /**
+ * Get the dataconnector by name.
+ * @param dcName the name of the dataconnector.
+ * @return a DataConnector object if this dataconnector exists, null
otherwise.
+ * @throws HiveException
+ */
+ public DataConnector getDataConnector(String dcName) throws HiveException {
+ try {
+ return getMSC().getDataConnector(dcName);
+ } catch (NoSuchObjectException e) {
+ return null;
Review comment:
Well, this is consistent with what we do for getDatabase, getTable(),
getPartition() calls. So this code is on the HS2 side. HMS already throws a
NoSuchObjectException to its clients. Now the client can decide what it does
with it. So in case of HS2, we dont automatically want to rethrow the exception.
Say you do a "describe connector foo" that doesn't exist. You dont want to
see an exception in beeline. You just want a pretty message saying this
connector doesn't exist.
Another example, "create connector foo". Hs2 first calls getConnector() to
check if it already exists. This is a common pattern for all create statements.
In this case, it is expected to be null. It is not necessarily a bad thing. We
want this call to not add any noise to the logs to the client. We dont want to
throw this exception back prematurely to the client.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]