You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by px...@apache.org on 2015/08/11 23:21:20 UTC

[2/4] hive git commit: HIVE-7351 ANALYZE TABLE statement fails on postgres metastore (Navis via Alan Gates)

HIVE-7351 ANALYZE TABLE statement fails on postgres metastore (Navis via Alan Gates)

git-svn-id: https://svn.apache.org/repos/asf/hive/trunk@1672696 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/20e1cc84
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/20e1cc84
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/20e1cc84

Branch: refs/heads/branch-1.0
Commit: 20e1cc84527b2135162c66770400dabe5ee05153
Parents: 8b9ba26
Author: Alan Gates <ga...@apache.org>
Authored: Fri Apr 10 16:13:23 2015 +0000
Committer: Pengcheng Xiong <px...@apache.org>
Committed: Tue Aug 11 14:16:46 2015 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hive/ql/exec/Utilities.java    | 19 +++++++++++++++++++
 .../hive/ql/stats/jdbc/JDBCStatsAggregator.java  |  2 +-
 .../hive/ql/stats/jdbc/JDBCStatsPublisher.java   |  4 ++--
 3 files changed, 22 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/20e1cc84/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
index b2db584..c696c1d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
@@ -47,6 +47,7 @@ import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
 import java.sql.SQLTransientException;
 import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
@@ -3016,6 +3017,24 @@ public final class Utilities {
     }
   }
 
+  public static void setQueryTimeout(java.sql.Statement stmt, int timeout) throws SQLException {
+    if (timeout < 0) {
+      LOG.info("Invalid query timeout " + timeout);
+      return;
+    }
+    try {
+      stmt.setQueryTimeout(timeout);
+    } catch (SQLException e) {
+      String message = e.getMessage() == null ? null : e.getMessage().toLowerCase();
+      if (e instanceof SQLFeatureNotSupportedException ||
+         (message != null && (message.contains("implemented") || message.contains("supported")))) {
+        LOG.info("setQueryTimeout is not supported");
+        return;
+      }
+      throw e;
+    }
+  }
+
   /**
    * Introducing a random factor to the wait time before another retry.
    * The wait time is dependent on # of failures and a random factor.

http://git-wip-us.apache.org/repos/asf/hive/blob/20e1cc84/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsAggregator.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsAggregator.java b/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsAggregator.java
index e26031c..cf25bee 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsAggregator.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsAggregator.java
@@ -81,7 +81,7 @@ public class JDBCStatsAggregator implements StatsAggregator {
     Utilities.SQLCommand<Void> setQueryTimeout = new Utilities.SQLCommand<Void>() {
       @Override
       public Void run(PreparedStatement stmt) throws SQLException {
-        stmt.setQueryTimeout(timeout);
+        Utilities.setQueryTimeout(stmt, timeout);
         return null;
       }
     };

http://git-wip-us.apache.org/repos/asf/hive/blob/20e1cc84/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsPublisher.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsPublisher.java b/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsPublisher.java
index 32826e7..4028a9b 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsPublisher.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsPublisher.java
@@ -81,7 +81,7 @@ public class JDBCStatsPublisher implements StatsPublisher {
     Utilities.SQLCommand<Void> setQueryTimeout = new Utilities.SQLCommand<Void>() {
       @Override
       public Void run(PreparedStatement stmt) throws SQLException {
-        stmt.setQueryTimeout(timeout);
+        Utilities.setQueryTimeout(stmt, timeout);
         return null;
       }
     };
@@ -278,7 +278,7 @@ public class JDBCStatsPublisher implements StatsPublisher {
         conn = DriverManager.getConnection(connectionString);
 
         stmt = conn.createStatement();
-        stmt.setQueryTimeout(timeout);
+        Utilities.setQueryTimeout(stmt, timeout);
 
         // TODO: why is this not done using Hive db scripts?
         // Check if the table exists