use of org.apache.hadoop.hive.ql.parse.TableAccessInfo in project hive by apache.
the class CheckTableAccessHook method run.
public void run(HookContext hookContext) {
HiveConf conf = hookContext.getConf();
if (conf.getBoolVar(HiveConf.ConfVars.HIVE_STATS_COLLECT_TABLEKEYS) == false) {
return;
}
QueryPlan plan = hookContext.getQueryPlan();
if (plan == null) {
return;
}
TableAccessInfo tableAccessInfo = hookContext.getQueryPlan().getTableAccessInfo();
if (tableAccessInfo == null || tableAccessInfo.getOperatorToTableAccessMap() == null || tableAccessInfo.getOperatorToTableAccessMap().isEmpty()) {
return;
}
LogHelper console = SessionState.getConsole();
Map<Operator<? extends OperatorDesc>, Map<String, List<String>>> operatorToTableAccessMap = tableAccessInfo.getOperatorToTableAccessMap();
// Must be deterministic order map for consistent q-test output across Java versions
Map<String, String> outputOrderedMap = new LinkedHashMap<String, String>();
for (Map.Entry<Operator<? extends OperatorDesc>, Map<String, List<String>>> tableAccess : operatorToTableAccessMap.entrySet()) {
StringBuilder perOperatorInfo = new StringBuilder();
perOperatorInfo.append("Operator:").append(tableAccess.getKey().getOperatorId()).append("\n");
for (Map.Entry<String, List<String>> entry : tableAccess.getValue().entrySet()) {
perOperatorInfo.append("Table:").append(entry.getKey()).append("\n");
perOperatorInfo.append("Keys:").append(StringUtils.join(entry.getValue(), ',')).append("\n");
}
outputOrderedMap.put(tableAccess.getKey().getOperatorId(), perOperatorInfo.toString());
}
for (String perOperatorInfo : outputOrderedMap.values()) {
console.printError(perOperatorInfo);
}
}
Aggregations