HIVE-17540: remove feature: describe pretty (Zoltan Haindrich, reviewed by Ashutosh Chauhan)
Signed-off-by: Zoltan Haindrich <k...@rxd.hu> Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/2a5e72c2 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/2a5e72c2 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/2a5e72c2 Branch: refs/heads/master Commit: 2a5e72c20d7351831e8e189ba212d4918420092f Parents: 38a594f Author: Zoltan Haindrich <k...@rxd.hu> Authored: Fri Oct 6 10:55:56 2017 +0200 Committer: Zoltan Haindrich <k...@rxd.hu> Committed: Fri Oct 6 10:55:56 2017 +0200 ---------------------------------------------------------------------- .../org/apache/hadoop/hive/ql/exec/DDLTask.java | 2 +- .../formatting/JsonMetaDataFormatter.java | 5 +- .../metadata/formatting/MetaDataFormatter.java | 2 +- .../formatting/MetaDataPrettyFormatUtils.java | 243 -------------- .../formatting/TextMetaDataFormatter.java | 8 +- .../hive/ql/parse/DDLSemanticAnalyzer.java | 25 +- .../org/apache/hadoop/hive/ql/parse/HiveLexer.g | 1 - .../apache/hadoop/hive/ql/parse/HiveParser.g | 2 +- .../hadoop/hive/ql/parse/IdentifiersParser.g | 2 +- .../hadoop/hive/ql/plan/DescTableDesc.java | 14 - .../queries/clientpositive/describe_pretty.q | 80 ----- .../queries/clientpositive/escape_comments.q | 1 - .../beeline/escape_comments.q.out | 18 -- .../clientpositive/describe_pretty.q.out | 323 ------------------- .../clientpositive/escape_comments.q.out | 18 -- 15 files changed, 26 insertions(+), 718 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java ---------------------------------------------------------------------- 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 aac38eb..ee3f52d 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 @@ -3501,7 +3501,7 @@ public class DDLTask extends Task<DDLWork> implements Serializable { boolean isOutputPadded = !SessionState.get().isHiveServerQuery(); formatter.describeTable(outStream, colPath, tableName, tbl, part, cols, descTbl.isFormatted(), descTbl.isExt(), - descTbl.isPretty(), isOutputPadded, colStats, + isOutputPadded, colStats, pkInfo, fkInfo, ukInfo, nnInfo); LOG.debug("DDLTask: written data for " + tbl.getTableName()); http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java index d795a19..bdf1b26 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java @@ -105,7 +105,7 @@ public class JsonMetaDataFormatter implements MetaDataFormatter { @Override public void describeTable(DataOutputStream out, String colPath, String tableName, Table tbl, Partition part, List<FieldSchema> cols, - boolean isFormatted, boolean isExt, boolean isPretty, + boolean isFormatted, boolean isExt, boolean isOutputPadded, List<ColumnStatisticsObj> colStats, PrimaryKeyInfo pkInfo, ForeignKeyInfo fkInfo, UniqueConstraint ukInfo, NotNullConstraint nnInfo) throws HiveException { @@ -362,8 +362,9 @@ public class JsonMetaDataFormatter implements MetaDataFormatter { String[] kv = StringUtils.split(part, "=", 2); if (kv != null) { name = kv[0]; - if (kv.length > 1) + if (kv.length > 1) { val = URLDecoder.decode(kv[1], "UTF-8"); + } } if (val != null) { names.add(name + "='" + val + "'"); http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataFormatter.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataFormatter.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataFormatter.java index 72ee440..ac5b306 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataFormatter.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataFormatter.java @@ -83,7 +83,7 @@ public interface MetaDataFormatter { */ public void describeTable(DataOutputStream out, String colPath, String tableName, Table tbl, Partition part, List<FieldSchema> cols, - boolean isFormatted, boolean isExt, boolean isPretty, + boolean isFormatted, boolean isExt, boolean isOutputPadded, List<ColumnStatisticsObj> colStats, PrimaryKeyInfo pkInfo, ForeignKeyInfo fkInfo, UniqueConstraint ukInfo, NotNullConstraint nnInfo) http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataPrettyFormatUtils.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataPrettyFormatUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataPrettyFormatUtils.java deleted file mode 100644 index 768ccef..0000000 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataPrettyFormatUtils.java +++ /dev/null @@ -1,243 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.hive.ql.metadata.formatting; - -import java.util.List; -import java.util.StringTokenizer; - -import org.apache.commons.lang.StringUtils; -import org.apache.hadoop.hive.metastore.api.FieldSchema; - -/** - * This class provides methods to format the output of DESCRIBE PRETTY - * in a human-readable way. - */ -public final class MetaDataPrettyFormatUtils { - - public static final int PRETTY_MAX_INTERCOL_SPACING = 4; - private static final int PRETTY_ALIGNMENT = 10; - /** - * Minimum length of the comment column. This is relevant only when the terminal width - * or hive.cli.pretty.output.num.cols is too small, or when there are very large column - * names. - * 10 was arbitrarily chosen. - */ - private static final int MIN_COMMENT_COLUMN_LEN = 10; - - private MetaDataPrettyFormatUtils() { - } - - /** - * @param prettyOutputNumCols The pretty output is formatted to fit within - * these many columns. - */ - public static String getAllColumnsInformation(List<FieldSchema> cols, - List<FieldSchema> partCols, int prettyOutputNumCols) { - StringBuilder columnInformation = new StringBuilder( - MetaDataFormatUtils.DEFAULT_STRINGBUILDER_SIZE); - int maxColNameLen = findMaxColumnNameLen(cols); - formatColumnsHeaderPretty(columnInformation, maxColNameLen, prettyOutputNumCols); - formatAllFieldsPretty(columnInformation, cols, maxColNameLen, prettyOutputNumCols); - - if ((partCols != null) && (!partCols.isEmpty())) { - columnInformation.append(MetaDataFormatUtils.LINE_DELIM) - .append("# Partition Information") - .append(MetaDataFormatUtils.LINE_DELIM); - formatColumnsHeaderPretty(columnInformation, maxColNameLen, prettyOutputNumCols); - formatAllFieldsPretty(columnInformation, partCols, maxColNameLen, prettyOutputNumCols); - } - - return columnInformation.toString(); - } - - /** - * Find the length of the largest column name. - */ - private static int findMaxColumnNameLen(List<FieldSchema> cols) { - int maxLen = -1; - for (FieldSchema col : cols) { - int colNameLen = col.getName().length(); - if (colNameLen > maxLen) { - maxLen = colNameLen; - } - } - return maxLen; - } - - /** - * @param maxColNameLen The length of the largest column name - */ - private static void formatColumnsHeaderPretty(StringBuilder columnInformation, - int maxColNameLen, int prettyOutputNumCols) { - String columnHeaders[] = MetaDataFormatUtils.getColumnsHeader(null); - formatOutputPretty(columnHeaders[0], columnHeaders[1], columnHeaders[2], - columnInformation, maxColNameLen, prettyOutputNumCols); - columnInformation.append(MetaDataFormatUtils.FIELD_DELIM) - .append(MetaDataFormatUtils.FIELD_DELIM).append(MetaDataFormatUtils.LINE_DELIM); - } - - private static void formatAllFieldsPretty(StringBuilder tableInfo, - List<FieldSchema> cols, int maxColNameLen, int prettyOutputNumCols) { - for (FieldSchema col : cols) { - formatOutputPretty(col.getName(), col.getType(), - MetaDataFormatUtils.getComment(col), tableInfo, maxColNameLen, - prettyOutputNumCols); - } - } - - /** - * If the specified comment is too long, add line breaks at appropriate - * locations. Note that the comment may already include line-breaks - * specified by the user at table creation time. - * @param columnsAlreadyConsumed The number of columns on the current line - * that have already been consumed by the column name, column type and - * and the surrounding delimiters. - * @return The comment with line breaks added at appropriate locations. - */ - private static String breakCommentIntoMultipleLines(String comment, - int columnsAlreadyConsumed, int prettyOutputNumCols) { - - if (prettyOutputNumCols == -1) { - // XXX fixed to 80 to remove jline dep - prettyOutputNumCols = 80 - 1; - } - - int commentNumCols = prettyOutputNumCols - columnsAlreadyConsumed; - if (commentNumCols < MIN_COMMENT_COLUMN_LEN) { - commentNumCols = MIN_COMMENT_COLUMN_LEN; - } - - // Track the number of columns allocated for the comment that have - // already been consumed on the current line. - int commentNumColsConsumed = 0; - - StringTokenizer st = new StringTokenizer(comment, " \t\n\r\f", true); - // We use a StringTokenizer instead of a BreakIterator, because - // table comments often contain text that looks like code. For eg: - // 'Type0' => 0, // This is Type 0 - // 'Type1' => 1, // This is Type 1 - // BreakIterator is meant for regular text, and was found to give - // bad line breaks when we tried it out. - - StringBuilder commentBuilder = new StringBuilder(comment.length()); - while (st.hasMoreTokens()) { - String currWord = st.nextToken(); - if (currWord.equals("\n") || currWord.equals("\r") || currWord.equals("\f")) { - commentBuilder.append(currWord); - commentNumColsConsumed = 0; - continue; - } - if (commentNumColsConsumed + currWord.length() > commentNumCols) { - // currWord won't fit on the current line - if (currWord.length() > commentNumCols) { - // currWord is too long to split on a line even all by itself. - // Hence we have no option but to split it. The first chunk - // will go to the end of the current line. Subsequent chunks - // will be of length commentNumCols. The last chunk - // may be smaller. - while (currWord.length() > commentNumCols) { - int remainingLineLen = commentNumCols - commentNumColsConsumed; - String wordChunk = currWord.substring(0, remainingLineLen); - commentBuilder.append(wordChunk); - commentBuilder.append(MetaDataFormatUtils.LINE_DELIM); - commentNumColsConsumed = 0; - currWord = currWord.substring(remainingLineLen); - } - // Handle the last chunk - if (currWord.length() > 0) { - commentBuilder.append(currWord); - commentNumColsConsumed = currWord.length(); - } - } else { - // Start on a new line - commentBuilder.append(MetaDataFormatUtils.LINE_DELIM); - if (!currWord.equals(" ")) { - // When starting a new line, do not start with a space. - commentBuilder.append(currWord); - commentNumColsConsumed = currWord.length(); - } else { - commentNumColsConsumed = 0; - } - } - } else { - commentBuilder.append(currWord); - commentNumColsConsumed += currWord.length(); - } - } - return commentBuilder.toString(); - } - - /** - * Appends the specified text with alignment to sb. - * Also appends an appopriately sized delimiter. - * @return The number of columns consumed by the aligned string and the - * delimiter. - */ - private static int appendFormattedColumn(StringBuilder sb, String text, - int alignment) { - String paddedText = String.format("%-" + alignment + "s", text); - int delimCount = 0; - if (paddedText.length() < alignment + PRETTY_MAX_INTERCOL_SPACING) { - delimCount = (alignment + PRETTY_MAX_INTERCOL_SPACING) - - paddedText.length(); - } else { - delimCount = PRETTY_MAX_INTERCOL_SPACING; - } - String delim = StringUtils.repeat(" ", delimCount); - sb.append(paddedText); - sb.append(delim); - sb.append(MetaDataFormatUtils.FIELD_DELIM); - - return paddedText.length() + delim.length(); - } - - private static void formatOutputPretty(String colName, String colType, - String colComment, StringBuilder tableInfo, int maxColNameLength, - int prettyOutputNumCols) { - int colsNameConsumed = appendFormattedColumn(tableInfo, colName, maxColNameLength + 1); - int colsTypeConsumed =appendFormattedColumn(tableInfo, colType, PRETTY_ALIGNMENT); - - colComment = breakCommentIntoMultipleLines(colComment, colsNameConsumed + colsTypeConsumed, - prettyOutputNumCols); - - /* Comment indent processing for multi-line comments. - * Comments should be indented the same amount on each line - * if the first line comment starts indented by k, - * the following line comments should also be indented by k - * The following line comments will as a new line,so we need to - * add colsNameConsumed spaces as the first column and - * colsTypeConsumed spaces as the second column and the - * comment as the last column.we use two FIELD_DELIM to - * split them. - */ - String[] commentSegments = colComment.split("\n|\r|\r\n"); - tableInfo.append(trimTrailingWS(commentSegments[0])); - tableInfo.append(MetaDataFormatUtils.LINE_DELIM); - for (int i = 1; i < commentSegments.length; i++) { - tableInfo.append(String.format( - "%" + colsNameConsumed + "s" + MetaDataFormatUtils.FIELD_DELIM + "%" + colsTypeConsumed - + "s" + MetaDataFormatUtils.FIELD_DELIM + "%s", "", "", commentSegments[i])); - tableInfo.append(MetaDataFormatUtils.LINE_DELIM); - } - } - - private static String trimTrailingWS(String str) { - return str.replaceAll("\\s+$", ""); - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java index 833dad6..18ce1f5 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java @@ -123,18 +123,12 @@ class TextMetaDataFormatter implements MetaDataFormatter { @Override public void describeTable(DataOutputStream outStream, String colPath, String tableName, Table tbl, Partition part, List<FieldSchema> cols, - boolean isFormatted, boolean isExt, boolean isPretty, + boolean isFormatted, boolean isExt, boolean isOutputPadded, List<ColumnStatisticsObj> colStats, PrimaryKeyInfo pkInfo, ForeignKeyInfo fkInfo, UniqueConstraint ukInfo, NotNullConstraint nnInfo) throws HiveException { try { List<FieldSchema> partCols = tbl.isPartitioned() ? tbl.getPartCols() : null; - - if (isPretty) { - String output = MetaDataPrettyFormatUtils.getAllColumnsInformation(cols, partCols, prettyOutputNumCols); - outStream.write(output.getBytes("UTF-8")); - return; - } String output = ""; boolean isColStatsAvailable = colStats != null; http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java index e70a72c..0036d18 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java @@ -591,8 +591,9 @@ public class DDLSemanticAnalyzer extends BaseSemanticAnalyzer { } } - if (colType == null) + if (colType == null) { throw new SemanticException("column type not found"); + } ColumnStatsDesc cStatsDesc = new ColumnStatsDesc(tbl.getDbName() + "." + tbl.getTableName(), Arrays.asList(colName), Arrays.asList(colType), partSpec == null); @@ -1799,7 +1800,9 @@ public class DDLSemanticAnalyzer extends BaseSemanticAnalyzer { } LinkedHashMap<String, String> newPartSpec = null; - if (partSpec != null) newPartSpec = new LinkedHashMap<String, String>(partSpec); + if (partSpec != null) { + newPartSpec = new LinkedHashMap<String, String>(partSpec); + } HashMap<String, String> mapProp = null; boolean isBlocking = false; @@ -2091,7 +2094,6 @@ public class DDLSemanticAnalyzer extends BaseSemanticAnalyzer { int descOptions = ast.getChild(1).getType(); descTblDesc.setFormatted(descOptions == HiveParser.KW_FORMATTED); descTblDesc.setExt(descOptions == HiveParser.KW_EXTENDED); - descTblDesc.setPretty(descOptions == HiveParser.KW_PRETTY); // in case of "DESCRIBE FORMATTED tablename column_name" statement, colPath // will contain tablename.column_name. If column_name is not specified // colPath will be equal to tableName. This is how we can differentiate @@ -2897,7 +2899,10 @@ public class DDLSemanticAnalyzer extends BaseSemanticAnalyzer { } Map<Integer, List<ExprNodeGenericFuncDesc>> partSpecs = getFullPartitionSpecs(ast, tab, canGroupExprs); - if (partSpecs.isEmpty()) return; // nothing to do + if (partSpecs.isEmpty()) + { + return; // nothing to do + } validateAlterTableType(tab, AlterTableTypes.DROPPARTITION, expectView); ReadEntity re = new ReadEntity(tab); @@ -3232,7 +3237,9 @@ public class DDLSemanticAnalyzer extends BaseSemanticAnalyzer { new HashMap<Integer, List<ExprNodeGenericFuncDesc>>(); for (int childIndex = 0; childIndex < ast.getChildCount(); childIndex++) { Tree partSpecTree = ast.getChild(childIndex); - if (partSpecTree.getType() != HiveParser.TOK_PARTSPEC) continue; + if (partSpecTree.getType() != HiveParser.TOK_PARTSPEC) { + continue; + } ExprNodeGenericFuncDesc expr = null; HashSet<String> names = new HashSet<String>(partSpecTree.getChildCount()); for (int i = 0; i < partSpecTree.getChildCount(); ++i) { @@ -3284,7 +3291,9 @@ public class DDLSemanticAnalyzer extends BaseSemanticAnalyzer { expr = (expr == null) ? op : makeBinaryPredicate("and", expr, op); names.add(key); } - if (expr == null) continue; + if (expr == null) { + continue; + } // We got the expr for one full partition spec. Determine the prefix length. int prefixLength = calculatePartPrefix(tab, names); List<ExprNodeGenericFuncDesc> orExpr = result.get(prefixLength); @@ -3323,7 +3332,9 @@ public class DDLSemanticAnalyzer extends BaseSemanticAnalyzer { private int calculatePartPrefix(Table tbl, HashSet<String> partSpecKeys) { int partPrefixToDrop = 0; for (FieldSchema fs : tbl.getPartCols()) { - if (!partSpecKeys.contains(fs.getName())) break; + if (!partSpecKeys.contains(fs.getName())) { + break; + } ++partPrefixToDrop; } return partPrefixToDrop; http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g index 0f1f6f6..6ffca02 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g @@ -188,7 +188,6 @@ KW_JAR: 'JAR'; KW_EXPLAIN: 'EXPLAIN'; KW_EXTENDED: 'EXTENDED'; KW_FORMATTED: 'FORMATTED'; -KW_PRETTY: 'PRETTY'; KW_DEPENDENCY: 'DEPENDENCY'; KW_LOGICAL: 'LOGICAL'; KW_SERDE: 'SERDE'; http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g index e8fa9f2..2cb6946 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g @@ -1528,7 +1528,7 @@ descStatement | (KW_FUNCTION) => KW_FUNCTION KW_EXTENDED? (name=descFuncNames) -> ^(TOK_DESCFUNCTION $name KW_EXTENDED?) | - (KW_FORMATTED|KW_EXTENDED|KW_PRETTY) => ((descOptions=KW_FORMATTED|descOptions=KW_EXTENDED|descOptions=KW_PRETTY) parttype=tabPartColTypeExpr) -> ^(TOK_DESCTABLE $parttype $descOptions) + (KW_FORMATTED|KW_EXTENDED) => ((descOptions=KW_FORMATTED|descOptions=KW_EXTENDED) parttype=tabPartColTypeExpr) -> ^(TOK_DESCTABLE $parttype $descOptions) | parttype=tabPartColTypeExpr -> ^(TOK_DESCTABLE $parttype) ) http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g b/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g index cd21de2..0591fbf 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g @@ -789,7 +789,7 @@ nonReserved | KW_INDEX | KW_INDEXES | KW_INPATH | KW_INPUTDRIVER | KW_INPUTFORMAT | KW_ITEMS | KW_JAR | KW_KILL | KW_KEYS | KW_KEY_TYPE | KW_LAST | KW_LIMIT | KW_OFFSET | KW_LINES | KW_LOAD | KW_LOCATION | KW_LOCK | KW_LOCKS | KW_LOGICAL | KW_LONG | KW_MAPJOIN | KW_MATERIALIZED | KW_METADATA | KW_MINUTE | KW_MONTH | KW_MSCK | KW_NOSCAN | KW_NO_DROP | KW_NULLS | KW_OFFLINE - | KW_OPTION | KW_OUTPUTDRIVER | KW_OUTPUTFORMAT | KW_OVERWRITE | KW_OWNER | KW_PARTITIONED | KW_PARTITIONS | KW_PLUS | KW_PRETTY + | KW_OPTION | KW_OUTPUTDRIVER | KW_OUTPUTFORMAT | KW_OVERWRITE | KW_OWNER | KW_PARTITIONED | KW_PARTITIONS | KW_PLUS | KW_PRINCIPALS | KW_PROTECTION | KW_PURGE | KW_QUERY | KW_QUARTER | KW_READ | KW_READONLY | KW_REBUILD | KW_RECORDREADER | KW_RECORDWRITER | KW_RELOAD | KW_RENAME | KW_REPAIR | KW_REPLACE | KW_REPLICATION | KW_RESTRICT | KW_REWRITE | KW_ROLE | KW_ROLES | KW_SCHEMA | KW_SCHEMAS | KW_SECOND | KW_SEMI | KW_SERDE | KW_SERDEPROPERTIES | KW_SERVER | KW_SETS | KW_SHARED http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/java/org/apache/hadoop/hive/ql/plan/DescTableDesc.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/DescTableDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/DescTableDesc.java index 88c9921..302926e 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/plan/DescTableDesc.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/DescTableDesc.java @@ -45,11 +45,6 @@ public class DescTableDesc extends DDLDesc implements Serializable { boolean isExt; boolean isFormatted; - /** Show pretty output? This has more human-readable formatting than - * isFormatted mode. - */ - private boolean isPretty; - /** * table name for the result of describe table. */ @@ -74,7 +69,6 @@ public class DescTableDesc extends DDLDesc implements Serializable { Map<String, String> partSpec, String colPath) { this.isExt = false; this.isFormatted = false; - this.isPretty = false; this.partSpec = partSpec; this.resFile = resFile.toString(); this.tableName = tableName; @@ -122,14 +116,6 @@ public class DescTableDesc extends DDLDesc implements Serializable { this.isFormatted = isFormat; } - public boolean isPretty() { - return this.isPretty; - } - - public void setPretty(boolean isPretty) { - this.isPretty = isPretty; - } - /** * @return the tableName */ http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/test/queries/clientpositive/describe_pretty.q ---------------------------------------------------------------------- diff --git a/ql/src/test/queries/clientpositive/describe_pretty.q b/ql/src/test/queries/clientpositive/describe_pretty.q deleted file mode 100644 index 89db075..0000000 --- a/ql/src/test/queries/clientpositive/describe_pretty.q +++ /dev/null @@ -1,80 +0,0 @@ --- test comment indent processing for multi-line comments - -CREATE TABLE test_table( - col1 INT COMMENT 'col1 one line comment', - col2 STRING COMMENT 'col2 -two lines comment', - col3 STRING COMMENT 'col3 -three lines -comment', - col4 STRING COMMENT 'col4 very long comment that is greater than 80 chars and is likely to spill into multiple lines', - col5 STRING COMMENT 'col5 very long multi-line comment where each line is very long by itself and is likely to spill -into multiple lines. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin in dolor nisl, sodales -adipiscing tortor. Integer venenatis', - col6 STRING COMMENT 'This comment has a very long single word ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvzxyz123 which will not fit in a line by itself for small column widths.', - col7_NoComment STRING) -COMMENT 'table comment -two lines'; - -SET hive.cli.pretty.output.num.cols=80; - --- There will be an extra tab at the end of each comment line in the output. --- This is because DESCRIBE <table_name> command separates the column, type and --- comment field using a \t. DESCRIBE PRETTY <table_name> uses spaces instead --- of \t to separate columns. Hive gets confused when it parses the string --- table description constructed in MetaDataPrettyFormatUtils, and adds a tab --- at the end of each line. --- There are three ways to address this: --- 1. Pad each row to the full terminal width with extra spaces. --- 2. Assume a maximum tab width of 8, and subtract 2 * 8 spaces from the --- available line width. This approach wastes upto 2 * 8 - 2 columns. --- 3. Since the pretty output is meant only for human consumption, do nothing. --- Just add a comment to the unit test file explaining what is happening. --- This is the approach chosen. - -DESCRIBE PRETTY test_table; - -SET hive.cli.pretty.output.num.cols=200; -DESCRIBE PRETTY test_table; - -SET hive.cli.pretty.output.num.cols=50; -DESCRIBE PRETTY test_table; - -SET hive.cli.pretty.output.num.cols=60; -DESCRIBE PRETTY test_table; - -CREATE TABLE test_table_very_long_column_name( - col1 INT COMMENT 'col1 one line comment', - col2_abcdefghiklmnopqrstuvxyz STRING COMMENT 'col2 -two lines comment', - col3 STRING COMMENT 'col3 -three lines -comment', - col4 STRING COMMENT 'col4 very long comment that is greater than 80 chars and is likely to spill into multiple lines') -; - -SET hive.cli.pretty.output.num.cols=80; -DESCRIBE PRETTY test_table_very_long_column_name; - -SET hive.cli.pretty.output.num.cols=20; -DESCRIBE PRETTY test_table_very_long_column_name; - -CREATE TABLE test_table_partitioned( - col1 INT COMMENT 'col1 one line comment', - col2 STRING COMMENT 'col2 -two lines comment', - col3 STRING COMMENT 'col3 -three lines -comment', - col4 STRING COMMENT 'col4 very long comment that is greater than 80 chars and is likely to spill into multiple lines', - col5 STRING COMMENT 'col5 very long multi-line comment where each line is very long by itself and is likely to spill -into multiple lines. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin in dolor nisl, sodales -adipiscing tortor. Integer venenatis', - col6 STRING COMMENT 'This comment has a very long single word ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvzxyz123 which will not fit in a line by itself for small column widths.', - col7_NoComment STRING) -COMMENT 'table comment -two lines' -PARTITIONED BY (ds STRING); - -SET hive.cli.pretty.output.num.cols=60; -DESCRIBE PRETTY test_table_partitioned; http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/test/queries/clientpositive/escape_comments.q ---------------------------------------------------------------------- diff --git a/ql/src/test/queries/clientpositive/escape_comments.q b/ql/src/test/queries/clientpositive/escape_comments.q index 8c38690..bcfac3d 100644 --- a/ql/src/test/queries/clientpositive/escape_comments.q +++ b/ql/src/test/queries/clientpositive/escape_comments.q @@ -11,7 +11,6 @@ describe database extended escape_comments_db; describe database escape_comments_db; show create table escape_comments_tbl1; describe formatted escape_comments_tbl1; -describe pretty escape_comments_tbl1; describe escape_comments_tbl1; show create table escape_comments_view1; describe formatted escape_comments_view1; http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/test/results/clientpositive/beeline/escape_comments.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientpositive/beeline/escape_comments.q.out b/ql/src/test/results/clientpositive/beeline/escape_comments.q.out index 9e17935..1b81d7c 100644 --- a/ql/src/test/results/clientpositive/beeline/escape_comments.q.out +++ b/ql/src/test/results/clientpositive/beeline/escape_comments.q.out @@ -118,24 +118,6 @@ Bucket Columns: [] NULL Sort Columns: [] NULL Storage Desc Params: NULL NULL serialization.format 1 -PREHOOK: query: describe pretty escape_comments_tbl1 -PREHOOK: type: DESCTABLE -PREHOOK: Input: escape_comments_db@escape_comments_tbl1 -POSTHOOK: query: describe pretty escape_comments_tbl1 -POSTHOOK: type: DESCTABLE -POSTHOOK: Input: escape_comments_db@escape_comments_tbl1 -col_name data_type comment - -col1 string a - b'; -p1 string a - b - NULL NULL -# Partition Information NULL NULL -col_name data_type comment - -p1 string a - b PREHOOK: query: describe escape_comments_tbl1 PREHOOK: type: DESCTABLE PREHOOK: Input: escape_comments_db@escape_comments_tbl1 http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/test/results/clientpositive/describe_pretty.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientpositive/describe_pretty.q.out b/ql/src/test/results/clientpositive/describe_pretty.q.out deleted file mode 100644 index aa90a67..0000000 --- a/ql/src/test/results/clientpositive/describe_pretty.q.out +++ /dev/null @@ -1,323 +0,0 @@ -PREHOOK: query: CREATE TABLE test_table( - col1 INT COMMENT 'col1 one line comment', - col2 STRING COMMENT 'col2 -two lines comment', - col3 STRING COMMENT 'col3 -three lines -comment', - col4 STRING COMMENT 'col4 very long comment that is greater than 80 chars and is likely to spill into multiple lines', - col5 STRING COMMENT 'col5 very long multi-line comment where each line is very long by itself and is likely to spill -into multiple lines. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin in dolor nisl, sodales -adipiscing tortor. Integer venenatis', - col6 STRING COMMENT 'This comment has a very long single word ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvzxyz123 which will not fit in a line by itself for small column widths.', - col7_NoComment STRING) -COMMENT 'table comment -two lines' -PREHOOK: type: CREATETABLE -PREHOOK: Output: database:default -PREHOOK: Output: default@test_table -POSTHOOK: query: CREATE TABLE test_table( - col1 INT COMMENT 'col1 one line comment', - col2 STRING COMMENT 'col2 -two lines comment', - col3 STRING COMMENT 'col3 -three lines -comment', - col4 STRING COMMENT 'col4 very long comment that is greater than 80 chars and is likely to spill into multiple lines', - col5 STRING COMMENT 'col5 very long multi-line comment where each line is very long by itself and is likely to spill -into multiple lines. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin in dolor nisl, sodales -adipiscing tortor. Integer venenatis', - col6 STRING COMMENT 'This comment has a very long single word ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvzxyz123 which will not fit in a line by itself for small column widths.', - col7_NoComment STRING) -COMMENT 'table comment -two lines' -POSTHOOK: type: CREATETABLE -POSTHOOK: Output: database:default -POSTHOOK: Output: default@test_table -PREHOOK: query: DESCRIBE PRETTY test_table -PREHOOK: type: DESCTABLE -PREHOOK: Input: default@test_table -POSTHOOK: query: DESCRIBE PRETTY test_table -POSTHOOK: type: DESCTABLE -POSTHOOK: Input: default@test_table -col_name data_type comment - -col1 int col1 one line comment -col2 string col2 - two lines comment -col3 string col3 - three lines - comment -col4 string col4 very long comment that is greater than 80 - chars and is likely to spill into multiple - lines -col5 string col5 very long multi-line comment where each - line is very long by itself and is likely to - spill - into multiple lines. Lorem ipsum dolor sit - amet, consectetur adipiscing elit. Proin in - dolor nisl, sodales - adipiscing tortor. Integer venenatis -col6 string This comment has a very long single word ABCDEF - GHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvzxyz12 - 3 which will not fit in a line by itself for - small column widths. -col7_nocomment string -PREHOOK: query: DESCRIBE PRETTY test_table -PREHOOK: type: DESCTABLE -PREHOOK: Input: default@test_table -POSTHOOK: query: DESCRIBE PRETTY test_table -POSTHOOK: type: DESCTABLE -POSTHOOK: Input: default@test_table -col_name data_type comment - -col1 int col1 one line comment -col2 string col2 - two lines comment -col3 string col3 - three lines - comment -col4 string col4 very long comment that is greater than 80 chars and is likely to spill into multiple lines -col5 string col5 very long multi-line comment where each line is very long by itself and is likely to spill - into multiple lines. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin in dolor nisl, sodales - adipiscing tortor. Integer venenatis -col6 string This comment has a very long single word ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvzxyz123 which will not fit in a line by itself for small column widths. -col7_nocomment string -PREHOOK: query: DESCRIBE PRETTY test_table -PREHOOK: type: DESCTABLE -PREHOOK: Input: default@test_table -POSTHOOK: query: DESCRIBE PRETTY test_table -POSTHOOK: type: DESCTABLE -POSTHOOK: Input: default@test_table -col_name data_type comment - -col1 int col1 one line - comment -col2 string col2 - two lines comment -col3 string col3 - three lines - comment -col4 string col4 very long - comment that is - greater than 80 - chars and is - likely to spill - into multiple - lines -col5 string col5 very long - multi-line - comment where - each line is very - long by itself - and is likely to - spill - into multiple - lines. Lorem - ipsum dolor sit - amet, consectetur - adipiscing elit. - Proin in dolor - nisl, sodales - adipiscing - tortor. Integer - venenatis -col6 string This comment has - a very long - single word ABCDE - FGHIJKLMNOPQRSTUV - XYZabcdefghijklmn - opqrstuvzxyz123 - which will not - fit in a line by - itself for small - column widths. -col7_nocomment string -PREHOOK: query: DESCRIBE PRETTY test_table -PREHOOK: type: DESCTABLE -PREHOOK: Input: default@test_table -POSTHOOK: query: DESCRIBE PRETTY test_table -POSTHOOK: type: DESCTABLE -POSTHOOK: Input: default@test_table -col_name data_type comment - -col1 int col1 one line comment -col2 string col2 - two lines comment -col3 string col3 - three lines - comment -col4 string col4 very long comment that - is greater than 80 chars - and is likely to spill into - multiple lines -col5 string col5 very long multi-line - comment where each line is - very long by itself and is - likely to spill - into multiple lines. Lorem - ipsum dolor sit amet, - consectetur adipiscing - elit. Proin in dolor nisl, - sodales - adipiscing tortor. Integer - venenatis -col6 string This comment has a very - long single word ABCDEFGHIJ - KLMNOPQRSTUVXYZabcdefghijkl - mnopqrstuvzxyz123 which - will not fit in a line by - itself for small column - widths. -col7_nocomment string -PREHOOK: query: CREATE TABLE test_table_very_long_column_name( - col1 INT COMMENT 'col1 one line comment', - col2_abcdefghiklmnopqrstuvxyz STRING COMMENT 'col2 -two lines comment', - col3 STRING COMMENT 'col3 -three lines -comment', - col4 STRING COMMENT 'col4 very long comment that is greater than 80 chars and is likely to spill into multiple lines') -PREHOOK: type: CREATETABLE -PREHOOK: Output: database:default -PREHOOK: Output: default@test_table_very_long_column_name -POSTHOOK: query: CREATE TABLE test_table_very_long_column_name( - col1 INT COMMENT 'col1 one line comment', - col2_abcdefghiklmnopqrstuvxyz STRING COMMENT 'col2 -two lines comment', - col3 STRING COMMENT 'col3 -three lines -comment', - col4 STRING COMMENT 'col4 very long comment that is greater than 80 chars and is likely to spill into multiple lines') -POSTHOOK: type: CREATETABLE -POSTHOOK: Output: database:default -POSTHOOK: Output: default@test_table_very_long_column_name -PREHOOK: query: DESCRIBE PRETTY test_table_very_long_column_name -PREHOOK: type: DESCTABLE -PREHOOK: Input: default@test_table_very_long_column_name -POSTHOOK: query: DESCRIBE PRETTY test_table_very_long_column_name -POSTHOOK: type: DESCTABLE -POSTHOOK: Input: default@test_table_very_long_column_name -col_name data_type comment - -col1 int col1 one line comment -col2_abcdefghiklmnopqrstuvxyz string col2 - two lines comment -col3 string col3 - three lines - comment -col4 string col4 very long comment that is - greater than 80 chars and is - likely to spill into multiple - lines -PREHOOK: query: DESCRIBE PRETTY test_table_very_long_column_name -PREHOOK: type: DESCTABLE -PREHOOK: Input: default@test_table_very_long_column_name -POSTHOOK: query: DESCRIBE PRETTY test_table_very_long_column_name -POSTHOOK: type: DESCTABLE -POSTHOOK: Input: default@test_table_very_long_column_name -col_name data_type comment - -col1 int col1 one - line - comment -col2_abcdefghiklmnopqrstuvxyz string col2 - two lines - comment -col3 string col3 - three - lines - comment -col4 string col4 very - long - comment - that is - greater - than 80 - chars and - is likely - to spill - into - multiple - lines -PREHOOK: query: CREATE TABLE test_table_partitioned( - col1 INT COMMENT 'col1 one line comment', - col2 STRING COMMENT 'col2 -two lines comment', - col3 STRING COMMENT 'col3 -three lines -comment', - col4 STRING COMMENT 'col4 very long comment that is greater than 80 chars and is likely to spill into multiple lines', - col5 STRING COMMENT 'col5 very long multi-line comment where each line is very long by itself and is likely to spill -into multiple lines. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin in dolor nisl, sodales -adipiscing tortor. Integer venenatis', - col6 STRING COMMENT 'This comment has a very long single word ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvzxyz123 which will not fit in a line by itself for small column widths.', - col7_NoComment STRING) -COMMENT 'table comment -two lines' -PARTITIONED BY (ds STRING) -PREHOOK: type: CREATETABLE -PREHOOK: Output: database:default -PREHOOK: Output: default@test_table_partitioned -POSTHOOK: query: CREATE TABLE test_table_partitioned( - col1 INT COMMENT 'col1 one line comment', - col2 STRING COMMENT 'col2 -two lines comment', - col3 STRING COMMENT 'col3 -three lines -comment', - col4 STRING COMMENT 'col4 very long comment that is greater than 80 chars and is likely to spill into multiple lines', - col5 STRING COMMENT 'col5 very long multi-line comment where each line is very long by itself and is likely to spill -into multiple lines. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin in dolor nisl, sodales -adipiscing tortor. Integer venenatis', - col6 STRING COMMENT 'This comment has a very long single word ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvzxyz123 which will not fit in a line by itself for small column widths.', - col7_NoComment STRING) -COMMENT 'table comment -two lines' -PARTITIONED BY (ds STRING) -POSTHOOK: type: CREATETABLE -POSTHOOK: Output: database:default -POSTHOOK: Output: default@test_table_partitioned -PREHOOK: query: DESCRIBE PRETTY test_table_partitioned -PREHOOK: type: DESCTABLE -PREHOOK: Input: default@test_table_partitioned -POSTHOOK: query: DESCRIBE PRETTY test_table_partitioned -POSTHOOK: type: DESCTABLE -POSTHOOK: Input: default@test_table_partitioned -col_name data_type comment - -col1 int col1 one line comment -col2 string col2 - two lines comment -col3 string col3 - three lines - comment -col4 string col4 very long comment that - is greater than 80 chars - and is likely to spill into - multiple lines -col5 string col5 very long multi-line - comment where each line is - very long by itself and is - likely to spill - into multiple lines. Lorem - ipsum dolor sit amet, - consectetur adipiscing - elit. Proin in dolor nisl, - sodales - adipiscing tortor. Integer - venenatis -col6 string This comment has a very - long single word ABCDEFGHIJ - KLMNOPQRSTUVXYZabcdefghijkl - mnopqrstuvzxyz123 which - will not fit in a line by - itself for small column - widths. -col7_nocomment string -ds string - -# Partition Information -col_name data_type comment - -ds string http://git-wip-us.apache.org/repos/asf/hive/blob/2a5e72c2/ql/src/test/results/clientpositive/escape_comments.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientpositive/escape_comments.q.out b/ql/src/test/results/clientpositive/escape_comments.q.out index ecd6331..6c86e81 100644 --- a/ql/src/test/results/clientpositive/escape_comments.q.out +++ b/ql/src/test/results/clientpositive/escape_comments.q.out @@ -120,24 +120,6 @@ Bucket Columns: [] Sort Columns: [] Storage Desc Params: serialization.format 1 -PREHOOK: query: describe pretty escape_comments_tbl1 -PREHOOK: type: DESCTABLE -PREHOOK: Input: escape_comments_db@escape_comments_tbl1 -POSTHOOK: query: describe pretty escape_comments_tbl1 -POSTHOOK: type: DESCTABLE -POSTHOOK: Input: escape_comments_db@escape_comments_tbl1 -col_name data_type comment - -col1 string a - b'; -p1 string a - b - -# Partition Information -col_name data_type comment - -p1 string a - b PREHOOK: query: describe escape_comments_tbl1 PREHOOK: type: DESCTABLE PREHOOK: Input: escape_comments_db@escape_comments_tbl1