Search in sources :

Example 26 with AlterTableDesc

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

the class ReplicationSemanticAnalyzer method tableUpdateReplStateTask.

private Task<? extends Serializable> tableUpdateReplStateTask(String dbName, String tableName, Map<String, String> partSpec, String replState, Task<? extends Serializable> preCursor) {
    HashMap<String, String> mapProp = new HashMap<>();
    mapProp.put(ReplicationSpec.KEY.CURR_STATE_ID.toString(), replState);
    AlterTableDesc alterTblDesc = new AlterTableDesc(AlterTableDesc.AlterTableTypes.ADDPROPS, new ReplicationSpec(replState, replState));
    alterTblDesc.setProps(mapProp);
    alterTblDesc.setOldName(StatsUtils.getFullyQualifiedTableName(dbName, tableName));
    alterTblDesc.setPartSpec((HashMap<String, String>) partSpec);
    Task<? extends Serializable> updateReplIdTask = TaskFactory.get(new DDLWork(inputs, outputs, alterTblDesc), conf);
    // Link the update repl state task with dependency collection task
    if (preCursor != null) {
        preCursor.addDependentTask(updateReplIdTask);
        LOG.debug("Added {}:{} as a precursor of {}:{}", preCursor.getClass(), preCursor.getId(), updateReplIdTask.getClass(), updateReplIdTask.getId());
    }
    return updateReplIdTask;
}
Also used : AlterTableDesc(org.apache.hadoop.hive.ql.plan.AlterTableDesc) DDLWork(org.apache.hadoop.hive.ql.plan.DDLWork) HashMap(java.util.HashMap)

Aggregations

AlterTableDesc (org.apache.hadoop.hive.ql.plan.AlterTableDesc)26 DDLWork (org.apache.hadoop.hive.ql.plan.DDLWork)24 ArrayList (java.util.ArrayList)10 SQLUniqueConstraint (org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint)8 SQLForeignKey (org.apache.hadoop.hive.metastore.api.SQLForeignKey)6 SQLPrimaryKey (org.apache.hadoop.hive.metastore.api.SQLPrimaryKey)6 SemanticException (org.apache.hadoop.hive.ql.parse.SemanticException)6 ImmutableList (com.google.common.collect.ImmutableList)4 Serializable (java.io.Serializable)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4 SQLCheckConstraint (org.apache.hadoop.hive.metastore.api.SQLCheckConstraint)4 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)4 SQLNotNullConstraint (org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)4 Task (org.apache.hadoop.hive.ql.exec.Task)4 Table (org.apache.hadoop.hive.ql.metadata.Table)4 HashMap (java.util.HashMap)3 DefaultConstraint (org.apache.hadoop.hive.ql.metadata.DefaultConstraint)3 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)3 FileNotFoundException (java.io.FileNotFoundException)2