Java Code Examples for org.apache.hadoop.hive.ql.parse.HiveParser#TOK_UNIONTYPE

The following examples show how to use org.apache.hadoop.hive.ql.parse.HiveParser#TOK_UNIONTYPE . 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 vote down vote up
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 vote down vote up
private void parseSubQuery(ASTNode subQuery) {

    int cc = 0;
    int cp = 0;

    switch (subQuery.getToken().getType()) {
    case HiveParser.TOK_QUERY:
      visitSubtree(subQuery);
      break;
    case HiveParser.TOK_UNIONTYPE: 
      cc = subQuery.getChildCount();

      for ( cp = 0; cp < cc; ++cp) {    
        parseSubQuery((ASTNode)subQuery.getChild(cp));
      }
      break;
    }
  }
 
Example 3
Source File: Parser.java    From eagle with Apache License 2.0 5 votes vote down vote up
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);
  }
}