[ https://issues.apache.org/jira/browse/HIVE-24396?focusedWorklogId=571954&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-571954 ]
ASF GitHub Bot logged work on HIVE-24396: ----------------------------------------- Author: ASF GitHub Bot Created on: 25/Mar/21 15:36 Start Date: 25/Mar/21 15:36 Worklog Time Spent: 10m Work Description: 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 571954) Time Spent: 5h 10m (was: 5h) > [New Feature] Add data connector support for remote datasources > --------------------------------------------------------------- > > Key: HIVE-24396 > URL: https://issues.apache.org/jira/browse/HIVE-24396 > Project: Hive > Issue Type: Improvement > Components: Hive > Reporter: Naveen Gangam > Assignee: Naveen Gangam > Priority: Major > Labels: pull-request-available > Time Spent: 5h 10m > Remaining Estimate: 0h > > This feature work is to be able to support in Hive Metastore to be able to > configure data connectors for remote datasources and map databases. We > currently have support for remote tables via StorageHandlers like > JDBCStorageHandler and HBaseStorageHandler. > Data connectors are a natural extension to this where we can map an entire > database or catalogs instead of individual tables. The tables within are > automagically mapped at runtime. The metadata for these tables are not > persisted in Hive. They are always mapped and built at runtime. > With this feature, we introduce a concept of type for Databases in Hive. > NATIVE vs REMOTE. All current databases are NATIVE. To create a REMOTE > database, the following syntax is to be used > CREATE REMOTE DATABASE remote_db USING <dataconnector> WITH DCPROPERTIES > (....); > Will attach a design doc to this jira. -- This message was sent by Atlassian Jira (v8.3.4#803005)