hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1633975 - in /hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/txn: CompactionTxnHandler.java TxnHandler.java
Date Thu, 23 Oct 2014 22:45:36 GMT
Author: gates
Date: Thu Oct 23 22:45:36 2014
New Revision: 1633975

URL: http://svn.apache.org/r1633975
Log:
HIVE-8543 Compactions fail on metastore using postgres (Damien Carol and Alan Gates, reviewed
by Eugene Koifman)

Modified:
    hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java
    hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java

Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java?rev=1633975&r1=1633974&r2=1633975&view=diff
==============================================================================
--- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java
(original)
+++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java
Thu Oct 23 22:45:36 2014
@@ -547,10 +547,27 @@ public class CompactionTxnHandler extend
     Statement stmt = null;
     ResultSet rs = null;
     try {
+      String quote = getIdentifierQuoteString(dbConn);
       stmt = dbConn.createStatement();
-      String s = "SELECT COLUMN_NAME FROM " + (ci.partName == null ? "TAB_COL_STATS" : "PART_COL_STATS")
+      StringBuilder bldr = new StringBuilder();
+      bldr.append("SELECT ").append(quote).append("COLUMN_NAME").append(quote)
+          .append(" FROM ")
+          .append(quote).append((ci.partName == null ? "TAB_COL_STATS" : "PART_COL_STATS"))
+              .append(quote)
+          .append(" WHERE ")
+          .append(quote).append("DB_NAME").append(quote).append(" = '").append(ci.dbname)
+              .append("' AND ").append(quote).append("TABLE_NAME").append(quote)
+              .append(" = '").append(ci.tableName).append("'");
+      if (ci.partName != null) {
+        bldr.append(" AND ").append(quote).append("PARTITION_NAME").append(quote).append("
= '")
+            .append(ci.partName).append("'");
+      }
+      String s = bldr.toString();
+
+      /*String s = "SELECT COLUMN_NAME FROM " + (ci.partName == null ? "TAB_COL_STATS" :
+          "PART_COL_STATS")
          + " WHERE DB_NAME='" + ci.dbname + "' AND TABLE_NAME='" + ci.tableName + "'"
-        + (ci.partName == null ? "" : " AND PARTITION_NAME='" + ci.partName + "'");
+        + (ci.partName == null ? "" : " AND PARTITION_NAME='" + ci.partName + "'");*/
       LOG.debug("Going to execute <" + s + ">");
       rs = stmt.executeQuery(s);
       List<String> columns = new ArrayList<String>();

Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java?rev=1633975&r1=1633974&r2=1633975&view=diff
==============================================================================
--- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java (original)
+++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java Thu
Oct 23 22:45:36 2014
@@ -90,6 +90,8 @@ public class TxnHandler {
   // Transaction timeout, in milliseconds.
   private long timeout;
 
+  private String identifierQuoteString; // quotes to use for quoting tables, where necessary
+
   // DEADLOCK DETECTION AND HANDLING
   // A note to developers of this class.  ALWAYS access HIVE_LOCKS before TXNS to avoid deadlock
   // between simultaneous accesses.  ALWAYS access TXN_COMPONENTS before HIVE_LOCKS .
@@ -960,6 +962,19 @@ public class TxnHandler {
     }
   }
 
+  /**
+   * Determine the String that should be used to quote identifiers.
+   * @param conn Active connection
+   * @return quotes
+   * @throws SQLException
+   */
+  protected String getIdentifierQuoteString(Connection conn) throws SQLException {
+    if (identifierQuoteString == null) {
+      identifierQuoteString = conn.getMetaData().getIdentifierQuoteString();
+    }
+    return identifierQuoteString;
+  }
+
   protected enum DatabaseProduct { DERBY, MYSQL, POSTGRES, ORACLE, SQLSERVER}
 
   /**



Mime
View raw message