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

ngangam 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 0dd63c6  HIVE-26041: Fix wrong type supplied for 
getLatestCommittedCompaction (Yu-Wen Lai via Naveen Gangam)
0dd63c6 is described below

commit 0dd63c69cbd3eedeefeece2384c30695667cf0bf
Author: Yu-Wen Lai <[email protected]>
AuthorDate: Wed Mar 16 11:49:41 2022 -0700

    HIVE-26041: Fix wrong type supplied for getLatestCommittedCompaction 
(Yu-Wen Lai via Naveen Gangam)
    
    We should use preparedStatement.setLong() to set correct type for CC_ID.
---
 .../hadoop/hive/metastore/txn/TestCompactionTxnHandler.java    | 10 ++++++++++
 .../java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java  |  8 +++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git 
a/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestCompactionTxnHandler.java
 
b/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestCompactionTxnHandler.java
index 46879b0..0de8ac6 100644
--- 
a/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestCompactionTxnHandler.java
+++ 
b/ql/src/test/org/apache/hadoop/hive/metastore/txn/TestCompactionTxnHandler.java
@@ -398,6 +398,16 @@ public class TestCompactionTxnHandler {
     assertEquals(partitionName, lci.getPartitionname());
     assertEquals(CompactionType.MINOR, lci.getType());
 
+    // response should contain the latest compaction
+    rqst.setLastCompactionId(1);
+    response = txnHandler.getLatestCommittedCompactionInfo(rqst);
+    assertNotNull(response);
+    assertEquals("Expecting a single record", 1, 
response.getCompactionsSize());
+    lci = response.getCompactions().get(0);
+    assertEquals("Expecting the second succeeded compaction record", 2, 
lci.getId());
+    assertEquals(partitionName, lci.getPartitionname());
+    assertEquals(CompactionType.MINOR, lci.getType());
+
     // response should only include compaction with id > 2
     rqst.setLastCompactionId(2);
     response = txnHandler.getLatestCommittedCompactionInfo(rqst);
diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
index bf61d08..7bcaf4a 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
@@ -4024,12 +4024,14 @@ abstract class TxnHandler implements TxnStore, 
TxnStore.MutexAPI {
         }
         if (rqst.isSetLastCompactionId()) {
           sb.append(" AND \"CC_ID\" > ?");
-          params.add(String.valueOf(rqst.getLastCompactionId()));
         }
         sb.append(" ORDER BY \"CC_ID\" DESC");
 
         pst = sqlGenerator.prepareStmtWithParameters(dbConn, sb.toString(), 
params);
-        LOG.debug("Going to execute query <" + sb.toString() + ">");
+        if (rqst.isSetLastCompactionId()) {
+          pst.setLong(params.size() + 1, rqst.getLastCompactionId());
+        }
+        LOG.debug("Going to execute query <{}>", sb);
         rs = pst.executeQuery();
         Set<String> partitionSet = new HashSet<>();
         while (rs.next()) {
@@ -4049,7 +4051,7 @@ abstract class TxnHandler implements TxnStore, 
TxnStore.MutexAPI {
           }
         }
       } catch (SQLException e) {
-        LOG.error("Unable to execute query " + e.getMessage());
+        LOG.error("Unable to execute query", e);
         checkRetryable(e, "getLatestCommittedCompactionInfo");
       } finally {
         close(rs, pst, dbConn);

Reply via email to