klcopp commented on a change in pull request #2199:
URL: https://github.com/apache/hive/pull/2199#discussion_r618535888



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -3739,34 +3743,34 @@ public GetLatestCommittedCompactionInfoResponse 
getLatestCommittedCompactionInfo
 
   public MetricsInfo getMetricsInfo() throws MetaException {
     Connection dbConn = null;
-    Statement stmt = null;
     try {
       MetricsInfo metrics = new MetricsInfo();
       String s = MessageFormat.format(SELECT_METRICS_INFO_QUERY, 
getEpochFn(dbProduct));

Review comment:
       Can add getEpochFn(dbProduct) to the preparedstatement instead.

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -290,7 +290,11 @@
         TxnStatus.OPEN + "') \"T\" CROSS JOIN (" +
       "SELECT COUNT(*), MIN(\"TXN_ID\"), ({0} - MIN(\"TXN_STARTED\"))/1000 
FROM \"TXNS\" WHERE \"TXN_STATE\"='" +
         TxnStatus.ABORTED + "') \"A\" CROSS JOIN (" +
-      "SELECT COUNT(*), ({0} - MIN(\"HL_ACQUIRED_AT\"))/1000 FROM 
\"HIVE_LOCKS\") \"HL\"";
+      "SELECT COUNT(*), ({0} - MIN(\"HL_ACQUIRED_AT\"))/1000 FROM 
\"HIVE_LOCKS\") \"HL\" CROSS JOIN (" +
+      "SELECT COUNT(*) FROM (SELECT COUNT(\"TXN_ID\"), \"T2W_DATABASE\", 
\"T2W_TABLE\" FROM \"TXN_TO_WRITE_ID\" " +
+          "INNER JOIN \"TXNS\" ON \"T2W_TXNID\" = \"TXN_ID\" WHERE 
\"TXN_STATE\"='" + TxnStatus.ABORTED + "' " +
+          "GROUP BY \"T2W_DATABASE\", \"T2W_TABLE\" HAVING COUNT(\"TXN_ID\") > 
?) \"L\") \"L\"";

Review comment:
       Theoretically mysql, postgresql, mssql, derby, and oracle can handle 
HAVING clauses but it might be worth it to try it out on all of them.
   (There's one use of HAVING already in CompactionTxnHandler but it's very 
new.)




-- 
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to