QueryContext queryContext = query.context.getQueryContext();
CatalogService catalog = query.context.getQueryMasterContext().getWorkerContext().getCatalog();
if (queryContext.hasOutputTable()) { // TRUE only if a query command is 'CREATE TABLE' OR 'INSERT INTO'
if (queryContext.isOutputOverwrite()) { // TRUE only if a query is 'INSERT OVERWRITE INTO'
catalog.deleteTable(finalOutputDir.getName());
}
catalog.addTable(finalTableDesc);
}
query.setResultDesc(finalTableDesc);
query.finished(QueryState.QUERY_SUCCEEDED);