Examples of OrderSpec


Examples of org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.OrderSpec

     * Partition expressions when the OrderSpec is null; but for now we are setting up
     * an OrderSpec that copies the Partition expressions.
     */
    protected void ensureOrderSpec() {
      if ( getOrder() == null ) {
        OrderSpec order = new OrderSpec();
        order.prefixBy(getPartition());
        setOrder(order);
      }
    }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.OrderSpec

    }

    PartitionedTableFunctionSpec prevFn = (PartitionedTableFunctionSpec) ptfChain.pop();
    applyConstantPartition(prevFn);
    PartitionSpec partSpec = prevFn.getPartition();
    OrderSpec orderSpec = prevFn.getOrder();

    if ( partSpec == null ) {
      //oops this should have been caught before trying to componentize
      throw new SemanticException(
          "No Partitioning specification specified at start of a PTFChain");
    }
    if ( orderSpec == null ) {
      orderSpec = new OrderSpec(partSpec);
      prevFn.setOrder(orderSpec);
    }

    while (!ptfChain.isEmpty()) {
      PartitionedTableFunctionSpec currentFn = (PartitionedTableFunctionSpec) ptfChain.pop();
      String fnName = currentFn.getName();
      if (!FunctionRegistry.isTableFunction(fnName)) {
        throw new SemanticException(ErrorMsg.INVALID_FUNCTION.getMsg(fnName));
      }
      boolean transformsRawInput = FunctionRegistry.getTableFunctionResolver(fnName)
          .transformsRawInput();

      /*
       * if the current table function has no partition info specified: inherit it from the PTF up
       * the chain.
       */
      if (currentFn.getPartition() == null) {
        currentFn.setPartition(prevFn.getPartition());
        if (currentFn.getOrder() == null) {
          currentFn.setOrder(prevFn.getOrder());
        }
      }
      /*
       * If the current table function has no order info specified;
       */
      if (currentFn.getOrder() == null) {
        currentFn.setOrder(new OrderSpec(currentFn.getPartition()));
      }

      if (!currentFn.getPartition().equals(partSpec) ||
          !currentFn.getOrder().equals(orderSpec) ||
          transformsRawInput) {
View Full Code Here

Examples of org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.OrderSpec

    }
    return pSpec;
  }

  private OrderSpec processOrderSpec(ASTNode sortNode) {
    OrderSpec oSpec = new OrderSpec();
    int exprCnt = sortNode.getChildCount();
    for(int i=0; i < exprCnt; i++) {
      OrderExpression exprSpec = new OrderExpression();
      exprSpec.setExpression((ASTNode) sortNode.getChild(i).getChild(0));
      if ( sortNode.getChild(i).getType() == HiveParser.TOK_TABSORTCOLNAMEASC ) {
        exprSpec.setOrder(org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.Order.ASC);
      }
      else {
        exprSpec.setOrder(org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.Order.DESC);
      }
      oSpec.addExpression(exprSpec);
    }
    return oSpec;
  }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.OrderSpec

      PartitionSpec pSpec = processPartitionSpec(firstChild);
      partitioning.setPartSpec(pSpec);
      ASTNode sortNode = pSpecNode.getChildCount() > 1 ? (ASTNode) pSpecNode.getChild(1) : null;
      if ( sortNode != null )
      {
        OrderSpec oSpec = processOrderSpec(sortNode);
        partitioning.setOrderSpec(oSpec);
      }
    }
    else if ( type == HiveParser.TOK_SORTBY || type == HiveParser.TOK_ORDERBY ) {
      ASTNode sortNode = firstChild;
      OrderSpec oSpec = processOrderSpec(sortNode);
      partitioning.setOrderSpec(oSpec);
    }
    return partitioning;
  }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.OrderSpec

  }

  private WindowSpec processWindowSpec(ASTNode node) throws SemanticException {
    String sourceId = null;
    PartitionSpec partition = null;
    OrderSpec order = null;
    WindowFrameSpec windowFrame = null;

    boolean hasSrcId = false, hasPartSpec = false, hasWF = false;
    int srcIdIdx = -1, partIdx = -1, wfIdx = -1;
View Full Code Here

Examples of xbird.xquery.expr.flwr.OrderSpec

                buf.append("order by");
            } else {
                buf.append(',');
            }
            indentln();
            OrderSpec spec = (OrderSpec) orders.get(i);
            spec.getKeyExpr().visit(this, ctxt);
            indent--;
            if(spec.isDescending()) {
                buf.append(" descending");
            }
            if(spec.isEmptyGreatest()) {
                buf.append(" empty greatest");
            }
            URI collation = spec.getCollation();
            if(collation != null) {
                buf.append(" collation ");
                buf.append(collation.toString());
            }
        }
