Search in sources :

Example 1 with ColumnStatsUpdateTask

use of org.apache.hadoop.hive.ql.exec.ColumnStatsUpdateTask 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");
    ColumnStatsDesc cStatsDesc = new ColumnStatsDesc(tbl.getDbName() + "." + tbl.getTableName(), Arrays.asList(colName), Arrays.asList(colType), partSpec == null);
    ColumnStatsUpdateTask cStatsUpdateTask = (ColumnStatsUpdateTask) TaskFactory.get(new ColumnStatsUpdateWork(cStatsDesc, partName, mapProp), conf);
    rootTasks.add(cStatsUpdateTask);
}
Also used : Table(org.apache.hadoop.hive.ql.metadata.Table) ColumnStatsDesc(org.apache.hadoop.hive.ql.plan.ColumnStatsDesc) 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 ColumnStatsDesc (org.apache.hadoop.hive.ql.plan.ColumnStatsDesc)1 ColumnStatsUpdateWork (org.apache.hadoop.hive.ql.plan.ColumnStatsUpdateWork)1