public static SubQueryType get(ASTNode opNode) throws SemanticException { if(opNode == null) { return SCALAR; } switch(opNode.getType()) { // opNode's type is always either KW_EXISTS or KW_IN never NOTEXISTS or NOTIN // to figure this out we need to check it's grand parent's parent case HiveParser.KW_EXISTS: if(opNode.getParent().getParent().getParent() != null && opNode.getParent().getParent().getParent().getType() == HiveParser.KW_NOT) { return NOT_EXISTS; } return EXISTS; case HiveParser.TOK_SUBQUERY_OP_NOTEXISTS: return NOT_EXISTS; case HiveParser.KW_IN: if(opNode.getParent().getParent().getParent() != null && opNode.getParent().getParent().getParent().getType() == HiveParser.KW_NOT) { return NOT_IN; } return IN; case HiveParser.TOK_SUBQUERY_OP_NOTIN: return NOT_IN; default: throw new SemanticException(SemanticAnalyzer.generateErrorMessage(opNode, "Operator not supported in SubQuery use.")); } } }
public static SubQueryType get(ASTNode opNode) throws SemanticException { if(opNode == null) { return SCALAR; } switch(opNode.getType()) { // opNode's type is always either KW_EXISTS or KW_IN never NOTEXISTS or NOTIN // to figure this out we need to check it's grand parent's parent case HiveParser.KW_EXISTS: if(opNode.getParent().getParent().getParent() != null && opNode.getParent().getParent().getParent().getType() == HiveParser.KW_NOT) { return NOT_EXISTS; } return EXISTS; case HiveParser.TOK_SUBQUERY_OP_NOTEXISTS: return NOT_EXISTS; case HiveParser.KW_IN: if(opNode.getParent().getParent().getParent() != null && opNode.getParent().getParent().getParent().getType() == HiveParser.KW_NOT) { return NOT_IN; } return IN; case HiveParser.TOK_SUBQUERY_OP_NOTIN: return NOT_IN; default: throw new SemanticException(SemanticAnalyzer.generateErrorMessage(opNode, "Operator not supported in SubQuery use.")); } } }
@Override public Object getParent(Object t) { if ( t==null ) return null; return ((Tree)t).getParent(); }
@Override public Object getParent(Object t) { if ( t==null ) return null; return ((Tree)t).getParent(); }
@Override public Object getParent(Object t) { if ( t==null ) return null; return ((Tree)t).getParent(); }
@Override public Object getParent(Object t) { if ( t==null ) return null; return ((Tree)t).getParent(); }
@Override public Object getParent(Object t) { if ( t==null ) return null; return ((Tree)t).getParent(); }
public Object getParent(Object t) { if ( t==null ) return null; return ((Tree)t).getParent(); }
static void traverse(Tree t, List<CommonTree> macroNodes, List<CommonTree> inlineNodes) { if (t.getText().equals(MACRO_DEF)) { macroNodes.add((CommonTree) t.getParent()); } else if (t.getText().equals(MACRO_INLINE)) { inlineNodes.add((CommonTree) t); } int n = t.getChildCount(); for (int i = 0; i < n; i++) { Tree t0 = t.getChild(i); traverse(t0, macroNodes, inlineNodes); } }
private String getArgumentTypes(Tree nameNode) { Tree typeNode = nameNode.getParent().getChild(nameNode.getChildIndex() + 1); if (typeNode.getChildCount() > 0) { return typeNode.getChild(0).getText(); } return UNTYPED_PARAMETER_NAME; }
private int extractLine(Tree currentCodeNode) { Tree parent = currentCodeNode.getParent(); for (int i = currentCodeNode.getChildIndex() - 1; i >= 0; i--) { Tree child = parent.getChild(i); if (child.getType() == DelphiLexer.FUNCTION || child.getType() == DelphiLexer.PROCEDURE || child.getType() == DelphiLexer.CONSTRUCTOR || child.getType() == DelphiLexer.DESTRUCTOR || child.getType() == DelphiLexer.OPERATOR) { return child.getLine(); } } return -1; }
private void addCubeNameAndAlias(ASTNode ast, Cube innerCube) { ASTNode cubeNameNode = findCubeNameNode(HQLParser.findNodeByPath(ast, TOK_FROM)); assert cubeNameNode != null; ASTNode tabrefNode = (ASTNode) cubeNameNode.getParent().getParent(); cubeNameNode.getToken().setText(innerCube.getName()); ASTNode aliasNode = new ASTNode(new CommonToken(Identifier, getCubeQueryContext().getAliasForTableName(getCube().getName()))); if (tabrefNode.getChildCount() > 1) { tabrefNode.setChild(1, aliasNode); } else { tabrefNode.addChild(aliasNode); } }
private void addCubeNameAndAlias(ASTNode ast, Cube innerCube) { ASTNode cubeNameNode = findCubeNameNode(HQLParser.findNodeByPath(ast, TOK_FROM)); assert cubeNameNode != null; ASTNode tabrefNode = (ASTNode) cubeNameNode.getParent().getParent(); cubeNameNode.getToken().setText(innerCube.getName()); ASTNode aliasNode = new ASTNode(new CommonToken(Identifier, getCubeQueryContext().getAliasForTableName(getCube().getName()))); if (tabrefNode.getChildCount() > 1) { tabrefNode.setChild(1, aliasNode); } else { tabrefNode.addChild(aliasNode); } }