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/06/23 11:05:04 UTC

svn commit: r1604718 - in /hive/trunk/ql/src: java/org/apache/hadoop/hive/ql/exec/DDLTask.java test/queries/clientpositive/columnstats_partlvl.q test/results/clientpositive/columnstats_partlvl.q.out

Author: hashutosh
Date: Mon Jun 23 09:05:03 2014
New Revision: 1604718

URL: http://svn.apache.org/r1604718
Log:
HIVE-7051 : Display partition level column stats in DESCRIBE EXTENDED/FORMATTED PARTITION (Ashutosh Chauhan via Gunther Hagleitner)

Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
    hive/trunk/ql/src/test/queries/clientpositive/columnstats_partlvl.q
    hive/trunk/ql/src/test/results/clientpositive/columnstats_partlvl.q.out

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java?rev=1604718&r1=1604717&r2=1604718&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java Mon Jun 23 09:05:03 2014
@@ -1279,7 +1279,7 @@ public class DDLTask extends Task<DDLWor
     assert(tbl.isPartitioned());
 
     List<FieldSchema> newPartitionKeys = new ArrayList<FieldSchema>();
-    
+
     //Check if the existing partition values can be type casted to the new column type
     // with a non null value before trying to alter the partition column type.
     try {
@@ -1291,19 +1291,19 @@ public class DDLTask extends Task<DDLWor
           break;
         }
       }
-      
+
       if (colIndex == -1 || colIndex == tbl.getTTable().getPartitionKeys().size()) {
-        throw new HiveException("Cannot find partition column " + 
+        throw new HiveException("Cannot find partition column " +
             alterPartitionDesc.getPartKeySpec().getName());
       }
-      
+
       TypeInfo expectedType =
           TypeInfoUtils.getTypeInfoFromTypeString(alterPartitionDesc.getPartKeySpec().getType());
       ObjectInspector outputOI =
           TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(expectedType);
       Converter converter = ObjectInspectorConverters.getConverter(
-          PrimitiveObjectInspectorFactory.javaStringObjectInspector, outputOI); 
-      
+          PrimitiveObjectInspectorFactory.javaStringObjectInspector, outputOI);
+
       // For all the existing partitions, check if the value can be type casted to a non-null object
       for(Partition part : partitions) {
         if (part.getName().equals(conf.getVar(HiveConf.ConfVars.DEFAULTPARTITIONNAME))) {
@@ -1312,23 +1312,23 @@ public class DDLTask extends Task<DDLWor
         try {
           String value = part.getValues().get(colIndex);
           Object convertedValue =
-              converter.convert(value);        
+              converter.convert(value);
           if (convertedValue == null) {
             throw new HiveException(" Converting from " + TypeInfoFactory.stringTypeInfo + " to " +
               expectedType + " for value : " + value + " resulted in NULL object");
           }
         } catch (Exception e) {
-          throw new HiveException("Exception while converting " + 
+          throw new HiveException("Exception while converting " +
               TypeInfoFactory.stringTypeInfo + " to " +
               expectedType + " for value : " + part.getValues().get(colIndex));
-        }        
+        }
       }
     } catch(Exception e) {
       throw new HiveException(
           "Exception while checking type conversion of existing partition values to " +
           alterPartitionDesc.getPartKeySpec() + " : " + e.getMessage());
     }
-    
+
     for(FieldSchema col : tbl.getTTable().getPartitionKeys()) {
       if (col.getName().compareTo(alterPartitionDesc.getPartKeySpec().getName()) == 0) {
         newPartitionKeys.add(alterPartitionDesc.getPartKeySpec());
@@ -3439,8 +3439,13 @@ public class DDLTask extends Task<DDLWor
           String[] dbTab = splitTableName(tableName);
           List<String> colNames = new ArrayList<String>();
           colNames.add(colName.toLowerCase());
-          colStats = db.getTableColumnStatistics(dbTab[0].toLowerCase(),
-              dbTab[1].toLowerCase(), colNames);
+          if (null == part) {
+            colStats = db.getTableColumnStatistics(dbTab[0].toLowerCase(), dbTab[1].toLowerCase(), colNames);
+          } else {
+            List<String> partitions = new ArrayList<String>();
+            partitions.add(part.getName());
+            colStats = db.getPartitionColumnStatistics(dbTab[0].toLowerCase(), dbTab[1].toLowerCase(), partitions, colNames).get(part.getName());
+          }
         }
       }
 
@@ -3701,7 +3706,7 @@ public class DDLTask extends Task<DDLWor
           MetadataTypedColumnsetSerDe.class.getName())
           && !tbl.getSerializationLib().equals(LazySimpleSerDe.class.getName())
           && !tbl.getSerializationLib().equals(ColumnarSerDe.class.getName())
-          && !tbl.getSerializationLib().equals(DynamicSerDe.class.getName()) 
+          && !tbl.getSerializationLib().equals(DynamicSerDe.class.getName())
           && !tbl.getSerializationLib().equals(ParquetHiveSerDe.class.getName())) {
         throw new HiveException(ErrorMsg.CANNOT_REPLACE_COLUMNS, alterTbl.getOldName());
       }

Modified: hive/trunk/ql/src/test/queries/clientpositive/columnstats_partlvl.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/columnstats_partlvl.q?rev=1604718&r1=1604717&r2=1604718&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/columnstats_partlvl.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/columnstats_partlvl.q Mon Jun 23 09:05:03 2014
@@ -23,3 +23,5 @@ explain 
 analyze table Employee_Part partition (employeeSalary=2000.0) compute statistics for columns;
 analyze table Employee_Part partition (employeeSalary=2000.0) compute statistics for columns;
 
+describe formatted Employee_Part.employeeID   partition (employeeSalary=2000.0);
+describe formatted Employee_Part.employeeName partition (employeeSalary=2000.0);

Modified: hive/trunk/ql/src/test/results/clientpositive/columnstats_partlvl.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/columnstats_partlvl.q.out?rev=1604718&r1=1604717&r2=1604718&view=diff
==============================================================================
Files hive/trunk/ql/src/test/results/clientpositive/columnstats_partlvl.q.out (original) and hive/trunk/ql/src/test/results/clientpositive/columnstats_partlvl.q.out Mon Jun 23 09:05:03 2014 differ