This is an automated email from the ASF dual-hosted git repository.

dmollitor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new ad1f6c5  HIVE-25477: Clean Up JDBC Code (David Mollitor reviewed by 
Miklos Gergely)
ad1f6c5 is described below

commit ad1f6c5ee17d784de00075416c47753583b81e08
Author: belugabehr <[email protected]>
AuthorDate: Wed Aug 25 12:51:55 2021 -0400

    HIVE-25477: Clean Up JDBC Code (David Mollitor reviewed by Miklos Gergely)
---
 .../java/org/apache/hive/jdbc/HiveConnection.java  | 12 +---
 .../org/apache/hive/jdbc/HiveDatabaseMetaData.java | 82 ----------------------
 .../hive/jdbc/HttpRequestInterceptorBase.java      |  2 -
 jdbc/src/java/org/apache/hive/jdbc/Utils.java      |  4 +-
 4 files changed, 3 insertions(+), 97 deletions(-)

diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java 
b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
index bc5245f..4eefded 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
@@ -46,7 +46,6 @@ import java.sql.CallableStatement;
 import java.sql.Clob;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
-import java.sql.DriverManager;
 import java.sql.NClob;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -68,7 +67,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.concurrent.Executor;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.stream.Stream;
 
@@ -100,8 +98,6 @@ import org.apache.hive.jdbc.saml.IJdbcBrowserClientFactory;
 import org.apache.hive.service.rpc.thrift.TSetClientInfoResp;
 
 import org.apache.hive.service.rpc.thrift.TSetClientInfoReq;
-import org.apache.hadoop.hive.common.auth.HiveAuthUtils;
-import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hive.jdbc.Utils.JdbcConnectionParams;
 import org.apache.hive.service.auth.HiveAuthConstants;
 import org.apache.hive.service.auth.KerberosSaslHelper;
@@ -120,8 +116,6 @@ import org.apache.hive.service.rpc.thrift.TProtocolVersion;
 import org.apache.hive.service.rpc.thrift.TRenewDelegationTokenReq;
 import org.apache.hive.service.rpc.thrift.TRenewDelegationTokenResp;
 import org.apache.hive.service.rpc.thrift.TSessionHandle;
