outputTableName = queryContext.getOutputTable();
} else { // SELECT STATEMENT
outputTableName = query.getId().toString();
}
TableMeta meta = subQuery.getTableMeta();
try {
FileSystem fs = finalOutputDir.getFileSystem(query.systemConf);
ContentSummary directorySummary = fs.getContentSummary(finalOutputDir);
if(meta.getStat() == null) meta.setStat(new TableStat());
meta.getStat().setNumBytes(directorySummary.getLength());
} catch (IOException e) {
LOG.error(e.getMessage(), e);
}
TableDesc outputTableDesc = new TableDescImpl(outputTableName, meta, finalOutputDir);
TableDesc finalTableDesc = outputTableDesc;
// If a query has a target table, a TableDesc is updated.
if (queryContext.hasOutputTable()) { // CREATE TABLE or INSERT STATEMENT
if (queryContext.isOutputOverwrite()) {
CatalogService catalog = query.context.getQueryMasterContext().getWorkerContext().getCatalog();
Preconditions.checkNotNull(catalog, "CatalogService is NULL");
TableDesc updatingTable = catalog.getTableDesc(outputTableDesc.getName());
updatingTable.getMeta().setStat(meta.getStat());
finalTableDesc = updatingTable;
}
}
return finalTableDesc;
}