diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowCompactionsOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowCompactionsOperation.java index 87419be95e..4bf45fcc2a 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowCompactionsOperation.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowCompactionsOperation.java @@ -29,6 +29,7 @@ import org.apache.hadoop.hive.ql.ddl.DDLUtils; import org.apache.hadoop.hive.ql.exec.Utilities; import org.apache.hadoop.hive.ql.metadata.HiveException; +import org.apache.hadoop.hive.ql.session.SessionState; /** * Operation process of showing compactions. @@ -40,13 +41,16 @@ public ShowCompactionsOperation(DDLOperationContext context, ShowCompactionsDesc @Override public int execute() throws HiveException { + SessionState sessionState = SessionState.get(); // Call the metastore to get the status of all known compactions (completed get purged eventually) ShowCompactResponse rsp = context.getDb().showCompactions(); // Write the results into the file try (DataOutputStream os = DDLUtils.getOutputStream(new Path(desc.getResFile()), context)) { - // Write a header - writeHeader(os); + // Write a header for cliDriver + if(!sessionState.isHiveServerQuery()) { + writeHeader(os); + } if (rsp.getCompacts() != null) { for (ShowCompactResponseElement e : rsp.getCompacts()) {