use of org.apache.hadoop.hive.ql.plan.AlterMaterializedViewDesc in project hive by apache.
the class DDLSemanticAnalyzer method analyzeAlterMaterializedViewRewrite.
private void analyzeAlterMaterializedViewRewrite(String mvName, ASTNode ast) throws SemanticException {
// Value for the flag
boolean enableFlag;
switch(ast.getChild(0).getType()) {
case HiveParser.TOK_REWRITE_ENABLED:
enableFlag = true;
break;
case HiveParser.TOK_REWRITE_DISABLED:
enableFlag = false;
break;
default:
throw new SemanticException("Invalid alter materialized view expression");
}
AlterMaterializedViewDesc alterMVDesc = new AlterMaterializedViewDesc(AlterMaterializedViewTypes.UPDATE_REWRITE_FLAG);
alterMVDesc.setMaterializedViewName(mvName);
alterMVDesc.setRewriteEnableFlag(enableFlag);
// It can be fully qualified name or use default database
Table materializedViewTable = getTable(mvName, true);
// only uses transactional (MM and ACID) tables
if (enableFlag) {
for (String tableName : materializedViewTable.getCreationMetadata().getTablesUsed()) {
Table table = getTable(tableName, true);
if (!AcidUtils.isTransactionalTable(table)) {
throw new SemanticException("Automatic rewriting for materialized view cannot " + "be enabled if the materialized view uses non-transactional tables");
}
}
}
inputs.add(new ReadEntity(materializedViewTable));
outputs.add(new WriteEntity(materializedViewTable, WriteEntity.WriteType.DDL_EXCLUSIVE));
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), alterMVDesc)));
}
Aggregations