[GitHub] [hive] nrg4878 commented on a change in pull request #2371: HIVE-25213: Implement List getTables() for existing connectors

Mon, 14 Jun 2021 20:13:12 -0700


nrg4878 commented on a change in pull request #2371:
URL: https://github.com/apache/hive/pull/2371#discussion_r651415437



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
##########
@@ -129,7 +129,30 @@ protected Connection getConnection() {
    * @throws MetaException To indicate any failures with executing this API
    * @param regex
    */
-  @Override public abstract List<Table> getTables(String regex) throws 
MetaException;
+  @Override public List<Table> getTables(String regex) throws MetaException {
+    ResultSet rs = null;
+    try {
+      rs = fetchTablesViaDBMetaData(regex);
+      if (rs != null) {
+        List<Table> tables = new ArrayList<Table>();
+        while(rs.next()) {
+          tables.add(getTable(rs.getString(3)));

Review comment:
       so getTable() can throw an exception when retrieving column info for 
each table. What should happen when there is an exception on a certain table? 
Currently, we are ending the iteration and throwing an exception. I dont know 
what the right behavior should be, whether to return the remaining table or to 
throw an exception. Do you know what the JDBC spec/javadocs for getTables() 
says/does for this?

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
##########
@@ -3799,10 +3799,33 @@ public Table get_table_core(GetTableRequest 
getTableRequest) throws MetaExceptio
   @Override
   public GetTablesResult get_table_objects_by_name_req(GetTablesRequest req) 
throws TException {
     String catName = req.isSetCatName() ? req.getCatName() : 
getDefaultCatalog(conf);
+    if (isDatabaseRemote(req.getDbName())) {
+      return new 
GetTablesResult(getRemoteTableObjectsInternal(req.getDbName(), 
req.getTblNames(), req.getTablesPattern()));
+    }
     return new GetTablesResult(getTableObjectsInternal(catName, 
req.getDbName(),
         req.getTblNames(), req.getCapabilities(), req.getProjectionSpec(), 
req.getTablesPattern()));
   }
 
+  private String tableNames2regex(List<String> tableNames) {
+    return "/^(" + String.join("|", tableNames) + ")$/";

Review comment:
       Are there any nuances around how different RDBMS database drivers 
process this regex? Do we know that this is truely a regex or do certain 
drivers expect other things?

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
##########
@@ -208,7 +232,7 @@ protected Connection getConnection() {
       return table;
     } catch (Exception e) {
       LOG.warn("Exception retrieving remote table " + scoped_db + "." + 
tableName + " via data connector "
-          + connector.getName());
+              + connector.getName());

Review comment:
       nit: please remove extra spaces

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
##########
@@ -176,7 +199,7 @@ protected Connection getConnection() {
     Table table = null;
     try {
       // rs = fetchTableMetadata(tableName);

Review comment:
       nit: I know this is old code. But can you please delete the commented 
line as well?

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
##########
@@ -28,7 +28,7 @@
 
   // duplicate constants from Constants.java to avoid a dependency on 
hive-common
   public static final String JDBC_HIVE_STORAGE_HANDLER_ID =
-      "org.apache.hive.storage.jdbc.JdbcStorageHandler";
+          "org.apache.hive.storage.jdbc.JdbcStorageHandler";

Review comment:
       nit: please remove extra spaces

##########
File path: itests/qtest/target/db_for_connectortest.db/service.properties
##########
@@ -0,0 +1,23 @@
+#/private/tmp/db_for_connectortest.db

Review comment:
       All the derby db files included above are from the 
$root/itests/qtest/target directory. These will get deleted when you run “mvn 
clean”
   instead these files need to reside in $root/data/resources (I think we 
discussed this location) and then a change to itests/pom.xml to copy from there 
to itests/qtest/target directory when a build is run in “itests/” directory.

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
##########
@@ -53,7 +53,7 @@
   private static final String JDBC_OUTPUTFORMAT_CLASS = 
"org.apache.hive.storage.jdbc.JdbcOutputFormat".intern();
 
   String type = null; // MYSQL, POSTGRES, ORACLE, DERBY, MSSQL, DB2 etc.
-  String driverClassName = null;
+  //String driverClassName = null;

Review comment:
       I thought this was set and used by sub-classes ? no? if it is not, 
instead of commenting, please delete. 




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

Reply via email to