org.apache.hadoop.hive.ql.lib.Node Java Examples
The following examples show how to use
org.apache.hadoop.hive.ql.lib.Node.
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: TableProcessor.java From circus-train with Apache License 2.0 | 5 votes |
@Override public Object process(Node node, Stack<Node> stack, NodeProcessorCtx procCtx, Object... nodeOutputs) throws SemanticException { ASTNode astNode = (ASTNode) node; if (astNode.getToken() != null && astNode.getToken().getText() != null) { if ("TOK_TABNAME".equals(astNode.getToken().getText())) { tables.add(extractTableName(astNode)); } } return null; }
Example #4
Source File: TableProcessorTest.java From circus-train with Apache License 2.0 | 5 votes |
@Test public void typical() throws Exception { ArrayList<Node> children = new ArrayList<>(); children.add(dbNode); children.add(tableNode); when(node.getChildren()).thenReturn(children); when(node.getChildCount()).thenReturn(children.size()); when(node.getChild(0)).thenReturn(dbNode); when(node.getChild(1)).thenReturn(tableNode); when(node.getType()).thenReturn(HiveParser.TOK_TABNAME); when(token.getText()).thenReturn("TOK_TABNAME"); processor.process(node, null, null); assertThat(processor.getTables(), is(Arrays.asList(DATABASE + "." + TABLE))); }
Example #5
Source File: TableProcessorTest.java From circus-train with Apache License 2.0 | 5 votes |
@Test public void unqualifiedTableName() throws Exception { ArrayList<Node> children = new ArrayList<>(); children.add(tableNode); when(node.getChildren()).thenReturn(children); when(node.getChildCount()).thenReturn(children.size()); when(node.getChild(0)).thenReturn(tableNode); when(node.getType()).thenReturn(HiveParser.TOK_TABNAME); when(token.getText()).thenReturn("TOK_TABNAME"); when(SessionState.get()).thenReturn(sessionState); processor.process(node, null, null); assertThat(processor.getTables(), is(Arrays.asList(DEFAULT_DATABASE + "." + TABLE))); }
Example #6
Source File: TableProcessorTest.java From circus-train with Apache License 2.0 | 5 votes |
@Test(expected = NullPointerException.class) public void unqualifiedTableNameFailsIsSessionIsNotSet() throws Exception { ArrayList<Node> children = new ArrayList<>(); children.add(tableNode); when(node.getChildren()).thenReturn(children); when(node.getChildCount()).thenReturn(children.size()); when(node.getChild(0)).thenReturn(tableNode); when(node.getType()).thenReturn(HiveParser.TOK_TABNAME); when(token.getText()).thenReturn("TOK_TABNAME"); processor.process(node, null, null); }
Example #7
Source File: HiveLanguageParserTest.java From circus-train with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void typical() throws Exception { parser.parse(CREATE_TABLE_STATEMENT, nodeProcessor); verify(nodeProcessor, times(49)).process(any(Node.class), any(Stack.class), any(NodeProcessorCtx.class), anyVararg()); }
Example #8
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); } }