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

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


    @Override
    public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
        Object... nodeOutputs) throws SemanticException {

      exprNodeDesc newfd = null;
      exprNodeGenericFuncDesc fd = (exprNodeGenericFuncDesc) nd;

      boolean unknown = false;
     
      if (FunctionRegistry.isOpAndOrNot(fd)) {
        // 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 (!FunctionRegistry.isDeterministic(fd.getGenericUDF())) {
        // If it's a non-deterministic UDF, set unknown to true
        unknown = true;
      } else {
        // If any child is null, set unknown to true
        for(Object child: nodeOutputs) {
          exprNodeDesc child_nd = (exprNodeDesc)child;
          if (child_nd instanceof exprNodeConstantDesc &&
              ((exprNodeConstantDesc)child_nd).getValue() == null) {
            unknown = true;
          }
        }
      }
     
      if (unknown)
        newfd = new exprNodeConstantDesc(fd.getTypeInfo(), null);
      else {
        // Create the list of children
        ArrayList<exprNodeDesc> children = new ArrayList<exprNodeDesc>();
        for(Object child: nodeOutputs) {
          children.add((exprNodeDesc) child);
        }
        // Create a copy of the function descriptor
        newfd = new exprNodeGenericFuncDesc(fd.getTypeInfo(), fd.getGenericUDF(), children);
      }
     
      return newfd;
    }
View Full Code Here


          // nothing
        } else if (node instanceof exprNodeFieldDesc) {
          groupByKeys.add(0, ((exprNodeFieldDesc) node).getDesc());
          continue;
        } else if (node instanceof exprNodeGenericFuncDesc) {
          exprNodeGenericFuncDesc udfNode = ((exprNodeGenericFuncDesc)node);
          GenericUDF udf = udfNode.getGenericUDF();
          if(!FunctionRegistry.isDeterministic(udf))
            return;
          groupByKeys.addAll(0, udfNode.getChildExprs());
        } else {
          return;
        }
      }
     
