Search in sources :

Example 1 with TreeWizard

use of org.antlr.runtime.tree.TreeWizard in project hive by apache.

the class PTFTranslator method validateNoLeadLagInValueBoundarySpec.

public static void validateNoLeadLagInValueBoundarySpec(ASTNode node) throws SemanticException {
    String errMsg = "Lead/Lag not allowed in ValueBoundary Spec";
    TreeWizard tw = new TreeWizard(ParseDriver.adaptor, HiveParser.tokenNames);
    ValidateNoLeadLag visitor = new ValidateNoLeadLag(errMsg);
    tw.visit(node, HiveParser.TOK_FUNCTION, visitor);
    visitor.checkValid();
}
Also used : TreeWizard(org.antlr.runtime.tree.TreeWizard)

Example 2 with TreeWizard

use of org.antlr.runtime.tree.TreeWizard in project hive by apache.

the class SemanticAnalyzer method isValidGroupBySelectList.

/*
   * Returns false if there is a SelectExpr that is not a constant or an aggr.
   *
   */
private boolean isValidGroupBySelectList(QB currQB, String clause) {
    ConstantExprCheck constantExprCheck = new ConstantExprCheck();
    AggregationExprCheck aggrExprCheck = new AggregationExprCheck(currQB.getParseInfo().getAggregationExprsForClause(clause));
    TreeWizard tw = new TreeWizard(ParseDriver.adaptor, HiveParser.tokenNames);
    ASTNode selectNode = currQB.getParseInfo().getSelForClause(clause);
    /*
     * for Select Distinct Queries we don't move any aggregations.
     */
    if (selectNode != null && selectNode.getType() == HiveParser.TOK_SELECTDI) {
        return true;
    }
    for (int i = 0; selectNode != null && i < selectNode.getChildCount(); i++) {
        ASTNode selectExpr = (ASTNode) selectNode.getChild(i);
        //check for QUERY_HINT expressions on ast
        if (selectExpr.getType() != HiveParser.TOK_SELEXPR) {
            continue;
        }
        constantExprCheck.reset();
        PTFTranslator.visit(selectExpr.getChild(0), constantExprCheck);
        if (!constantExprCheck.isConstant()) {
            aggrExprCheck.reset();
            PTFTranslator.visit(selectExpr.getChild(0), aggrExprCheck);
            if (!aggrExprCheck.isAggr()) {
                return false;
            }
        }
    }
    return true;
}
Also used : TreeWizard(org.antlr.runtime.tree.TreeWizard)

Example 3 with TreeWizard

use of org.antlr.runtime.tree.TreeWizard in project SQLWindowing by hbutani.

the class TranslateUtils method unescapeStringLiterals.

public static void unescapeStringLiterals(ASTNode node) {
    TreeWizard tw = new TreeWizard(adaptor, Windowing2Parser.tokenNames);
    tw.visit(node, Windowing2Parser.StringLiteral, new UnescapeStringLiterals());
}
Also used : TreeWizard(org.antlr.runtime.tree.TreeWizard)

Example 4 with TreeWizard

use of org.antlr.runtime.tree.TreeWizard in project SQLWindowing by hbutani.

the class TranslateUtils method validateNoLeadLagInValueBoundarySpec.

public static void validateNoLeadLagInValueBoundarySpec(ASTNode node, String errMsg) throws WindowingException {
    TreeWizard tw = new TreeWizard(adaptor, Windowing2Parser.tokenNames);
    ValidateNoLeadLag visitor = new ValidateNoLeadLag(errMsg);
    tw.visit(node, Windowing2Parser.FUNCTION, visitor);
    visitor.checkValid();
}
Also used : TreeWizard(org.antlr.runtime.tree.TreeWizard)

Example 5 with TreeWizard

use of org.antlr.runtime.tree.TreeWizard in project SQLWindowing by hbutani.

the class TranslateUtils method buildASTNode.

public static ASTNode buildASTNode(String colName) {
    TreeWizard tw = new TreeWizard(adaptor, Windowing2Parser.tokenNames);
    Object o = tw.create(sprintf("(TABLEORCOL Identifier[%s])", colName));
    return (ASTNode) o;
}
Also used : ASTNode(org.apache.hadoop.hive.ql.parse.ASTNode) TreeWizard(org.antlr.runtime.tree.TreeWizard)

Aggregations

TreeWizard (org.antlr.runtime.tree.TreeWizard)5 ASTNode (org.apache.hadoop.hive.ql.parse.ASTNode)1