diff --git common/src/java/org/apache/hadoop/hive/conf/HiveConf.java common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index 0c783e144d..0894b053c3 100644 --- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -3140,6 +3140,9 @@ private static void populateLlapDaemonVarsSet(Set llapDaemonVarsSetLocal "partition columns or non-partition columns while displaying columns in describe\n" + "table. From 0.12 onwards, they are displayed separately. This flag will let you\n" + "get old behavior, if desired. See, test-case in patch for HIVE-6689."), + HIVE_DISPLAY_PARTITIONED_TABLE_STATS("hive.display.partitioned.table.stats", true, + "A flag that determines whether 'DESCRIBE [EXTENDED|FORMATTED]' operation display\n" + + "partitioned table stats or not. See Hive-21485 for details."), HIVE_SSL_PROTOCOL_BLACKLIST("hive.ssl.protocol.blacklist", "SSLv2,SSLv3", "SSL Versions to disable for all Hive Servers"), diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/table/DescTableOperation.java ql/src/java/org/apache/hadoop/hive/ql/ddl/table/DescTableOperation.java index 1d94ff3a5b..bcae13cb42 100644 --- ql/src/java/org/apache/hadoop/hive/ql/ddl/table/DescTableOperation.java +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/table/DescTableOperation.java @@ -114,6 +114,7 @@ public int execute() throws Exception { } } + boolean displayPartitionedTblStats = context.getConf().getBoolVar(HiveConf.ConfVars.HIVE_DISPLAY_PARTITIONED_TABLE_STATS); if (colPath.equals(tableName)) { cols = (part == null || tbl.getTableType() == TableType.VIRTUAL_VIEW) ? tbl.getCols() : part.getCols(); @@ -122,7 +123,7 @@ public int execute() throws Exception { cols.addAll(tbl.getPartCols()); } - if (tbl.isPartitioned() && part == null) { + if (tbl.isPartitioned() && part == null && displayPartitionedTblStats) { // No partitioned specified for partitioned table, lets fetch all. Map tblProps = tbl.getParameters() == null ? new HashMap() : tbl.getParameters(); @@ -162,7 +163,7 @@ public int execute() throws Exception { List colNames = new ArrayList(); colNames.add(colName.toLowerCase()); if (null == part) { - if (tbl.isPartitioned()) { + if (tbl.isPartitioned() && displayPartitionedTblStats) { Map tblProps = tbl.getParameters() == null ? new HashMap() : tbl.getParameters(); if (tbl.isPartitionKey(colNames.get(0))) { diff --git ql/src/test/queries/clientpositive/describe_table.q ql/src/test/queries/clientpositive/describe_table.q index 69fec9281d..0c2c62bb44 100644 --- ql/src/test/queries/clientpositive/describe_table.q +++ ql/src/test/queries/clientpositive/describe_table.q @@ -27,6 +27,10 @@ describe formatted `srcpart` PARTITION(ds='2008-04-08', hr='12'); describe formatted `srcpart` `ds`; describe formatted `srcpart` `hr`; +set hive.display.partitioned.table.stats=false; +describe formatted `srcpart`; +set hive.display.partitioned.table.stats=true; + create table srcpart_serdeprops like srcpart; alter table srcpart_serdeprops set serdeproperties('xyz'='0'); alter table srcpart_serdeprops set serdeproperties('pqrs'='1'); diff --git ql/src/test/results/clientpositive/describe_table.q.out ql/src/test/results/clientpositive/describe_table.q.out index 8c7a16c4b6..8fdb21d431 100644 --- ql/src/test/results/clientpositive/describe_table.q.out +++ ql/src/test/results/clientpositive/describe_table.q.out @@ -388,6 +388,41 @@ num_falses bitVector comment COLUMN_STATS_ACCURATE {\"COLUMN_STATS\":{\"hr\":\"true\"}} +PREHOOK: query: describe formatted `srcpart` +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@srcpart +POSTHOOK: query: describe formatted `srcpart` +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@srcpart +# col_name data_type comment +key string default +value string default + +# Partition Information +# col_name data_type comment +ds string +hr string + +# Detailed Table Information +Database: default +#### A masked pattern was here #### +Retention: 0 +#### A masked pattern was here #### +Table Type: MANAGED_TABLE +Table Parameters: + bucketing_version 2 +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe +InputFormat: org.apache.hadoop.mapred.TextInputFormat +OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 PREHOOK: query: create table srcpart_serdeprops like srcpart PREHOOK: type: CREATETABLE PREHOOK: Output: database:default