[ https://issues.apache.org/jira/browse/HIVE-25091?focusedWorklogId=600572&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-600572 ]
ASF GitHub Bot logged work on HIVE-25091: ----------------------------------------- Author: ASF GitHub Bot Created on: 21/May/21 18:21 Start Date: 21/May/21 18:21 Worklog Time Spent: 10m Work Description: belugabehr commented on a change in pull request #2248: URL: https://github.com/apache/hive/pull/2248#discussion_r637117347 ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MSSQLConnectorProvider.java ########## @@ -0,0 +1,100 @@ +package org.apache.hadoop.hive.metastore.dataconnector.jdbc; + +import org.apache.hadoop.hive.metastore.ColumnType; +import org.apache.hadoop.hive.metastore.api.DataConnector; +import org.apache.hadoop.hive.metastore.api.MetaException; +import org.apache.hadoop.hive.metastore.api.Table; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class MSSQLConnectorProvider extends AbstractJDBCConnectorProvider { + private static Logger LOG = LoggerFactory.getLogger(MySQLConnectorProvider.class); + private static final String DRIVER_CLASS = "com.microsoft.sqlserver.jdbc.SQLServerDriver".intern(); + + public MSSQLConnectorProvider(String dbName, DataConnector dataConn) { + super(dbName, dataConn); + driverClassName = DRIVER_CLASS; + } + + /** + * Returns Hive Table objects from the remote database for tables that match a name pattern. + * @return List A collection of objects that match the name pattern, null otherwise. + * @throws MetaException To indicate any failures with executing this API + * @param regex + */ + @Override public List<Table> getTables(String regex) throws MetaException { + return null; + } + + @Override protected ResultSet fetchTableMetadata(String tableName) throws MetaException { + ResultSet rs = null; + try { + rs = getConnection().getMetaData().getColumns(null, scoped_db, tableName, null); + } catch (SQLException sqle) { + LOG.warn("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage()); + throw new MetaException("Could not retrieve table metadata from remote datasource, cause:" + sqle.getMessage()); + } + return rs; + } + + @Override protected ResultSet fetchTableNames() throws MetaException { + return null; + } + + @Override public List<String> getTableNames() throws MetaException { + ResultSet rs = null; + try { + rs = getConnection().getMetaData().getTables(null, scoped_db, null, null); + if (rs != null) { + List<String> tables = new ArrayList<String>(); Review comment: `= newArrayList<>();` ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/DerbySQLConnectorProvider.java ########## @@ -48,7 +48,14 @@ protected ResultSet fetchTableNames() throws MetaException { */ @Override public ResultSet fetchTableMetadata(String tableName) throws MetaException { - return null; + ResultSet rs = null; + try { + rs = getConnection().getMetaData().getColumns(scoped_db, null, tableName, null); + } catch (SQLException sqle) { + LOG.warn("Could not retrieve column names from JDBC table, cause:" + sqle.getMessage()); Review comment: `LOG.warn("Could not retrieve column names from JDBC table", sqle);` ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MSSQLConnectorProvider.java ########## @@ -0,0 +1,100 @@ +package org.apache.hadoop.hive.metastore.dataconnector.jdbc; + +import org.apache.hadoop.hive.metastore.ColumnType; +import org.apache.hadoop.hive.metastore.api.DataConnector; +import org.apache.hadoop.hive.metastore.api.MetaException; +import org.apache.hadoop.hive.metastore.api.Table; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class MSSQLConnectorProvider extends AbstractJDBCConnectorProvider { + private static Logger LOG = LoggerFactory.getLogger(MySQLConnectorProvider.class); + private static final String DRIVER_CLASS = "com.microsoft.sqlserver.jdbc.SQLServerDriver".intern(); + + public MSSQLConnectorProvider(String dbName, DataConnector dataConn) { + super(dbName, dataConn); + driverClassName = DRIVER_CLASS; + } + + /** + * Returns Hive Table objects from the remote database for tables that match a name pattern. + * @return List A collection of objects that match the name pattern, null otherwise. + * @throws MetaException To indicate any failures with executing this API + * @param regex + */ + @Override public List<Table> getTables(String regex) throws MetaException { + return null; + } + + @Override protected ResultSet fetchTableMetadata(String tableName) throws MetaException { + ResultSet rs = null; + try { + rs = getConnection().getMetaData().getColumns(null, scoped_db, tableName, null); + } catch (SQLException sqle) { + LOG.warn("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage()); + throw new MetaException("Could not retrieve table metadata from remote datasource, cause:" + sqle.getMessage()); + } + return rs; + } + + @Override protected ResultSet fetchTableNames() throws MetaException { + return null; + } + + @Override public List<String> getTableNames() throws MetaException { + ResultSet rs = null; + try { + rs = getConnection().getMetaData().getTables(null, scoped_db, null, null); + if (rs != null) { + List<String> tables = new ArrayList<String>(); + while(rs.next()) { + tables.add(rs.getString(3)); + } + return tables; + } + } catch (SQLException sqle) { + LOG.warn("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage()); + } finally { + try { + if (rs != null) { + rs.close(); + rs = null; + } + } catch(Exception e) { + LOG.info("Error in MSSQL Data Provider: "+e.getMessage()); Review comment: `LOG.error("Error in... ", e);` ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MSSQLConnectorProvider.java ########## @@ -0,0 +1,100 @@ +package org.apache.hadoop.hive.metastore.dataconnector.jdbc; + +import org.apache.hadoop.hive.metastore.ColumnType; +import org.apache.hadoop.hive.metastore.api.DataConnector; +import org.apache.hadoop.hive.metastore.api.MetaException; +import org.apache.hadoop.hive.metastore.api.Table; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class MSSQLConnectorProvider extends AbstractJDBCConnectorProvider { + private static Logger LOG = LoggerFactory.getLogger(MySQLConnectorProvider.class); + private static final String DRIVER_CLASS = "com.microsoft.sqlserver.jdbc.SQLServerDriver".intern(); + + public MSSQLConnectorProvider(String dbName, DataConnector dataConn) { + super(dbName, dataConn); + driverClassName = DRIVER_CLASS; + } + + /** + * Returns Hive Table objects from the remote database for tables that match a name pattern. + * @return List A collection of objects that match the name pattern, null otherwise. + * @throws MetaException To indicate any failures with executing this API + * @param regex + */ + @Override public List<Table> getTables(String regex) throws MetaException { + return null; + } + + @Override protected ResultSet fetchTableMetadata(String tableName) throws MetaException { + ResultSet rs = null; + try { + rs = getConnection().getMetaData().getColumns(null, scoped_db, tableName, null); + } catch (SQLException sqle) { + LOG.warn("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage()); Review comment: `LOG.warn("Could not retrieve table names from JDBC table", sqle);` ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MSSQLConnectorProvider.java ########## @@ -0,0 +1,100 @@ +package org.apache.hadoop.hive.metastore.dataconnector.jdbc; + +import org.apache.hadoop.hive.metastore.ColumnType; +import org.apache.hadoop.hive.metastore.api.DataConnector; +import org.apache.hadoop.hive.metastore.api.MetaException; +import org.apache.hadoop.hive.metastore.api.Table; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class MSSQLConnectorProvider extends AbstractJDBCConnectorProvider { + private static Logger LOG = LoggerFactory.getLogger(MySQLConnectorProvider.class); + private static final String DRIVER_CLASS = "com.microsoft.sqlserver.jdbc.SQLServerDriver".intern(); + + public MSSQLConnectorProvider(String dbName, DataConnector dataConn) { + super(dbName, dataConn); + driverClassName = DRIVER_CLASS; + } + + /** + * Returns Hive Table objects from the remote database for tables that match a name pattern. + * @return List A collection of objects that match the name pattern, null otherwise. + * @throws MetaException To indicate any failures with executing this API + * @param regex + */ + @Override public List<Table> getTables(String regex) throws MetaException { + return null; + } + + @Override protected ResultSet fetchTableMetadata(String tableName) throws MetaException { + ResultSet rs = null; + try { + rs = getConnection().getMetaData().getColumns(null, scoped_db, tableName, null); + } catch (SQLException sqle) { + LOG.warn("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage()); + throw new MetaException("Could not retrieve table metadata from remote datasource, cause:" + sqle.getMessage()); + } + return rs; + } + + @Override protected ResultSet fetchTableNames() throws MetaException { + return null; + } + + @Override public List<String> getTableNames() throws MetaException { + ResultSet rs = null; + try { + rs = getConnection().getMetaData().getTables(null, scoped_db, null, null); + if (rs != null) { + List<String> tables = new ArrayList<String>(); + while(rs.next()) { + tables.add(rs.getString(3)); + } + return tables; + } + } catch (SQLException sqle) { + LOG.warn("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage()); Review comment: `LOG.warn("Failed to retrieve ....", sqle);` ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java ########## @@ -216,16 +218,16 @@ protected Connection getConnection() { } } - private ResultSet fetchTableViaDBMetaData(String tableName) throws SQLException { - ResultSet rs = null; - try { - rs = getConnection().getMetaData().getColumns(scoped_db, null, tableName, null); - } catch (SQLException sqle) { - LOG.warn("Could not retrieve column names from JDBC table, cause:" + sqle.getMessage()); - throw sqle; - } - return rs; - } +// private ResultSet fetchTableViaDBMetaData(String tableName) throws SQLException { +// ResultSet rs = null; +// try { +// rs = getConnection().getMetaData().getColumns(scoped_db, null, tableName, null); +// } catch (SQLException sqle) { +// LOG.warn("Could not retrieve column names from JDBC table, cause:" + sqle.getMessage()); +// throw sqle; +// } +// return rs; +// } Review comment: Just drop the code if need be, do not check-in commented out code -- 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: 600572) Time Spent: 0.5h (was: 20m) > Implement connector provider for MSSQL and Oracle > ------------------------------------------------- > > Key: HIVE-25091 > URL: https://issues.apache.org/jira/browse/HIVE-25091 > Project: Hive > Issue Type: Sub-task > Reporter: Sai Hemanth Gantasala > Assignee: Sai Hemanth Gantasala > Priority: Major > Labels: pull-request-available > Time Spent: 0.5h > Remaining Estimate: 0h > > Provide an implementation of Connector provider for MSSQL and Oracle -- This message was sent by Atlassian Jira (v8.3.4#803005)