当前位置: 首页>>代码示例>>Java>>正文


Java HiveParser.TOK_SELEXPR属性代码示例

本文整理汇总了Java中org.apache.hadoop.hive.ql.parse.HiveParser.TOK_SELEXPR属性的典型用法代码示例。如果您正苦于以下问题:Java HiveParser.TOK_SELEXPR属性的具体用法?Java HiveParser.TOK_SELEXPR怎么用?Java HiveParser.TOK_SELEXPR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.hadoop.hive.ql.parse.HiveParser的用法示例。


在下文中一共展示了HiveParser.TOK_SELEXPR属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isExpressionsAnswerableFromFact

/**
 * Check if expression is answerable from fact, then push it to fact pushdown subquery
 *
 * @param node
 * @return true if expressions is used
 */
public boolean isExpressionsAnswerableFromFact(ASTNode node) {
  boolean isAnswerable = true;
  for (int i = 0; i < node.getChildCount(); i++) {
    if (node.getChild(i).getType() == HiveParser.TOK_SELEXPR) {
      int cnt = getColumnCount((ASTNode) node.getChild(i));
      if (cnt >= 2) {
        if (cnt == getNumFactTableInExpressions((ASTNode) node.getChild(i), new MutableInt(0))) {
          isAnswerable = true;
        } else {
          isAnswerable = false;
        }
      }
    }
  }
  return isAnswerable;
}
 
开发者ID:apache,项目名称:lens,代码行数:22,代码来源:ColumnarSQLRewriter.java

示例2: processAggregate

private ASTNode processAggregate(ASTNode astNode, ASTNode innerSelectAST,
    AliasDecider aliasDecider, boolean isSelectAst) {
  ASTNode innerSelectASTWithoutAlias = MetastoreUtil.copyAST(astNode);
  ASTNode innerSelectExprAST = new ASTNode(new CommonToken(HiveParser.TOK_SELEXPR, "TOK_SELEXPR"));
  innerSelectExprAST.addChild(innerSelectASTWithoutAlias);
  String alias = aliasDecider.decideAlias(astNode);
  ASTNode aliasNode = new ASTNode(new CommonToken(Identifier, alias));
  innerSelectExprAST.addChild(aliasNode);
  innerSelectAST.addChild(innerSelectExprAST);
  ASTNode dotAST = getDotAST(cubeql.getCube().getName(), alias);
  ASTNode outerAST = new ASTNode(new CommonToken(TOK_FUNCTION, "TOK_FUNCTION"));
  //TODO: take care or non-transitive aggregate functions
  outerAST.addChild(new ASTNode(new CommonToken(Identifier, astNode.getChild(0).getText())));
  outerAST.addChild(dotAST);
  HashableASTNode innerAST = new HashableASTNode(innerSelectASTWithoutAlias);
  if (isSelectAst && !innerToOuterSelectASTs.containsKey(innerAST)) {
    innerToOuterSelectASTs.put(innerAST, outerAST);
  } else if (!isSelectAst && !innerToOuterHavingASTs.containsKey(innerAST)) {
    innerToOuterHavingASTs.put(innerAST, outerAST);
  }
  return outerAST;
}
 
开发者ID:apache,项目名称:lens,代码行数:22,代码来源:UnionQueryWriter.java

示例3: promoteGroupby

private void promoteGroupby(CubeQueryContext cubeql, List<SelectPhraseContext> selectExprs, List<String> groupByExprs)
  throws LensException {
  if (!groupbyPromotionEnabled) {
    return;
  }

  if (selectExprs.size() > 0) {
    log.info("Not promoting groupby expression to select, since there are expression projected");
    return;
  }

  int index = 0;
  for (String expr : groupByExprs) {
    if (!contains(selectExprs, expr)) {
      ASTNode exprAST = HQLParser.parseExpr(expr, cubeql.getConf());
      ASTNode parent = new ASTNode(new CommonToken(HiveParser.TOK_SELEXPR, "TOK_SELEXPR"));
      parent.addChild(exprAST);
      exprAST.setParent(parent);
      addChildAtIndex(index, cubeql.getSelectAST(), parent);
      updateSelectPhrase(cubeql, index, parent);
      index++;
    }
  }
}
 
开发者ID:apache,项目名称:lens,代码行数:24,代码来源:GroupbyResolver.java

示例4: generate

@Override
public boolean generate(ASTNode hiveRoot, CommonTree sqlRoot, ASTNode currentHiveNode,
    CommonTree currentSqlNode, TranslateContext context) throws SqlXlateException {
  if (currentHiveNode.getChildCount() == 2&&currentHiveNode.getType()==HiveParser.TOK_SELEXPR) {

    ASTNode dot = super.newHiveASTNode(HiveParser.DOT, ".");
    dot.addChild((ASTNode) currentHiveNode.getChild(0));
    // if children count == 2 the second should only be text element
    dot.addChild((ASTNode) currentHiveNode.getChild(1).getChild(0));
    currentHiveNode.deleteChild(0);
    currentHiveNode.deleteChild(0);
    currentHiveNode.addChild(dot);
    LOG.debug("Generated Cascated Element : " + dot.toStringTree());
    return true;
  }
  return true;
}
 
开发者ID:adrian-wang,项目名称:project-panthera-skin,代码行数:17,代码来源:PostCascatedElementGenerator.java

示例5: isSelectDistinctStar

/**
 * Check if subtree represents select distinct *
 *
 * @param select
 * @return
 */
public static boolean isSelectDistinctStar(ASTNode select) {
  if (select.getType() != HiveParser.TOK_SELECTDI) {
    return false;
  }
  if (select.getChildCount() > 1) {
    return false;
  }
  if (select.getChild(0).getType() != HiveParser.TOK_SELEXPR) {
    return false;
  }
  if (select.getChild(0).getChild(0).getType() != HiveParser.TOK_ALLCOLREF) {
    return false;
  }
  return true;
}
 
开发者ID:adrian-wang,项目名称:project-panthera-skin,代码行数:21,代码来源:SqlXlateUtil.java

示例6: getSelectExprAST

private ASTNode getSelectExprAST() {
  return new ASTNode(new CommonToken(HiveParser.TOK_SELEXPR, "TOK_SELEXPR"));
}
 
开发者ID:apache,项目名称:lens,代码行数:3,代码来源:UnionQueryWriter.java


注:本文中的org.apache.hadoop.hive.ql.parse.HiveParser.TOK_SELEXPR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。