HIVE-17607 : remove ColumnStatsDesc usage from columnstatsupdatetask (Gergely Hajos via Ashutosh Chauhan)
Signed-off-by: Ashutosh Chauhan <hashut...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/39e1636f Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/39e1636f Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/39e1636f Branch: refs/heads/master Commit: 39e1636f4ddc532647e51befd5ca289084ef8ada Parents: 0538e51 Author: Gergely Hajós <rogoz...@gmail.com> Authored: Thu Oct 19 17:16:52 2017 -0700 Committer: Ashutosh Chauhan <hashut...@apache.org> Committed: Thu Oct 19 18:11:14 2017 -0700 ---------------------------------------------------------------------- .../hive/ql/exec/ColumnStatsUpdateTask.java | 19 +++------ .../hive/ql/parse/DDLSemanticAnalyzer.java | 7 ++- .../hive/ql/plan/ColumnStatsUpdateWork.java | 45 ++++++++++++-------- 3 files changed, 38 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/39e1636f/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsUpdateTask.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsUpdateTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsUpdateTask.java index 2c15ba7..ab048cc 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsUpdateTask.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsUpdateTask.java @@ -48,7 +48,6 @@ import org.apache.hadoop.hive.ql.QueryState; import org.apache.hadoop.hive.ql.metadata.Hive; import org.apache.hadoop.hive.ql.metadata.HiveException; import org.apache.hadoop.hive.ql.parse.SemanticException; -import org.apache.hadoop.hive.ql.plan.ColumnStatsDesc; import org.apache.hadoop.hive.ql.plan.ColumnStatsUpdateWork; import org.apache.hadoop.hive.ql.plan.api.StageType; import org.apache.hadoop.hive.serde2.io.DateWritable; @@ -77,26 +76,23 @@ public class ColumnStatsUpdateTask extends Task<ColumnStatsUpdateWork> { private ColumnStatistics constructColumnStatsFromInput() throws SemanticException, MetaException { - String dbName = work.getCurrentDatabaseName(); - ColumnStatsDesc desc = work.getColStats(); - String tableName = desc.getTableName(); + String dbName = work.dbName(); + String tableName = work.getTableName(); String partName = work.getPartName(); - List<String> colName = desc.getColName(); - List<String> colType = desc.getColType(); + String colName = work.getColName(); + String columnType = work.getColType(); ColumnStatisticsObj statsObj = new ColumnStatisticsObj(); // grammar prohibits more than 1 column so we are guaranteed to have only 1 // element in this lists. - statsObj.setColName(colName.get(0)); + statsObj.setColName(colName); - statsObj.setColType(colType.get(0)); + statsObj.setColType(columnType); ColumnStatisticsData statsData = new ColumnStatisticsData(); - String columnType = colType.get(0); - if (columnType.equalsIgnoreCase("long") || columnType.equalsIgnoreCase("tinyint") || columnType.equalsIgnoreCase("smallint") || columnType.equalsIgnoreCase("int") || columnType.equalsIgnoreCase("bigint") || columnType.equalsIgnoreCase("timestamp")) { @@ -267,8 +263,7 @@ public class ColumnStatsUpdateTask extends Task<ColumnStatsUpdateWork> { } else { throw new SemanticException("Unsupported type"); } - String [] names = Utilities.getDbTableName(dbName, tableName); - ColumnStatisticsDesc statsDesc = getColumnStatsDesc(names[0], names[1], + ColumnStatisticsDesc statsDesc = getColumnStatsDesc(dbName, tableName, partName, partName == null); ColumnStatistics colStat = new ColumnStatistics(); colStat.setStatsDesc(statsDesc); http://git-wip-us.apache.org/repos/asf/hive/blob/39e1636f/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 9730518..941a067 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 @@ -92,7 +92,6 @@ import org.apache.hadoop.hive.ql.plan.AlterTableDesc.AlterTableTypes; import org.apache.hadoop.hive.ql.plan.AlterTableExchangePartition; import org.apache.hadoop.hive.ql.plan.AlterTableSimpleDesc; import org.apache.hadoop.hive.ql.plan.CacheMetadataDesc; -import org.apache.hadoop.hive.ql.plan.ColumnStatsDesc; import org.apache.hadoop.hive.ql.plan.ColumnStatsUpdateWork; import org.apache.hadoop.hive.ql.plan.CreateDatabaseDesc; import org.apache.hadoop.hive.ql.plan.CreateIndexDesc; @@ -598,10 +597,10 @@ public class DDLSemanticAnalyzer extends BaseSemanticAnalyzer { throw new SemanticException("column type not found"); } - ColumnStatsDesc cStatsDesc = new ColumnStatsDesc(tbl.getDbName() + "." + tbl.getTableName(), - Arrays.asList(colName), Arrays.asList(colType), partSpec == null); + ColumnStatsUpdateWork columnStatsUpdateWork = + new ColumnStatsUpdateWork(partName, mapProp, tbl.getDbName(), tbl.getTableName(), colName, colType); ColumnStatsUpdateTask cStatsUpdateTask = (ColumnStatsUpdateTask) TaskFactory - .get(new ColumnStatsUpdateWork(cStatsDesc, partName, mapProp, SessionState.get().getCurrentDatabase()), conf); + .get(columnStatsUpdateWork, conf); rootTasks.add(cStatsUpdateTask); } http://git-wip-us.apache.org/repos/asf/hive/blob/39e1636f/ql/src/java/org/apache/hadoop/hive/ql/plan/ColumnStatsUpdateWork.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/ColumnStatsUpdateWork.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/ColumnStatsUpdateWork.java index 5f9041e..9c606e2 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/plan/ColumnStatsUpdateWork.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/ColumnStatsUpdateWork.java @@ -34,17 +34,25 @@ import org.apache.hadoop.hive.ql.plan.Explain.Level; @Explain(displayName = "Column Stats Update Work", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED }) public class ColumnStatsUpdateWork implements Serializable { private static final long serialVersionUID = 1L; - private ColumnStatsDesc colStats; - private String partName; - private Map<String, String> mapProp; - private String currentDatabaseName; + private final String partName; + private final Map<String, String> mapProp; + private final String dbName; + private final String tableName; + private final String colName; + private final String colType; - public ColumnStatsUpdateWork(ColumnStatsDesc colStats, String partName, - Map<String, String> mapProp, String currentDatabaseName) { + public ColumnStatsUpdateWork(String partName, + Map<String, String> mapProp, + String dbName, + String tableName, + String colName, + String colType) { this.partName = partName; - this.colStats = colStats; this.mapProp = mapProp; - this.currentDatabaseName = currentDatabaseName; + this.dbName = dbName; + this.tableName = tableName; + this.colName = colName; + this.colType = colType; } @Override @@ -52,11 +60,6 @@ public class ColumnStatsUpdateWork implements Serializable { return null; } - @Explain(displayName = "Column Stats Desc") - public ColumnStatsDesc getColStats() { - return colStats; - } - public String getPartName() { return partName; } @@ -65,11 +68,19 @@ public class ColumnStatsUpdateWork implements Serializable { return mapProp; } - public String getCurrentDatabaseName() { - return currentDatabaseName; + public String dbName() { + return dbName; + } + + public String getTableName() { + return tableName; + } + + public String getColName() { + return colName; } - public void setCurrentDatabaseName(String currentDatabaseName) { - this.currentDatabaseName = currentDatabaseName; + public String getColType() { + return colType; } }