Java Code Examples for org.apache.hadoop.hive.ql.parse.ASTNode#getChildren()
The following examples show how to use
org.apache.hadoop.hive.ql.parse.ASTNode#getChildren() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Parser.java From Eagle with Apache License 2.0 | 7 votes |
private void visitSubtree(ASTNode ast) { int len = ast.getChildCount(); if (len > 0) { for (Node n : ast.getChildren()) { ASTNode asn = (ASTNode)n; switch (asn.getToken().getType()) { case HiveParser.TOK_TABNAME: tableSet.add(ast.getChild(0).getChild(0).getText()); break; case HiveParser.TOK_SET_COLUMNS_CLAUSE: for (int i = 0; i < asn.getChildCount(); i++) { addToColumnSet((ASTNode)asn.getChild(i).getChild(0)); } case HiveParser.TOK_FROM: parseFromClause((ASTNode)asn.getChild(0)); break; case HiveParser.TOK_INSERT: for (int i = 0; i < asn.getChildCount(); i++) { parseInsertClause((ASTNode)asn.getChild(i)); } break; case HiveParser.TOK_UNIONTYPE: int childcount = asn.getChildCount(); for (int i = 0; i < childcount; i++) { parseQL((ASTNode)asn.getChild(i)); } break; } } // Add tableSet and columnSet to tableColumnMap addTablesColumnsToMap(tableSet, columnSet); } }
Example 2
Source File: Parser.java From eagle with Apache License 2.0 | 6 votes |
private void parseQueryClause(ASTNode ast) { int len = ast.getChildCount(); if (len > 0) { for (Node n : ast.getChildren()) { ASTNode asn = (ASTNode) n; switch (asn.getToken().getType()) { case HiveParser.TOK_FROM: parseFromClause((ASTNode) asn.getChild(0)); break; case HiveParser.TOK_INSERT: for (int i = 0; i < asn.getChildCount(); i++) { parseInsertClause((ASTNode) asn.getChild(i)); } break; } } } }
Example 3
Source File: HiveASTRewriter.java From incubator-atlas with Apache License 2.0 | 5 votes |
private void rewrite(ASTNode origin) throws RewriteException { ASTNode node = origin; if (node != null) { for(ASTRewriter rewriter : rewriters) { rewriter.rewrite(rwCtx, node); } if (node.getChildren() != null) { for (int i = 0; i < node.getChildren().size(); i++) { rewrite((ASTNode) node.getChild(i)); } } } }
Example 4
Source File: Parser.java From eagle with Apache License 2.0 | 5 votes |
private void visitSubtree(ASTNode ast) { int len = ast.getChildCount(); if (len > 0) { for (Node n : ast.getChildren()) { ASTNode asn = (ASTNode)n; switch (asn.getToken().getType()) { case HiveParser.TOK_TABNAME: //tableSet.add(ast.getChild(0).getChild(0).getText()); parserContent.getTableColumnMap().put(ast.getChild(0).getChild(0).getText(), new HashSet<>(columnSet)); break; case HiveParser.TOK_SET_COLUMNS_CLAUSE: for (int i = 0; i < asn.getChildCount(); i++) { addToColumnSet((ASTNode) asn.getChild(i).getChild(0)); } break; case HiveParser.TOK_QUERY: parseQueryClause(asn); break; case HiveParser.TOK_UNIONTYPE: case HiveParser.TOK_UNIONALL: case HiveParser.TOK_UNIONDISTINCT: visitSubtree(asn); break; } } // Add tableSet and columnSet to tableColumnMap addTablesColumnsToMap(tableSet, columnSet); } }