Search in sources :

Example 1 with ColumnStatsUpdateWork

use of org.apache.hadoop.hive.ql.plan.ColumnStatsUpdateWork in project hive by apache.

the class DDLSemanticAnalyzer method analyzeAlterTableUpdateStats.

private void analyzeAlterTableUpdateStats(ASTNode ast, String tblName, Map<String, String> partSpec) throws SemanticException {
    String colName = getUnescapedName((ASTNode) ast.getChild(0));
    Map<String, String> mapProp = getProps((ASTNode) (ast.getChild(1)).getChild(0));
    Table tbl = getTable(tblName);
    String partName = null;
    if (partSpec != null) {
        try {
            partName = Warehouse.makePartName(partSpec, false);
        } catch (MetaException e) {
            throw new SemanticException("partition " + partSpec.toString() + " not found");
        }
    }
    String colType = null;
    List<FieldSchema> cols = tbl.getCols();
    for (FieldSchema col : cols) {
        if (colName.equalsIgnoreCase(col.getName())) {
            colType = col.getType();
            break;
        }
    }
    if (colType == null) {
        throw new SemanticException("column type not found");
    }
    ColumnStatsUpdateWork columnStatsUpdateWork = new ColumnStatsUpdateWork(partName, mapProp, tbl.getDbName(), tbl.getTableName(), colName, colType);
    ColumnStatsUpdateTask cStatsUpdateTask = (ColumnStatsUpdateTask) TaskFactory.get(columnStatsUpdateWork);
    rootTasks.add(cStatsUpdateTask);
}
Also used : Table(org.apache.hadoop.hive.ql.metadata.Table) ColumnStatsUpdateTask(org.apache.hadoop.hive.ql.exec.ColumnStatsUpdateTask) ColumnStatsUpdateWork(org.apache.hadoop.hive.ql.plan.ColumnStatsUpdateWork) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Aggregations

FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)1 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)1 ColumnStatsUpdateTask (org.apache.hadoop.hive.ql.exec.ColumnStatsUpdateTask)1 Table (org.apache.hadoop.hive.ql.metadata.Table)1 ColumnStatsUpdateWork (org.apache.hadoop.hive.ql.plan.ColumnStatsUpdateWork)1