-import org.apache.hive.service.rpc.thrift.TSetClientInfoReq;
-import org.apache.hive.service.rpc.thrift.TSetClientInfoResp;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestInterceptor;
@@ -156,8 +150,6 @@ import org.apache.thrift.transport.TTransportException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.annotations.VisibleForTesting;
-
 /**
  * HiveConnection.
  *
@@ -696,7 +688,7 @@ public class HiveConnection implements java.sql.Connection {
         } else {
           for (final Class<? extends IOException> rejectException : 
this.nonRetriableClasses) {
             if (rejectException.isInstance(exception)) {
-              LOG.info("Not retrying as the class (" + exception.getClass() + 
") is an instance of is non-retriable class.");;
+              LOG.info("Not retrying as the class (" + exception.getClass() + 
") is an instance of is non-retriable class.");
               return false;
             }
           }
@@ -1674,7 +1666,7 @@ public class HiveConnection implements 
java.sql.Connection {
     }
     boolean rc = false;
     try {
-      String productName = new HiveDatabaseMetaData(this, client, sessHandle)
+      new HiveDatabaseMetaData(this, client, sessHandle)
               .getDatabaseProductName();
       rc = true;
     } catch (SQLException e) {
diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java 
b/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
index 2591785..d1cfd7e 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
@@ -22,8 +22,6 @@ import java.util.ArrayList;
 
 import java.util.List;
 
-import jline.internal.Log;
-import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hive.jdbc.Utils.JdbcConnectionParams;
 import org.apache.hive.service.cli.TableSchema;
@@ -34,13 +32,11 @@ import java.sql.RowIdLifetime;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.util.Arrays;
-import java.util.Comparator;
 import java.util.Map;
 import java.util.jar.Attributes;
 import org.apache.hadoop.hive.metastore.TableType;
 import org.apache.hive.service.cli.GetInfoType;
 import org.apache.hive.service.rpc.thrift.TCLIService;
-import org.apache.hive.service.rpc.thrift.TCLIService.Iface;
 import org.apache.hive.service.rpc.thrift.TGetCatalogsReq;
 import org.apache.hive.service.rpc.thrift.TGetCatalogsResp;
 import org.apache.hive.service.rpc.thrift.TGetColumnsReq;
@@ -218,47 +214,6 @@ public class HiveDatabaseMetaData implements 
DatabaseMetaData {
     throw new SQLFeatureNotSupportedException("Method not supported");
   }
 
-  /**
-   * Convert a pattern containing JDBC catalog search wildcards into
-   * Java regex patterns.
-   *
-   * @param pattern input which may contain '%' or '_' wildcard characters, or
-   * these characters escaped using {@link #getSearchStringEscape()}.
-   * @return replace %/_ with regex search characters, also handle escaped
-   * characters.
-   */
-  private String convertPattern(final String pattern) {
-    if (pattern==null) {
-      return ".*";
-    } else {
-      StringBuilder result = new StringBuilder(pattern.length());
-
-      boolean escaped = false;
-      for (int i = 0, len = pattern.length(); i < len; i++) {
-        char c = pattern.charAt(i);
-        if (escaped) {
-          if (c != SEARCH_STRING_ESCAPE) {
-            escaped = false;
-          }
-          result.append(c);
-        } else {
-          if (c == SEARCH_STRING_ESCAPE) {
-            escaped = true;
-            continue;
-          } else if (c == '%') {
-            result.append(".*");
-          } else if (c == '_') {
-            result.append('.');
-          } else {
-            result.append(Character.toLowerCase(c));
-          }
-        }
-      }
-
-      return result.toString();
-    }
-  }
-
   public ResultSet getColumns(String catalog, String schemaPattern,
       String tableNamePattern, String columnNamePattern) throws SQLException {
     TGetColumnsResp colResp;
@@ -281,27 +236,6 @@ public class HiveDatabaseMetaData implements 
DatabaseMetaData {
     .build();
   }
 
-  /**
-   * We sort the output of getColumns to guarantee jdbc compliance.
-   * First check by table name then by ordinal position
-   */
-  private class GetColumnsComparator implements Comparator<JdbcColumn> {
-
-    public int compare(JdbcColumn o1, JdbcColumn o2) {
-      int compareName = o1.getTableName().compareTo(o2.getTableName());
-      if (compareName==0) {
-        if (o1.getOrdinalPos() > o2.getOrdinalPos()) {
-          return 1;
-        } else if (o1.getOrdinalPos() < o2.getOrdinalPos()) {
-          return -1;
-        }
-        return 0;
-      } else {
-        return compareName;
-      }
-    }
-  }
-
   public Connection getConnection() throws SQLException {
     return this.connection;
   }
@@ -745,22 +679,6 @@ public class HiveDatabaseMetaData implements 
DatabaseMetaData {
   }
 
   /**
-   * We sort the output of getTables to guarantee jdbc compliance.
-   * First check by table type then by table name
-   */
-  private class GetTablesComparator implements Comparator<JdbcTable> {
-
-    public int compare(JdbcTable o1, JdbcTable o2) {
-      int compareType = o1.getType().compareTo(o2.getType());
-      if (compareType==0) {
-        return o1.getTableName().compareTo(o2.getTableName());
-      } else {
-        return compareType;
-      }
-    }
-  }
-
-  /**
    * Translate hive table types into jdbc table types.
    * @param hivetabletype
    * @return the type of the table
diff --git a/jdbc/src/java/org/apache/hive/jdbc/HttpRequestInterceptorBase.java 
b/jdbc/src/java/org/apache/hive/jdbc/HttpRequestInterceptorBase.java
index 1e6ddeb..eeaa48a 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HttpRequestInterceptorBase.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HttpRequestInterceptorBase.java
@@ -20,8 +20,6 @@ package org.apache.hive.jdbc;
 
 import java.io.IOException;
 import java.util.Map;
-import java.util.concurrent.locks.ReentrantLock;
-
 import org.apache.http.Header;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
diff --git a/jdbc/src/java/org/apache/hive/jdbc/Utils.java 
b/jdbc/src/java/org/apache/hive/jdbc/Utils.java
index 4e329f3..ffd628c 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/Utils.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/Utils.java
@@ -32,7 +32,6 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hive.service.cli.HiveSQLException;
 import org.apache.hive.service.rpc.thrift.TStatus;
 import org.apache.hive.service.rpc.thrift.TStatusCode;
@@ -674,8 +673,7 @@ public class Utils {
      */
     int fromIndex = Utils.URL_PREFIX.length();
     int toIndex = -1;
-    ArrayList<String> toIndexChars = new ArrayList<String>(Arrays.asList("/", 
"?", "#"));
-    for (String toIndexChar : toIndexChars) {
+    for (String toIndexChar : Arrays.asList("/", "?", "#")) {
       toIndex = uri.indexOf(toIndexChar, fromIndex);
       if (toIndex > 0) {
         break;

Reply via email to