Examples of exprNodeConstantDesc


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

        // 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

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

      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

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

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

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

      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

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

        // "." :  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

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

        } 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

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

    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

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

  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

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

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

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

      int basetimes = 100000;
      measureSpeed("1 + 2",
          basetimes * 100,
          ExprNodeEvaluatorFactory.get(
              TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("+",
                  new exprNodeConstantDesc(1),
                  new exprNodeConstantDesc(2))),
          r,
          Integer.valueOf(1 + 2));
      measureSpeed("1 + 2 - 3",
          basetimes * 100,
          ExprNodeEvaluatorFactory.get(
              TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("-",
                  TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("+",
                      new exprNodeConstantDesc(1),
                      new exprNodeConstantDesc(2)),
                  new exprNodeConstantDesc(3))),
          r,
          Integer.valueOf(1 + 2 - 3));
      measureSpeed("1 + 2 - 3 + 4",
          basetimes * 100,
          ExprNodeEvaluatorFactory.get(
              TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("+",
                  TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("-",
                      TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("+",
                          new exprNodeConstantDesc(1),
                          new exprNodeConstantDesc(2)),
                      new exprNodeConstantDesc(3)),
                  new exprNodeConstantDesc(4))),                     
          r,
          Integer.valueOf(1 + 2 - 3 + 4));
      measureSpeed("concat(\"1\", \"2\")",
          basetimes * 100,
          ExprNodeEvaluatorFactory.get(
              TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("concat",
                  new exprNodeConstantDesc("1"),
                  new exprNodeConstantDesc("2"))),
          r,
          "12");
      measureSpeed("concat(concat(\"1\", \"2\"), \"3\")",
          basetimes * 100,
          ExprNodeEvaluatorFactory.get(
              TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("concat",
                  TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("concat",
                      new exprNodeConstantDesc("1"),
                      new exprNodeConstantDesc("2")),
                  new exprNodeConstantDesc("3"))),
          r,
          "123");
      measureSpeed("concat(concat(concat(\"1\", \"2\"), \"3\"), \"4\")",
          basetimes * 100,
          ExprNodeEvaluatorFactory.get(
              TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("concat",
                TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("concat",
                    TypeCheckProcFactory.DefaultExprProcessor.getFuncExprNodeDesc("concat",
                        new exprNodeConstantDesc("1"),
                        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.