View Full Code Here

Examples of xbird.xquery.expr.flwr.OrderSpec

                final IFocus<? extends Item> itor = src.iterator();
                for(Item it : itor) {
                    final Comparable[] tuple = new Comparable[keylen + 1];
                    tuple[0] = it;
                    for(int i = 0; i < keylen; i++) {
                        final OrderSpec key = oderSpecs.get(i);
                        final Sequence<? extends Item> keyval = key.getKeyExpr().eval(contextSeq, dynEnv);
                        if(keyval.isEmpty()) {
                            tuple[i + 1] = null;
                        } else {
                            final Sequence<? extends Item> atomized = keyval.atomize(dynEnv);
                            final Item keyitem = SingleCollection.wrap(atomized, dynEnv);
View Full Code Here

Examples of xbird.xquery.expr.flwr.OrderSpec

                final int cmp;
                final int keyidx = i + 1;
                if(o1[keyidx] instanceof Item) {
                    final Item it1 = (Item) o1[keyidx];
                    final Item it2 = (Item) o2[keyidx];
                    final OrderSpec spec = orderSpecs.get(i);
                    cmp = spec.compare(it1, it2, dynEnv);
                } else {
                    final OrderSpec spec = orderSpecs.get(i);
                    cmp = spec.compare(o1[keyidx], o2[keyidx]);
                }
                if(cmp != 0) {
                    return cmp;
                }
            }
View Full Code Here

Examples of xbird.xquery.expr.flwr.OrderSpec

    ************************************************************************/
    final public XQExpression parseFLWRExpr() throws ParseException, XQueryException {
        final FLWRExpr flower = new FLWRExpr();
        List<Binding> bindings = null;
        XQExpression whereExpr = null;
        OrderSpec order = null;
        XQExpression returnExpr = null;
        currentModule.pushVarScope();
        locate(flower);
        label_7: while(true) {
            switch(jj_nt.kind) {
View Full Code Here

Examples of xbird.xquery.expr.flwr.OrderSpec

    /************************************************************************
    [40] OrderSpec      ::=  ExprSingle OrderModifier
    [41] OrderModifier ::= ("ascending" | "descending")? (<"empty" "greatest"> | <"empty" "least">)? ("collation" URILiteral)?
    ************************************************************************/
    final public OrderSpec parseOrderSpec() throws ParseException, XQueryException {
        final OrderSpec spec;
        final XQExpression keyExpr;
        String collation = null;
        keyExpr = parseExprSingle();
        spec = new OrderSpec(keyExpr);
        locate(spec);
        switch(jj_nt.kind) {
            case Ascending:
            case Descending:
                switch(jj_nt.kind) {
                    case Ascending:
                        currentToken = jj_consume_token(Ascending);
                        break;
                    case Descending:
                        currentToken = jj_consume_token(Descending);
                        spec.setDescending(true);
                        break;
                    default:
                        jj_la1[78] = jj_gen;
                        jj_consume_token(-1);
                        throw new ParseException();
                }
                break;
            default:
                jj_la1[79] = jj_gen;
                ;
        }
        switch(jj_nt.kind) {
            case EmptyGreatest:
            case EmptyLeast:
                switch(jj_nt.kind) {
                    case EmptyGreatest:
                        currentToken = jj_consume_token(EmptyGreatest);
                        spec.setEmptyGreatest(true);
                        break;
                    case EmptyLeast:
                        currentToken = jj_consume_token(EmptyLeast);
                        break;
                    default:
                        jj_la1[80] = jj_gen;
                        jj_consume_token(-1);
                        throw new ParseException();
                }
                break;
            default:
                jj_la1[81] = jj_gen;
                ;
        }
        switch(jj_nt.kind) {
            case Collation:
                currentToken = jj_consume_token(Collation);
                currentToken = jj_consume_token(URILiteralToOperator);
                collation = unquote(currentToken.image);
                if(collation != null) {
                    try {
                        URI url = new URI(collation);
                        spec.setCollation(url);
                    } catch (URISyntaxException e) {
                        error("err:XQST0046");
                    }
                }
                break;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.