private void addCTEAsSubQuery(QB qb, String cteName, String cteAlias) throws SemanticException { cteAlias = cteAlias == null ? cteName : cteAlias; CTEClause cte = findCTEFromName(qb, cteName); ASTNode cteQryNode = cte.cteNode; QBExpr cteQBExpr = new QBExpr(cteAlias); doPhase1QBExpr(cteQryNode, cteQBExpr, qb.getId(), cteAlias); qb.rewriteCTEToSubq(cteAlias, cteName, cteQBExpr); }
public OrderSpec(PartitionSpec pSpec) { for(PartitionExpression peSpec : pSpec.getExpressions()) { addExpression(new OrderExpression(peSpec)); } }
private PartitionSpec processPartitionSpec(ASTNode node) { PartitionSpec pSpec = new PartitionSpec(); int exprCnt = node.getChildCount(); for(int i=0; i < exprCnt; i++) { PartitionExpression exprSpec = new PartitionExpression(); exprSpec.setExpression((ASTNode) node.getChild(i)); pSpec.addExpression(exprSpec); } return pSpec; }
private void processQueryWindowClause(WindowingSpec spec, ASTNode node) throws SemanticException { ASTNode nameNode = (ASTNode) node.getChild(0); ASTNode wsNode = (ASTNode) node.getChild(1); if(spec.getWindowSpecs() != null && spec.getWindowSpecs().containsKey(nameNode.getText())){ throw new SemanticException(generateErrorMessage(nameNode, "Duplicate definition of window " + nameNode.getText() + " is not allowed")); } WindowSpec ws = processWindowSpec(wsNode); spec.addWindowSpec(nameNode.getText(), ws); }
private void handleQueryWindowClauses(QB qb, Phase1Ctx ctx_1, ASTNode node) throws SemanticException { WindowingSpec spec = qb.getWindowingSpec(ctx_1.dest); for(int i=0; i < node.getChildCount(); i++) { processQueryWindowClause(spec, (ASTNode) node.getChild(i)); } }
private Operator genPlan(QB parent, QBExpr qbexpr) throws SemanticException { if (qbexpr.getOpcode() == QBExpr.Opcode.NULLOP) { boolean skipAmbiguityCheck = viewSelect == null && parent.isTopLevelSelectStarQuery(); return genPlan(qbexpr.getQB(), skipAmbiguityCheck); } if (qbexpr.getOpcode() == QBExpr.Opcode.UNION) { Operator qbexpr1Ops = genPlan(parent, qbexpr.getQBExpr1()); Operator qbexpr2Ops = genPlan(parent, qbexpr.getQBExpr2()); return genUnionPlan(qbexpr.getAlias(), qbexpr.getQBExpr1().getAlias(), qbexpr1Ops, qbexpr.getQBExpr2().getAlias(), qbexpr2Ops); } return null; }
private void applyConstantPartition(WindowSpec wdwSpec) { PartitionSpec partSpec = wdwSpec.getPartition(); if ( partSpec == null ) { partSpec = new PartitionSpec(); PartitionExpression partExpr = new PartitionExpression(); partExpr.setExpression(new ASTNode(new CommonToken(HiveParser.Number, "0"))); partSpec.addExpression(partExpr); wdwSpec.setPartition(partSpec); } }
private Operator genPlanForSubQueryPredicate( QB qbSQ, ISubQueryJoinInfo subQueryPredicate) throws SemanticException { qbSQ.setSubQueryDef(subQueryPredicate.getSubQuery()); Phase1Ctx ctx_1 = initPhase1Ctx(); doPhase1(subQueryPredicate.getSubQueryAST(), qbSQ, ctx_1, null); getMetaData(qbSQ); Operator op = genPlan(qbSQ); return op; }
static SubQueryTypeDef buildSQOperator(ASTNode astSQOp) throws SemanticException { ASTNode opAST = (ASTNode) astSQOp.getChild(0); SubQueryType type = SubQueryType.get(opAST); return new SubQueryTypeDef(opAST, type); }
private void processPTF(QB qb, ASTNode ptf) throws SemanticException{ PartitionedTableFunctionSpec ptfSpec = processPTFChain(qb, ptf); if ( ptfSpec.getAlias() != null ) { qb.addAlias(ptfSpec.getAlias()); } PTFInvocationSpec spec = new PTFInvocationSpec(); spec.setFunction(ptfSpec); qb.addPTFNodeToSpec(ptf, spec); }
public ASTNode getOriginalSubQueryASTForRewrite() { return (operator.getType() == SubQueryType.NOT_EXISTS || operator.getType() == SubQueryType.NOT_IN ? (ASTNode) originalSQASTOrigin.getUsageNode().getParent() : originalSQASTOrigin.getUsageNode()); }
private void setupSelectListInputInfo() throws SemanticException { selectListInputTypeCheckCtx = new TypeCheckCtx(selectListInputRowResolver); selectListInputTypeCheckCtx.setUnparseTranslator(null); /* * create SelectListOI */ selectListInputOI = PTFTranslator.getStandardStructOI(selectListInputRowResolver); }
public ExprNodeDesc genExprNodeDesc(ASTNode expr, RowResolver input, boolean useCaching, boolean foldExpr) throws SemanticException { TypeCheckCtx tcCtx = new TypeCheckCtx(input, useCaching, foldExpr); return genExprNodeDesc(expr, input, tcCtx); }
private void validateSelectExpr() throws SemanticException { for (WindowExpressionSpec expr : selectSpec) { PTFTranslator.validateNoLeadLagInValueBoundarySpec(expr.getExpression()); } }
public ASTNode getJoinConditionAST() { ASTNode ast = SubQueryUtils.buildNotInNullJoinCond(getAlias(), CNT_ALIAS); return ast; }
@Override public List<Task<?>> getAllRootTasks() { if (!rootTasksResolved) { rootTasks = toRealRootTasks(rootClause.asExecutionOrder()); rootTasksResolved = true; } return rootTasks; }