Package org.apache.hadoop.hive.ql.typeinfo

Examples of org.apache.hadoop.hive.ql.typeinfo.TypeInfo


      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));
      }
      TypeInfo t = objectTypeInfo.getStructFieldTypeInfo(fieldNameString);
      if (isList) {
        t = TypeInfoFactory.getListTypeInfo(t);
      }
     
      desc = new exprNodeFieldDesc(t, children.get(0), fieldNameString, isList);
     
    } else if (funcText.equals("[")){
      // "[]" : LSQUARE/INDEX Expression
      assert(children.size() == 2);
     
      // Check whether this is a list or a map
      TypeInfo myt = children.get(0).getTypeInfo();

      if (myt.getCategory() == Category.LIST) {
        // Only allow constant integer index for now
        if (!(children.get(1) instanceof exprNodeConstantDesc)
            || !(((exprNodeConstantDesc)children.get(1)).getValue() instanceof Integer)) {
          throw new SemanticException(ErrorMsg.INVALID_ARRAYINDEX_CONSTANT.getMsg(expr));
        }
     
        // Calculate TypeInfo
        TypeInfo t = myt.getListElementTypeInfo();
        desc = new exprNodeIndexDesc(t, children.get(0), children.get(1));
      }
      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)).getValue().getClass() ==
              myt.getMapKeyTypeInfo().getPrimitiveClass())) {
          throw new SemanticException(ErrorMsg.INVALID_MAPINDEX_TYPE.getMsg(expr));
        }
        // Calculate TypeInfo
        TypeInfo t = myt.getMapValueTypeInfo();
       
        desc = new exprNodeIndexDesc(t, children.get(0), children.get(1));
      }
      else {
        throw new SemanticException(ErrorMsg.NON_COLLECTION_TYPE.getMsg(expr));
View Full Code Here


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

            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);
            }
          } catch (SerDeException e){
            throw new RuntimeException(e);
          }
        }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.ql.typeinfo.TypeInfo

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.