rkirtir commented on code in PR #3608:
URL: https://github.com/apache/hive/pull/3608#discussion_r992116708
##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/ShowCompactionsOperation.java:
##########
@@ -68,6 +83,71 @@ public int execute() throws HiveException {
return 0;
}
+ private ShowCompactRequest getShowCompactioRequest(ShowCompactionsDesc desc)
throws MetaException, SemanticException {
+ ShowCompactRequest request = new ShowCompactRequest();
+ if (desc.getDbName() == null && desc.getTbName() != null) {
+ request.setDbname(SessionState.get().getCurrentDatabase());
+ } else {
+ request.setDbname(desc.getDbName());
+ }
+ if (desc.getTbName() != null && !desc.getTbName().isEmpty())
+ request.setTablename(desc.getTbName());
+ if (desc.getPoolName() != null && !desc.getPoolName().isEmpty())
+ request.setPoolName(desc.getPoolName());
+ if (desc.getCompactionType() != null &&
!desc.getCompactionType().isEmpty())
+ request.setType(inputCompactionType2DBType(desc.getCompactionType()));
+ if (desc.getCompactionStatus() != null &&
!desc.getCompactionStatus().isEmpty())
+ request.setState(compactorStateFromInput(desc.getCompactionStatus()));
+ if (desc.getPartSpec() != null && !desc.getPartSpec().isEmpty())
+ request.setPartitionname(getPartitionName(desc.getPartSpec()));
+ return request;
+ }
+
+ private String getPartitionName(Map<String, String> partitionSpec) throws
SemanticException {
+ String partitionName = null;
+ if (partitionSpec != null) {
+ try {
+ partitionName = Warehouse.makePartName(partitionSpec, false);
+ } catch (MetaException e) {
+ throw new SemanticException("partition " + partitionSpec.toString() +
" not found");
+ }
+ }
+ return partitionName;
+ }
+
+ static CompactionType inputCompactionType2DBType(String inputValue) throws
MetaException {
+ switch (inputValue.toUpperCase()) {
+ case MAJOR_TYPE:
+ return CompactionType.MAJOR;
+ case MINOR_TYPE:
+ return CompactionType.MINOR;
+ default:
+ throw new MetaException("Unexpected compaction type " + inputValue);
+ }
+ }
+
+ private String compactorStateFromInput(String s) throws MetaException {
Review Comment:
done
--
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]