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

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


        "   <object idref=\"PrimitiveTypeInfo1\"/> \n" +
        "  </void> \n" +
        " </object> \n" +
        "</java> \n";
    Configuration conf = new Configuration();
    ExprNodeDesc expr = Utilities.deserializeExpression(exprStr, conf);
    SearchArgumentImpl sarg =
        (SearchArgumentImpl) SearchArgument.FACTORY.create(expr);
    List<PredicateLeaf> leaves = sarg.getLeaves();
    assertEquals(4, leaves.size());
View Full Code Here


        "   <object idref=\"PrimitiveTypeInfo0\"/> \n" +
        "  </void> \n" +
        " </object> \n" +
        "</java> \n";
    Configuration conf = new Configuration();
    ExprNodeDesc expr = Utilities.deserializeExpression(exprStr, conf);
    SearchArgumentImpl sarg =
        (SearchArgumentImpl) SearchArgument.FACTORY.create(expr);
    List<PredicateLeaf> leaves = sarg.getLeaves();
    assertEquals(3, leaves.size());
View Full Code Here

    //  a constant, we convert that into an exprNodeConstantDesc.  For others we just
    //  build the exprNodeFuncDesc with recursively built children.
    ASTNode expr = (ASTNode)nd;
    TypeCheckCtx ctx = (TypeCheckCtx) procCtx;
    RowResolver input = ctx.getInputRR();
    exprNodeDesc desc = null;

    //  If the current subExpression is pre-calculated, as in Group-By etc.
    ColumnInfo colInfo = input.get("", expr.toStringTree());
    if (colInfo != null) {
      desc = new exprNodeColumnDesc(colInfo.getType(), colInfo.getInternalName());
View Full Code Here

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

      exprNodeDesc desc = TypeCheckProcFactory.processGByExpr(nd, procCtx);
      if (desc != null) {
        return desc;
      }
     
      return new exprNodeNullDesc();
View Full Code Here

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

      exprNodeDesc desc = TypeCheckProcFactory.processGByExpr(nd, procCtx);
      if (desc != null) {
        return desc;
      }
     
      Number v = null;
View Full Code Here

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

      exprNodeDesc desc = TypeCheckProcFactory.processGByExpr(nd, procCtx);
      if (desc != null) {
        return desc;
      }
     
      ASTNode expr = (ASTNode)nd;
View Full Code Here

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

      exprNodeDesc desc = TypeCheckProcFactory.processGByExpr(nd, procCtx);
      if (desc != null) {
        return desc;
      }

      ASTNode expr = (ASTNode)nd;
View Full Code Here

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

      exprNodeDesc desc = TypeCheckProcFactory.processGByExpr(nd, procCtx);
      if (desc != null) {
        return desc;
      }

      ASTNode expr = (ASTNode)nd;
View Full Code Here

     */
    public static exprNodeDesc getFuncExprNodeDesc(String udfName, List<exprNodeDesc> children) {
      // Find the corresponding method
      ArrayList<Class<?>> argumentClasses = new ArrayList<Class<?>>(children.size());
      for(int i=0; i<children.size(); i++) {
        exprNodeDesc child = children.get(i);
        assert(child != null);
        TypeInfo childTypeInfo = child.getTypeInfo();
        assert(childTypeInfo != null);
       
        // Note: we don't pass the element types of MAP/LIST to UDF.
        // That will work for null test and size but not other more complex functionalities like list slice etc.
        // For those more complex functionalities, we plan to have a ComplexUDF interface which has an evaluate
        // method that accepts a list of objects and a list of objectinspectors.
        switch (childTypeInfo.getCategory()) {
          case PRIMITIVE: {
            argumentClasses.add(childTypeInfo.getPrimitiveClass());
            break;
          }
          case MAP: {
            argumentClasses.add(Map.class);
            break;
          }
          case LIST: {
            argumentClasses.add(List.class);
            break;
          }
          case STRUCT: {
            argumentClasses.add(Object.class);
            break;
          }
          default: {
            // should never happen
            assert(false);
          }
        }
      }
      Method udfMethod = FunctionRegistry.getUDFMethod(udfName, argumentClasses);
      if (udfMethod == null) return null;

      ArrayList<exprNodeDesc> ch = new ArrayList<exprNodeDesc>();
      Class<?>[] pTypes = udfMethod.getParameterTypes();

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

        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

TOP

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

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.