Examples of exprNodeDesc


Examples of org.apache.hadoop.hive.ql.plan.exprNodeDesc

        assert(children.size() == 1);
        assert(children.get(0) != null);
        return children.get(0);
      }
      String funcText = getFunctionText(expr, isFunction);
      exprNodeDesc desc;
      if (funcText.equals(".")) {
        // "." :  FIELD Expression
        assert(children.size() == 2);
        // Only allow constant field name for now
        assert(children.get(1) instanceof exprNodeConstantDesc);
        exprNodeDesc object = children.get(0);
        exprNodeConstantDesc fieldName = (exprNodeConstantDesc)children.get(1);
        assert(fieldName.getValue() instanceof String);
       
        // Calculate result TypeInfo
        String fieldNameString = (String)fieldName.getValue();
        TypeInfo objectTypeInfo = object.getTypeInfo();
       
        // Allow accessing a field of list element structs directly from a list 
        boolean isList = (object.getTypeInfo().getCategory() == ObjectInspector.Category.LIST);
        if (isList) {
          objectTypeInfo = objectTypeInfo.getListElementTypeInfo();
        }
        if (objectTypeInfo.getCategory() != Category.STRUCT) {
          throw new SemanticException(ErrorMsg.INVALID_DOT.getMsg(expr));
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.exprNodeDesc

          expr.getToken().getType() == HiveParser.CharSetName ||
          expr.getToken().getType() == HiveParser.CharSetLiteral) {
        return null;
      }
     
      exprNodeDesc desc = TypeCheckProcFactory.processGByExpr(nd, procCtx);
      if (desc != null) {
        return desc;
      }

      boolean isFunction = (expr.getType() == HiveParser.TOK_FUNCTION);
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.exprNodeDesc

    //  We recursively create the exprNodeDesc.  Base cases:  when we encounter
    //  a column ref, we convert that into an exprNodeColumnDesc;  when we encounter
    //  a constant, we convert that into an exprNodeConstantDesc.  For others we just
    //  build the exprNodeFuncDesc with recursively built children.

    exprNodeDesc desc = null;

    //  Is this a simple expr node (not a TOK_COLREF or a TOK_FUNCTION or an operator)?
    desc = SemanticAnalyzer.genSimpleExprNodeDesc(expr);
    if (desc != null) {
      return desc;
    }

    int tokType = expr.getType();
    switch (tokType) {
      case HiveParser.TOK_COLREF: {

        String tabAlias = null;
        String colName = null;
        if (expr.getChildCount() != 1) {
          assert(expr.getChildCount() == 2);
          tabAlias = BaseSemanticAnalyzer.unescapeIdentifier(expr.getChild(0).getText());
          colName = BaseSemanticAnalyzer.unescapeIdentifier(expr.getChild(1).getText());
        }
        else {
          colName = BaseSemanticAnalyzer.unescapeIdentifier(expr.getChild(0).getText());
          tabAlias = SemanticAnalyzer.getTabAliasForCol(this.metaData, colName, (ASTNode)expr.getChild(0));
        }

        // Set value to null if it's not partition column
        if (tabAlias.equalsIgnoreCase(tableAlias) && tab.isPartitionKey(colName)) {
          desc = new exprNodeColumnDesc(String.class, colName);
        } else {
          try {
            // might be a column from another table
            Table t = this.metaData.getTableForAlias(tabAlias);
            if (t.isPartitionKey(colName)) {
              desc = new exprNodeConstantDesc(String.class, null);
            }
            else {
              TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(
                                                                               this.metaData.getTableForAlias(tabAlias).getDeserializer().getObjectInspector());
              desc = new exprNodeConstantDesc(typeInfo.getStructFieldTypeInfo(colName), null);
              containsPartCols = false;
            }
          } catch (SerDeException e){
            throw new RuntimeException(e);
          }
        }
        break;
      }

      default: {
        boolean isFunction = (expr.getType() == HiveParser.TOK_FUNCTION);
       
        // Create all children
        int childrenBegin = (isFunction ? 1 : 0);
        ArrayList<exprNodeDesc> children = new ArrayList<exprNodeDesc>(expr.getChildCount() - childrenBegin);
        for (int ci=childrenBegin; ci<expr.getChildCount(); ci++) {
          exprNodeDesc child = genExprNodeDesc((ASTNode)expr.getChild(ci));
          assert(child.getTypeInfo() != null);
          children.add(child);
        }

        // Create function desc
        desc = TypeCheckProcFactory.DefaultExprProcessor.getXpathOrFuncExprNodeDesc(expr, isFunction, children);
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.exprNodeDesc

  /** Add an expression */
  @SuppressWarnings("nls")
  public void addExpression(ASTNode expr) throws SemanticException {
    LOG.trace("adding pruning Tree = " + expr.toStringTree());
    exprNodeDesc desc = genExprNodeDesc(expr);
    // Ignore null constant expressions
    if (!(desc instanceof exprNodeConstantDesc) || ((exprNodeConstantDesc)desc).getValue() != null ) {
      LOG.trace("adding pruning expr = " + desc);
      if (this.prunerExpr == null)
        this.prunerExpr = desc;
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.exprNodeDesc

   * condition.
   */
  @SuppressWarnings("nls")
  public void addJoinOnExpression(ASTNode expr) throws SemanticException {
    LOG.trace("adding pruning Tree = " + expr.toStringTree());
    exprNodeDesc desc = genExprNodeDesc(expr);
    // Ignore null constant expressions
    if (!(desc instanceof exprNodeConstantDesc) || ((exprNodeConstantDesc)desc).getValue() != null ) {
      LOG.trace("adding pruning expr = " + desc);
      if (this.prunerExpr == null)
        this.prunerExpr = desc;
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.exprNodeDesc

    selectDesc conf = op.getConf();
    ArrayList<exprNodeDesc> selectExprs = conf.getColList();

    for (String col : colList) {
      // col is the internal name i.e. position within the expression list
      exprNodeDesc expr = selectExprs.get(Integer.parseInt(col));
      cols = Utilities.mergeUniqElems(cols, expr.getCols());
    }
    return cols;
  }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.exprNodeDesc

  }

  public void testExprNodeColumnEvaluator() throws Throwable {
    try {
      // get a evaluator for a simple field expression
      exprNodeDesc exprDesc = new exprNodeColumnDesc(colaType, "cola");
      ExprNodeEvaluator eval = ExprNodeEvaluatorFactory.get(exprDesc);

      // evaluate on row
      InspectableObject result = new InspectableObject();
      eval.evaluate(r.o, r.oi, result);
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.exprNodeDesc

  }

  public void testExprNodeFuncEvaluator() throws Throwable {
    try {
      // get a evaluator for a string concatenation expression
      exprNodeDesc col1desc = new exprNodeColumnDesc(col1Type, "col1");
      exprNodeDesc coladesc = new exprNodeColumnDesc(colaType, "cola");
      exprNodeDesc col11desc = new exprNodeIndexDesc(col1desc, new exprNodeConstantDesc(new Integer(1)));
      exprNodeDesc cola0desc = new exprNodeIndexDesc(coladesc, new exprNodeConstantDesc(new Integer(0)));
      exprNodeDesc func1 = TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("concat", col11desc, cola0desc);
      ExprNodeEvaluator eval = ExprNodeEvaluatorFactory.get(func1);

      // evaluate on row
      InspectableObject result = new InspectableObject();
      eval.evaluate(r.o, r.oi, result);
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.exprNodeDesc

  }

  public void testExprNodeConversionEvaluator() throws Throwable {
    try {
      // get a evaluator for a string concatenation expression
      exprNodeDesc col1desc = new exprNodeColumnDesc(col1Type, "col1");
      exprNodeDesc col11desc = new exprNodeIndexDesc(col1desc, new exprNodeConstantDesc(new Integer(1)));
      exprNodeDesc func1 = TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc(Double.class.getName(), col11desc);
      ExprNodeEvaluator eval = ExprNodeEvaluatorFactory.get(func1);

      // evaluate on row
      InspectableObject result = new InspectableObject();
      eval.evaluate(r.o, r.oi, result);
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.exprNodeDesc

                        new exprNodeConstantDesc("2")),
                    new exprNodeConstantDesc("3")),
                new exprNodeConstantDesc("4"))),
          r,
          "1234");
      exprNodeDesc constant1 = new exprNodeConstantDesc(1);
      exprNodeDesc constant2 = new exprNodeConstantDesc(2);
      measureSpeed("concat(col1[1], cola[1])",
          basetimes * 10,
          ExprNodeEvaluatorFactory.get(
              TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("concat",
                  new exprNodeIndexDesc(new exprNodeColumnDesc(col1Type, "col1"), constant1),
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.