You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2014/03/21 16:48:09 UTC

svn commit: r1579962 - in /hive/branches/branch-0.13: common/src/java/org/apache/hadoop/hive/conf/ conf/ ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/ ql/src/test/queries/clientpositive/ ql/src/test/results/clientpositive/

Author: hashutosh
Date: Fri Mar 21 15:48:09 2014
New Revision: 1579962

URL: http://svn.apache.org/r1579962
Log:
HIVE-6689 : Provide an option to not display partition columns separately in describe table output (Ashutosh Chauhan via Jason Dere)

Added:
    hive/branches/branch-0.13/ql/src/test/queries/clientpositive/desc_tbl_part_cols.q
    hive/branches/branch-0.13/ql/src/test/results/clientpositive/desc_tbl_part_cols.q.out
Modified:
    hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
    hive/branches/branch-0.13/conf/hive-default.xml.template
    hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataFormatUtils.java
    hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java

Modified: hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java?rev=1579962&r1=1579961&r2=1579962&view=diff
==============================================================================
--- hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (original)
+++ hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java Fri Mar 21 15:48:09 2014
@@ -836,7 +836,7 @@ public class HiveConf extends Configurat
     HIVE_DRIVER_RUN_HOOKS("hive.exec.driver.run.hooks", ""),
     HIVE_DDL_OUTPUT_FORMAT("hive.ddl.output.format", null),
     HIVE_ENTITY_SEPARATOR("hive.entity.separator", "@"),
-
+    HIVE_DISPLAY_PARTITION_COLUMNS_SEPARATELY("hive.display.partition.cols.separately",true),
     HIVE_SERVER2_MAX_START_ATTEMPTS("hive.server2.max.start.attempts", 30L,
         new LongRangeValidator(0L, Long.MAX_VALUE)),
 

Modified: hive/branches/branch-0.13/conf/hive-default.xml.template
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/conf/hive-default.xml.template?rev=1579962&r1=1579961&r2=1579962&view=diff
==============================================================================
--- hive/branches/branch-0.13/conf/hive-default.xml.template (original)
+++ hive/branches/branch-0.13/conf/hive-default.xml.template Fri Mar 21 15:48:09 2014
@@ -1876,6 +1876,17 @@
 </property>
 
 <property>
+  <name>hive.display.partition.cols.separately</name>
+  <value>true</value>
+  <description>
+    In older Hive version (0.10 and earlier) no distinction was made between
+    partition columns or non-partition columns while displaying columns in describe
+    table. From 0.12 onwards, they are displayed separately. This flag will let you
+    get old behavior, if desired. See, test-case in patch for HIVE-6689.
+  </description>
+</property>
+
+<property>
   <name>hive.transform.escape.input</name>
   <value>false</value>
   <description>

