diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java index a1b9e240a9..f829b682ec 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java @@ -2630,15 +2630,26 @@ public int showColumns(Hive db, ShowColumnsDesc showCols) try { List allCols = table.getCols(); allCols.addAll(table.getPartCols()); - List cols = getColumnsByPattern(allCols,showCols.getPattern()); - // In case the query is served by HiveServer2, don't pad it with spaces, - // as HiveServer2 output is consumed by JDBC/ODBC clients. - boolean isOutputPadded = !SessionState.get().isHiveServerQuery(); - TextMetaDataTable tmd = new TextMetaDataTable(); - for (FieldSchema fieldSchema : cols) { - tmd.addRow(MetaDataFormatUtils.extractColumnValues(fieldSchema)); + + if(showCols.getPattern() == null) { + boolean isOutputPadded = !SessionState.get().isHiveServerQuery(); + TextMetaDataTable tmd = new TextMetaDataTable(); + for (FieldSchema fieldSchema : allCols) { + tmd.addRow(MetaDataFormatUtils.extractColumnValues(fieldSchema)); + } + outStream.writeBytes(tmd.renderTable(isOutputPadded)); + } + else { + List cols = getColumnsByPattern(allCols,showCols.getPattern()); + // In case the query is served by HiveServer2, don't pad it with spaces, + // as HiveServer2 output is consumed by JDBC/ODBC clients. + boolean isOutputPadded = !SessionState.get().isHiveServerQuery(); + TextMetaDataTable tmd = new TextMetaDataTable(); + for (FieldSchema fieldSchema : cols) { + tmd.addRow(MetaDataFormatUtils.extractColumnValues(fieldSchema)); + } + outStream.writeBytes(tmd.renderTable(isOutputPadded)); } - outStream.writeBytes(tmd.renderTable(isOutputPadded)); } catch (IOException e) { throw new HiveException(e, ErrorMsg.GENERIC_ERROR); } finally {