private void rewriteCorrConjunctForHaving(ASTNode conjunctASTNode, boolean refersLeft, String outerQueryAlias, RowResolver outerQueryRR, ColumnInfo outerQueryCol) { String newColAlias = "_gby_sq_col_" + numOuterCorrExprsForHaving++; ASTNode outerExprForCorr = SubQueryUtils.createColRefAST(outerQueryAlias, newColAlias); if ( refersLeft ) { conjunctASTNode.setChild(0, outerExprForCorr); } else { conjunctASTNode.setChild(1, outerExprForCorr); } outerQueryRR.put(outerQueryAlias, newColAlias, outerQueryCol); }
private void rewriteCorrConjunctForHaving(ASTNode conjunctASTNode, boolean refersLeft, String outerQueryAlias, RowResolver outerQueryRR, ColumnInfo outerQueryCol) { String newColAlias = "_gby_sq_col_" + numOuterCorrExprsForHaving++; ASTNode outerExprForCorr = SubQueryUtils.createColRefAST(outerQueryAlias, newColAlias); if ( refersLeft ) { conjunctASTNode.setChild(0, outerExprForCorr); } else { conjunctASTNode.setChild(1, outerExprForCorr); } outerQueryRR.put(outerQueryAlias, newColAlias, outerQueryCol); }
root.setChild(1, child1); root.addChild(child2); found.setValue(true);
static ASTNode setQualifiedColumnReferences(ASTNode ast, String tableAlias) { int type = ast.getType(); if (type == HiveParser.DOT) { return ast; } if (type == HiveParser.TOK_TABLE_OR_COL) { if (tableAlias == null) { return null; } String colName = SemanticAnalyzer.unescapeIdentifier(ast.getChild(0).getText()); return SubQueryUtils.createColRefAST(tableAlias, colName); } for (int i = 0; i < ast.getChildCount(); i++) { ASTNode child = (ASTNode) ast.getChild(i); ASTNode c = setQualifiedColumnReferences(child, tableAlias); if (c == null) { return null; } if (c != child) { ast.setChild(i, c); } } return ast; }
static ASTNode setQualifiedColumnReferences(ASTNode ast, String tableAlias) { int type = ast.getType(); if (type == HiveParser.DOT) { return ast; } if (type == HiveParser.TOK_TABLE_OR_COL) { if (tableAlias == null) { return null; } String colName = SemanticAnalyzer.unescapeIdentifier(ast.getChild(0).getText()); return SubQueryUtils.createColRefAST(tableAlias, colName); } for (int i = 0; i < ast.getChildCount(); i++) { ASTNode child = (ASTNode) ast.getChild(i); ASTNode c = setQualifiedColumnReferences(child, tableAlias); if (c == null) { return null; } if (c != child) { ast.setChild(i, c); } } return ast; }
int pos = Integer.parseInt(node.getText()); if (pos > 0 && pos <= selectExpCnt) { groupbyNode.setChild(child_pos, selectNode.getChild(pos - 1).getChild(0)); } else { int pos = Integer.parseInt(node.getText()); if (pos > 0 && pos <= selectExpCnt) { colNode.setChild(0, selectNode.getChild(pos - 1).getChild(0)); } else { throw new SemanticException(
int pos = Integer.parseInt(node.getText()); if (pos > 0 && pos <= selectExpCnt) { groupbyNode.setChild(child_pos, selectNode.getChild(pos - 1).getChild(0)); } else { int pos = Integer.parseInt(node.getText()); if (pos > 0 && pos <= selectExpCnt && selectNode.getChild(pos - 1).getChildCount() > 0) { colNode.setChild(0, selectNode.getChild(pos - 1).getChild(0)); } else { throw new SemanticException(
subQueryDiagnostic.addWhereClauseRewrite("1 = 1"); whereClause.setChild(0, sqNewSearchCond);
subQueryDiagnostic.addWhereClauseRewrite("1 = 1"); whereClause.setChild(0, sqNewSearchCond);
ast.setChild(0, newFrom); processTable(qb, newFrom); } else if (frm.getToken().getType() == HiveParser.TOK_SUBQUERY) {
private void addChildAtIndex(int index, ASTNode parent, ASTNode child) { // add the last child int count = parent.getChildCount(); Tree lastchild = parent.getChild(count - 1); parent.addChild(lastchild); // move all the children from last upto index for (int i = count - 2; i >= index; i--) { Tree ch = parent.getChild(i); parent.setChild(i + 1, ch); } parent.setChild(index, child); }
List<String> processSelectAST(ASTNode selectAST) throws LensException { // iterate over children for (int i = 0; i < selectAST.getChildCount(); i++) { ASTNode selectExprNode = (ASTNode) selectAST.getChild(i); ASTNode child = (ASTNode) selectExprNode.getChild(0); if (hasBridgeCol(child, tableAlias)) { selectExprNode.setChild(0, getDotASTForExprAST(child)); } } return selectedBridgeExprs; }
private ASTNode getDefaultExpr(ASTNode node) { if (HQLParser.isAggregateAST(node)) { node.setChild(1, new ASTNode(new CommonToken(HiveParser.Identifier, "0.0"))); } for (int i = 0; i < node.getChildCount(); i++) { ASTNode child = (ASTNode) node.getChild(i); getDefaultExpr(child); } return node; }