本文整理汇总了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;
}
示例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;
}
示例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++;
}
}
}
示例4: generate
@Override
public boolean generate(ASTNode hiveRoot, CommonTree sqlRoot, ASTNode currentHiveNode,
CommonTree currentSqlNode, TranslateContext context) throws SqlXlateException {
if (currentHiveNode.getChildCount() == 2&¤tHiveNode.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;
}
示例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;
}
示例6: getSelectExprAST
private ASTNode getSelectExprAST() {
return new ASTNode(new CommonToken(HiveParser.TOK_SELEXPR, "TOK_SELEXPR"));
}