Search in sources :

Example 1 with DDLDescWithWriteId

use of org.apache.hadoop.hive.ql.ddl.DDLDesc.DDLDescWithWriteId in project hive by apache.

the class DriverTxnHandler method setWriteIdForAcidDdl.

private boolean setWriteIdForAcidDdl() throws SemanticException, LockException {
    DDLDescWithWriteId acidDdlDesc = driverContext.getPlan().getAcidDdlDesc();
    boolean hasAcidDdl = acidDdlDesc != null && acidDdlDesc.mayNeedWriteId();
    if (hasAcidDdl) {
        String fqTableName = acidDdlDesc.getFullTableName();
        TableName tableName = HiveTableName.of(fqTableName);
        long writeId = driverContext.getTxnManager().getTableWriteId(tableName.getDb(), tableName.getTable());
        acidDdlDesc.setWriteId(writeId);
    }
    return hasAcidDdl;
}
Also used : TableName(org.apache.hadoop.hive.common.TableName) HiveTableName(org.apache.hadoop.hive.ql.parse.HiveTableName) DDLDescWithWriteId(org.apache.hadoop.hive.ql.ddl.DDLDesc.DDLDescWithWriteId)

Example 2 with DDLDescWithWriteId

use of org.apache.hadoop.hive.ql.ddl.DDLDesc.DDLDescWithWriteId in project hive by apache.

the class AlterTableSkewedByAnalyzer method analyzeCommand.

@Override
protected void analyzeCommand(TableName tableName, Map<String, String> partitionSpec, ASTNode command) throws SemanticException {
    Table table = getTable(tableName);
    validateAlterTableType(table, AlterTableType.SKEWED_BY, false);
    inputs.add(new ReadEntity(table));
    outputs.add(new WriteEntity(table, WriteEntity.WriteType.DDL_EXCLUSIVE));
    DDLDescWithWriteId desc = null;
    if (command.getChildCount() == 0) {
        desc = new AlterTableNotSkewedDesc(tableName);
        setAcidDdlDesc(table, desc);
    } else {
        switch(((ASTNode) command.getChild(0)).getToken().getType()) {
            case HiveParser.TOK_TABLESKEWED:
                desc = handleAlterTableSkewedBy(command, tableName, table);
                setAcidDdlDesc(table, desc);
                break;
            case HiveParser.TOK_STOREDASDIRS:
                desc = handleAlterTableDisableStoredAsDirs(tableName, table);
                setAcidDdlDesc(table, desc);
                break;
            default:
                assert false;
        }
    }
    rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
}
Also used : ReadEntity(org.apache.hadoop.hive.ql.hooks.ReadEntity) Table(org.apache.hadoop.hive.ql.metadata.Table) DDLWork(org.apache.hadoop.hive.ql.ddl.DDLWork) DDLDescWithWriteId(org.apache.hadoop.hive.ql.ddl.DDLDesc.DDLDescWithWriteId) WriteEntity(org.apache.hadoop.hive.ql.hooks.WriteEntity)

Aggregations

DDLDescWithWriteId (org.apache.hadoop.hive.ql.ddl.DDLDesc.DDLDescWithWriteId)2 TableName (org.apache.hadoop.hive.common.TableName)1 DDLWork (org.apache.hadoop.hive.ql.ddl.DDLWork)1 ReadEntity (org.apache.hadoop.hive.ql.hooks.ReadEntity)1 WriteEntity (org.apache.hadoop.hive.ql.hooks.WriteEntity)1 Table (org.apache.hadoop.hive.ql.metadata.Table)1 HiveTableName (org.apache.hadoop.hive.ql.parse.HiveTableName)1