View Full Code Here

      }
    }

    exprNodeDesc equalsExpr = null;
    {
      exprNodeDesc hashfnExpr = new exprNodeGenericFuncDesc(TypeInfoFactory.intTypeInfo,
          new GenericUDFHash(), args);
      assert(hashfnExpr != null);
      LOG.info("hashfnExpr = " + hashfnExpr);
      exprNodeDesc andExpr = TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("&", hashfnExpr, intMaxExpr);
      assert(andExpr != null);
View Full Code Here

 
  private static exprNodeDesc getListIndexNode(exprNodeDesc node, exprNodeDesc index) {
    ArrayList<exprNodeDesc> children = new ArrayList<exprNodeDesc>(2);
    children.add(node);
    children.add(index);
    return new exprNodeGenericFuncDesc(
          ((ListTypeInfo)node.getTypeInfo()).getListElementTypeInfo(),
          FunctionRegistry.getGenericUDFForIndex(),
          children);
  }
View Full Code Here


  private filterDesc getTestFilterDesc(String column) {
    ArrayList<exprNodeDesc> children1 = new ArrayList<exprNodeDesc>();
    children1.add(new exprNodeColumnDesc(TypeInfoFactory.stringTypeInfo, column, "", false));
    exprNodeDesc lhs = new exprNodeGenericFuncDesc(
        TypeInfoFactory.doubleTypeInfo,
        FunctionRegistry.getFunctionInfo(Constants.DOUBLE_TYPE_NAME).getGenericUDF(),
        children1);
   
    ArrayList<exprNodeDesc> children2 = new ArrayList<exprNodeDesc>();
    children2.add(new exprNodeConstantDesc(TypeInfoFactory.longTypeInfo, Long.valueOf(100)));
    exprNodeDesc rhs = new exprNodeGenericFuncDesc(
        TypeInfoFactory.doubleTypeInfo,
        FunctionRegistry.getFunctionInfo(Constants.DOUBLE_TYPE_NAME).getGenericUDF(),
        children2);
   
    ArrayList<exprNodeDesc> children3 = new ArrayList<exprNodeDesc>();
    children3.add(lhs);
    children3.add(rhs);
   
    exprNodeDesc desc = new exprNodeGenericFuncDesc(
        TypeInfoFactory.booleanTypeInfo,
        FunctionRegistry.getFunctionInfo("<").getGenericUDF(),
        children3);
   
    return new filterDesc(desc, false);
View Full Code Here

  private static exprNodeDesc getListIndexNode(exprNodeDesc node, int index) {
    return getListIndexNode(node, new exprNodeConstantDesc(index));
  }
 
  private static exprNodeDesc getListIndexNode(exprNodeDesc node, exprNodeDesc index) {
    return new exprNodeGenericFuncDesc(
          ((ListTypeInfo)node.getTypeInfo()).getListElementTypeInfo(),
          FunctionRegistry.getGenericUDFClassForIndex(),
          Arrays.asList(new exprNodeDesc[]{node, index}));
  }
View Full Code Here

    @Override
    public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
        Object... nodeOutputs) throws SemanticException {

      exprNodeDesc newfd = null;
      exprNodeGenericFuncDesc fd = (exprNodeGenericFuncDesc) nd;

      boolean unknown = false;
      // Check if any of the children is unknown
      for(Object child: nodeOutputs) {
        exprNodeDesc child_nd = (exprNodeDesc)child;
        if (child_nd instanceof exprNodeConstantDesc &&
            ((exprNodeConstantDesc)child_nd).getValue() == null) {
          unknown = true;
        }
      }
     
      if (unknown)
        newfd = new exprNodeConstantDesc(fd.getTypeInfo(), null);
      else {
        // Create the list of children
        ArrayList<exprNodeDesc> children = new ArrayList<exprNodeDesc>();
        for(Object child: nodeOutputs) {
          children.add((exprNodeDesc) child);
        }
        // Create a copy of the function descriptor
        newfd = new exprNodeGenericFuncDesc(fd.getTypeInfo(), fd.getGenericUDFClass(), children);
      }
     
      return newfd;
    }
View Full Code Here

          return true;
        }
      }
      return false;
    } else if (desc instanceof exprNodeGenericFuncDesc) {
      exprNodeGenericFuncDesc d = (exprNodeGenericFuncDesc)desc;
      for(int i=0; i<d.getChildren().size(); i++) {
        if (mightBeUnknown(d.getChildExprs().get(i))) {
          return true;
        }
      }
      return false;
    } else if (desc instanceof exprNodeColumnDesc) {
View Full Code Here

            throw new SemanticException(ErrorMsg.INVALID_ARRAYINDEX_CONSTANT.getMsg(expr));
          }
       
          // Calculate TypeInfo
          TypeInfo t = ((ListTypeInfo)myt).getListElementTypeInfo();
          desc = new exprNodeGenericFuncDesc(t,
              FunctionRegistry.getGenericUDFClassForIndex(),
              children);
        }
        else if (myt.getCategory() == Category.MAP) {
          // Only allow only constant indexes for now
          if (!(children.get(1) instanceof exprNodeConstantDesc)) {
            throw new SemanticException(ErrorMsg.INVALID_MAPINDEX_CONSTANT.getMsg(expr));
          }
          if (!(((exprNodeConstantDesc)children.get(1)).getTypeInfo().equals(
              ((MapTypeInfo)myt).getMapKeyTypeInfo()))) {
            throw new SemanticException(ErrorMsg.INVALID_MAPINDEX_TYPE.getMsg(expr));
          }
          // Calculate TypeInfo
          TypeInfo t = ((MapTypeInfo)myt).getMapValueTypeInfo();
          desc = new exprNodeGenericFuncDesc(t,
              FunctionRegistry.getGenericUDFClassForIndex(),
              children);
        }
        else {
          throw new SemanticException(ErrorMsg.NON_COLLECTION_TYPE.getMsg(expr,
View Full Code Here

    @Override
    public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
        Object... nodeOutputs) throws SemanticException {
      ExprWalkerInfo ctx = (ExprWalkerInfo) procCtx;
      String alias = null;
      exprNodeGenericFuncDesc expr = (exprNodeGenericFuncDesc) nd;

      UDFType note = expr.getGenericUDFClass().getAnnotation(UDFType.class);
      if(note != null && !note.deterministic()) {
        // this GenericUDF can't be pushed down
        ctx.setIsCandidate(expr, false);
        ctx.setDeterministic(false);
        return false;
      }
     
      boolean isCandidate = true;
      for (int i=0; i < nd.getChildren().size(); i++) {
        exprNodeDesc ch = (exprNodeDesc) nd.getChildren().get(i);
        exprNodeDesc newCh = ctx.getConvertedNode(ch);
        if (newCh != null) {
          expr.getChildExprs().set(i, newCh);
          ch = newCh;
        }
        String chAlias = ctx.getAlias(ch);
       
        isCandidate = isCandidate && ctx.isCandidate(ch);
View Full Code Here

TOP

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

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.