You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by vg...@apache.org on 2020/02/28 19:49:15 UTC
[hive] branch master updated: HIVE-22453: Describe table
unnecessarily fetches partitions (Toshihiko Uchida, reviewed by Vineet Garg)
This is an automated email from the ASF dual-hosted git repository.
vgarg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 4488735 HIVE-22453: Describe table unnecessarily fetches partitions (Toshihiko Uchida, reviewed by Vineet Garg)
4488735 is described below
commit 44887354c7819beca4b9e51306b985a9ae2a956f
Author: Vineet Garg <vg...@apache.org>
AuthorDate: Fri Feb 28 11:47:06 2020 -0800
HIVE-22453: Describe table unnecessarily fetches partitions (Toshihiko Uchida, reviewed by Vineet Garg)
---
.../ql/ddl/table/info/desc/DescTableOperation.java | 57 ++++++++++++----------
1 file changed, 30 insertions(+), 27 deletions(-)
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/desc/DescTableOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/desc/DescTableOperation.java
index 91a9c69..f428cf3 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/desc/DescTableOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/desc/DescTableOperation.java
@@ -153,39 +153,42 @@ public class DescTableOperation extends DDLOperation<DescTableDesc> {
cols.addAll(table.getPartCols());
}
- if (table.isPartitioned() && partition == null) {
- // No partition specified for partitioned table, lets fetch all.
- Map<String, String> tblProps = table.getParameters() == null ?
- new HashMap<String, String>() : table.getParameters();
-
- Map<String, Long> valueMap = new HashMap<>();
- Map<String, Boolean> stateMap = new HashMap<>();
- for (String stat : StatsSetupConst.SUPPORTED_STATS) {
- valueMap.put(stat, 0L);
- stateMap.put(stat, true);
- }
+ // Fetch partition statistics only for describe extended or formatted.
+ if (desc.isExtended() || desc.isFormatted()) {
+ if (table.isPartitioned() && partition == null) {
+ // No partition specified for partitioned table, lets fetch all.
+ Map<String, String> tblProps = table.getParameters() == null ?
+ new HashMap<String, String>() : table.getParameters();
- PartitionIterable partitions = new PartitionIterable(context.getDb(), table, null,
- MetastoreConf.getIntVar(context.getConf(), MetastoreConf.ConfVars.BATCH_RETRIEVE_MAX));
- int numParts = 0;
- for (Partition p : partitions) {
- Map<String, String> partitionProps = p.getParameters();
- Boolean state = StatsSetupConst.areBasicStatsUptoDate(partitionProps);
+ Map<String, Long> valueMap = new HashMap<>();
+ Map<String, Boolean> stateMap = new HashMap<>();
for (String stat : StatsSetupConst.SUPPORTED_STATS) {
- stateMap.put(stat, stateMap.get(stat) && state);
- if (partitionProps != null && partitionProps.get(stat) != null) {
- valueMap.put(stat, valueMap.get(stat) + Long.parseLong(partitionProps.get(stat)));
+ valueMap.put(stat, 0L);
+ stateMap.put(stat, true);
+ }
+
+ PartitionIterable partitions = new PartitionIterable(context.getDb(), table, null,
+ MetastoreConf.getIntVar(context.getConf(), MetastoreConf.ConfVars.BATCH_RETRIEVE_MAX));
+ int numParts = 0;
+ for (Partition p : partitions) {
+ Map<String, String> partitionProps = p.getParameters();
+ Boolean state = StatsSetupConst.areBasicStatsUptoDate(partitionProps);
+ for (String stat : StatsSetupConst.SUPPORTED_STATS) {
+ stateMap.put(stat, stateMap.get(stat) && state);
+ if (partitionProps != null && partitionProps.get(stat) != null) {
+ valueMap.put(stat, valueMap.get(stat) + Long.parseLong(partitionProps.get(stat)));
+ }
}
+ numParts++;
}
- numParts++;
- }
- tblProps.put(StatsSetupConst.NUM_PARTITIONS, Integer.toString(numParts));
+ tblProps.put(StatsSetupConst.NUM_PARTITIONS, Integer.toString(numParts));
- for (String stat : StatsSetupConst.SUPPORTED_STATS) {
- StatsSetupConst.setBasicStatsState(tblProps, Boolean.toString(stateMap.get(stat)));
- tblProps.put(stat, valueMap.get(stat).toString());
+ for (String stat : StatsSetupConst.SUPPORTED_STATS) {
+ StatsSetupConst.setBasicStatsState(tblProps, Boolean.toString(stateMap.get(stat)));
+ tblProps.put(stat, valueMap.get(stat).toString());
+ }
+ table.setParameters(tblProps);
}
- table.setParameters(tblProps);
}
}