use of org.apache.hadoop.hive.ql.parse.QBSubQuery in project hive by apache.
the class ExplainSQRewriteTask method addRewrites.
void addRewrites(TokenRewriteStream stream, QB qb, String program, PrintStream out) {
QBSubQuery sqW = qb.getWhereClauseSubQueryPredicate();
QBSubQuery sqH = qb.getHavingClauseSubQueryPredicate();
if (sqW != null || sqH != null) {
ASTNode sqNode = sqW != null ? sqW.getOriginalSubQueryASTForRewrite() : sqH.getOriginalSubQueryASTForRewrite();
ASTNode tokQry = getQueryASTNode(sqNode);
ASTNode tokFrom = (ASTNode) tokQry.getChild(0);
StringBuilder addedJoins = new StringBuilder();
if (sqW != null) {
addRewrites(stream, sqW, program, out, qb.getId(), true, addedJoins);
}
if (sqH != null) {
addRewrites(stream, sqH, program, out, qb.getId(), false, addedJoins);
}
stream.insertAfter(program, tokFrom.getTokenStopIndex(), addedJoins);
}
Set<String> sqAliases = qb.getSubqAliases();
for (String sqAlias : sqAliases) {
addRewrites(stream, qb.getSubqForAlias(sqAlias).getQB(), program, out);
}
}
Aggregations