Modified: hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataFormatUtils.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataFormatUtils.java?rev=1579962&r1=1579961&r2=1579962&view=diff
==============================================================================
--- hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataFormatUtils.java (original)
+++ hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataFormatUtils.java Fri Mar 21 15:48:09 2014
@@ -29,6 +29,7 @@ import java.util.Set;
 
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hadoop.hive.metastore.TableType;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.Index;
@@ -92,14 +93,14 @@ public final class MetaDataFormatUtils {
    * @return string with formatted column information
    */
   public static String getAllColumnsInformation(List<FieldSchema> cols,
-      List<FieldSchema> partCols, boolean printHeader, boolean isOutputPadded) {
+      List<FieldSchema> partCols, boolean printHeader, boolean isOutputPadded, boolean showPartColsSep) {
     StringBuilder columnInformation = new StringBuilder(DEFAULT_STRINGBUILDER_SIZE);
     if(printHeader){
       formatColumnsHeader(columnInformation);
     }
     formatAllFields(columnInformation, cols, isOutputPadded);
 
-    if ((partCols != null) && (!partCols.isEmpty())) {
+    if ((partCols != null) && !partCols.isEmpty() && showPartColsSep) {
       columnInformation.append(LINE_DELIM).append("# Partition Information")
       .append(LINE_DELIM);
       formatColumnsHeader(columnInformation);
@@ -371,7 +372,7 @@ public final class MetaDataFormatUtils {
     if ("json".equals(conf.get(HiveConf.ConfVars.HIVE_DDL_OUTPUT_FORMAT.varname, "text"))) {
       return new JsonMetaDataFormatter();
     } else {
-      return new TextMetaDataFormatter(conf.getIntVar(HiveConf.ConfVars.CLIPRETTYOUTPUTNUMCOLS));
+      return new TextMetaDataFormatter(conf.getIntVar(HiveConf.ConfVars.CLIPRETTYOUTPUTNUMCOLS), conf.getBoolVar(ConfVars.HIVE_DISPLAY_PARTITION_COLUMNS_SEPARATELY));
     }
   }
 }

Modified: hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java?rev=1579962&r1=1579961&r2=1579962&view=diff
==============================================================================
--- hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java (original)
+++ hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java Fri Mar 21 15:48:09 2014
@@ -57,9 +57,11 @@ class TextMetaDataFormatter implements M
    * If -1, then the current terminal width is auto-detected and used.
    */
   private final int prettyOutputNumCols;
+  private final boolean showPartColsSeparately;
 
-  public TextMetaDataFormatter(int prettyOutputNumCols) {
+  public TextMetaDataFormatter(int prettyOutputNumCols, boolean partColsSeparately) {
     this.prettyOutputNumCols = prettyOutputNumCols;
+    this.showPartColsSeparately = partColsSeparately;
   }
 
   /**
@@ -123,7 +125,7 @@ class TextMetaDataFormatter implements M
             MetaDataPrettyFormatUtils.getAllColumnsInformation(
                 cols, partCols, prettyOutputNumCols)
                 :
-                  MetaDataFormatUtils.getAllColumnsInformation(cols, partCols, isFormatted, isOutputPadded);
+                  MetaDataFormatUtils.getAllColumnsInformation(cols, partCols, isFormatted, isOutputPadded, showPartColsSeparately);
       } else {
         output = MetaDataFormatUtils.getAllColumnsInformation(cols, isFormatted, isOutputPadded);
       }

Added: hive/branches/branch-0.13/ql/src/test/queries/clientpositive/desc_tbl_part_cols.q
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/ql/src/test/queries/clientpositive/desc_tbl_part_cols.q?rev=1579962&view=auto
==============================================================================
--- hive/branches/branch-0.13/ql/src/test/queries/clientpositive/desc_tbl_part_cols.q (added)
+++ hive/branches/branch-0.13/ql/src/test/queries/clientpositive/desc_tbl_part_cols.q Fri Mar 21 15:48:09 2014
@@ -0,0 +1,7 @@
+create table t1 (a int, b string) partitioned by (c int, d string);
+describe t1;
+
+set hive.display.partition.cols.separately=false;
+describe t1;
+
+set hive.display.partition.cols.separately=true;

Added: hive/branches/branch-0.13/ql/src/test/results/clientpositive/desc_tbl_part_cols.q.out
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/ql/src/test/results/clientpositive/desc_tbl_part_cols.q.out?rev=1579962&view=auto
==============================================================================
--- hive/branches/branch-0.13/ql/src/test/results/clientpositive/desc_tbl_part_cols.q.out (added)
+++ hive/branches/branch-0.13/ql/src/test/results/clientpositive/desc_tbl_part_cols.q.out Fri Mar 21 15:48:09 2014
@@ -0,0 +1,29 @@
+PREHOOK: query: create table t1 (a int, b string) partitioned by (c int, d string)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+POSTHOOK: query: create table t1 (a int, b string) partitioned by (c int, d string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@t1
+PREHOOK: query: describe t1
+PREHOOK: type: DESCTABLE
+POSTHOOK: query: describe t1
+POSTHOOK: type: DESCTABLE
+a                   	int                 	                    
+b                   	string              	                    
+c                   	int                 	                    
+d                   	string              	                    
+	 	 
+# Partition Information	 	 
+# col_name            	data_type           	comment             
+	 	 
+c                   	int                 	                    
+d                   	string              	                    
+PREHOOK: query: describe t1
+PREHOOK: type: DESCTABLE
+POSTHOOK: query: describe t1
+POSTHOOK: type: DESCTABLE
+a                   	int                 	                    
+b                   	string              	                    
+c                   	int                 	                    
+d                   	string