deniskuzZ commented on code in PR #3708:
URL: https://github.com/apache/hive/pull/3708#discussion_r1023637301


##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/ShowCompactionsAnalyzer.java:
##########
@@ -80,15 +83,34 @@ public void analyzeInternal(ASTNode root) throws 
SemanticException {
         case HiveParser.TOK_COMPACT_ID:
           compactionId = Long.parseLong(child.getChild(0).getText());
           break;
+        case HiveParser.TOK_LIMIT:
+          limit = Short.valueOf((child.getChild(0)).getText());
+          break;
+        case HiveParser.TOK_ORDERBY:
+          orderBy = processSortOrderSpec(child);
+          break;
         default:
           dbName = stripQuotes(child.getText());
       }
     }
     ShowCompactionsDesc desc = new ShowCompactionsDesc(ctx.getResFile(), 
compactionId, dbName, tblName, poolName, compactionType,
-      compactionStatus, partitionSpec);
+      compactionStatus, partitionSpec, limit, orderBy);
     Task<DDLWork> task = TaskFactory.get(new DDLWork(getInputs(), 
getOutputs(), desc));
     rootTasks.add(task);
     task.setFetchSource(true);
     setFetchTask(createFetchTask(ShowCompactionsDesc.SCHEMA));
   }
+  private String processSortOrderSpec(ASTNode sortNode) {
+    List<PTFInvocationSpec.OrderExpression> orderExp = 
processOrderSpec(sortNode).getExpressions();
+    Map<String, String> orderByAttributes = orderExp.stream().
+      collect(Collectors.toMap(x -> getDbColumnName(x.getExpression()), x -> 
x.getOrder().toString()));
+    return orderByAttributes.entrySet().stream().map(e -> e.getKey() + "\t" + 
e.getValue()).collect(Collectors.joining(","));
+  }
+  private String getDbColumnName(ASTNode expression) {
+    String dbColumnPrefix = "CC_";
+    String dbColumnName = expression.getChild(0) == null ? 
expression.getText().replaceAll("\'", "").replaceAll(" ", "_").toUpperCase() :

Review Comment:
   code smells report: use replace() instead of replaceAll() if you don't 
provide regex pattern



-- 
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.

To unsubscribe, e-mail: [email protected]

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