Package org.apache.hadoop.hive.ql.plan

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


      assert (idx == 0);

      ExprNodeDesc newnd = null;
      if (unknown) {
        newnd = new ExprNodeConstantDesc(fnd.getTypeInfo(), null);
      } else {
        newnd = new ExprNodeFieldDesc(fnd.getTypeInfo(), left_nd, fnd
            .getFieldName(), fnd.getIsList());
      }
      return newnd;
View Full Code Here


    }

    ExprNodeDesc child1 = (ExprNodeDesc) nodeOutputs[0];
    ExprNodeDesc child2 = (ExprNodeDesc) nodeOutputs[1];
    ExprNodeColumnDesc columnDesc = null;
    ExprNodeConstantDesc constantDesc = null;
    if ((child1 instanceof ExprNodeColumnDesc)
      && (child2 instanceof ExprNodeConstantDesc)) {
      // COL <op> CONSTANT
      columnDesc = (ExprNodeColumnDesc) child1;
      constantDesc = (ExprNodeConstantDesc) child2;
View Full Code Here

        // do nothing here, we will throw an exception in the following block
      }
      if (v == null) {
        throw new SemanticException(ErrorMsg.INVALID_NUMERICAL_CONSTANT.getMsg(expr));
      }
      return new exprNodeConstantDesc(v);
    }
View Full Code Here

      default:
        // HiveParser.identifier | HiveParse.KW_IF | HiveParse.KW_LEFT | HiveParse.KW_RIGHT
        str = BaseSemanticAnalyzer.unescapeIdentifier(expr.getText());
        break;
      }
      return new exprNodeConstantDesc(String.class, str);
    }
View Full Code Here

        bool = Boolean.FALSE;
        break;
      default:
        assert false;
      }
      return new exprNodeConstantDesc(Boolean.class, bool);     
    }
View Full Code Here

      for (int i = 0; i < children.size(); i++)
      {
        exprNodeDesc desc = children.get(i);
        Class<?> pType = ObjectInspectorUtils.generalizePrimitive(pTypes[i]);
        if (desc instanceof exprNodeNullDesc) {
          exprNodeConstantDesc newCh = new exprNodeConstantDesc(TypeInfoFactory.getPrimitiveTypeInfo(pType), null);
          ch.add(newCh);
        } else if (pType.isAssignableFrom(argumentClasses.get(i))) {
          // no type conversion needed
          ch.add(desc);
        } else {
View Full Code Here

        // "." :  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) {
View Full Code Here

        } 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);
       
        if (desc instanceof exprNodeFuncDesc && (
            ((exprNodeFuncDesc)desc).getUDFMethod().getDeclaringClass().equals(UDFOPAnd.class)
            || ((exprNodeFuncDesc)desc).getUDFMethod().getDeclaringClass().equals(UDFOPOr.class)
            || ((exprNodeFuncDesc)desc).getUDFMethod().getDeclaringClass().equals(UDFOPNot.class))) {
          // do nothing because "And" and "Or" and "Not" supports null value evaluation
          // NOTE: In the future all UDFs that treats null value as UNKNOWN (both in parameters and return
          // values) should derive from a common base class UDFNullAsUnknown, so instead of listing the classes
          // here we would test whether a class is derived from that base class.
        } else if ((desc instanceof exprNodeFuncDesc &&
            ((exprNodeFuncDesc)desc).getUDFClass().getAnnotation(UDFType.class) != null &&
            ((exprNodeFuncDesc)desc).getUDFClass().getAnnotation(UDFType.class).deterministic() == false) ||
            mightBeUnknown(desc)) {
           // If its a non-deterministic UDF or if any child is null, set this node to null
          LOG.trace("Pruner function might be unknown: " + expr.toStringTree());
          desc = new exprNodeConstantDesc(desc.getTypeInfo(), null);   
        }
        break;
      }
    }
    return desc;
View Full Code Here

    return desc;
 
 
  public static boolean mightBeUnknown(exprNodeDesc desc) {
    if (desc instanceof exprNodeConstantDesc) {
      exprNodeConstantDesc d = (exprNodeConstantDesc)desc;
      return d.getValue() == null;
    } else if (desc instanceof exprNodeNullDesc) {
      return false;
    } else if (desc instanceof exprNodeIndexDesc) {
      exprNodeIndexDesc d = (exprNodeIndexDesc)desc;
      return mightBeUnknown(d.getDesc()) || mightBeUnknown(d.getIndex());
    } else if (desc instanceof exprNodeFieldDesc) {
      exprNodeFieldDesc d = (exprNodeFieldDesc)desc;
      return mightBeUnknown(d.getDesc());
    } else if (desc instanceof exprNodeFuncDesc) {
      exprNodeFuncDesc d = (exprNodeFuncDesc)desc;
      for(int i=0; i<d.getChildren().size(); i++) {
        if (mightBeUnknown(d.getChildren().get(i))) {
          return true;
        }
      }
      return false;
    } else if (desc instanceof exprNodeColumnDesc) {
View Full Code Here

  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();
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc

Copyright © 2018 www.massapicom. 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.