Package org.apache.howl.data.schema.HowlFieldSchema

Examples of org.apache.howl.data.schema.HowlFieldSchema.Type


      HowlFieldSchema mapField = getTableCol(fSchema.alias, howlTblSchema);
      HowlFieldSchema valFS;
      List<HowlFieldSchema> valFSList = new ArrayList<HowlFieldSchema>(1);

      if(mapField != null){
        Type mapValType = mapField.getMapValueSchema().get(0).getType();

        switch(mapValType){
        case STRING:
        case BIGINT:
        case INT:
View Full Code Here


  private Object getJavaObj(Object pigObj, HowlFieldSchema howlFS) throws ExecException, HowlException{

    // The real work-horse. Spend time and energy in this method if there is
    // need to keep HowlStorer lean and go fast.
    Type type = howlFS.getType();

    switch(type){

    case STRUCT:
      // Unwrap the tuple.
View Full Code Here

            validateAlias(innerField.alias);
          }
          if(howlField != null){
            // Do the same validation for HowlSchema.
            HowlFieldSchema arrayFieldScehma = howlField.getArrayElementSchema().get(0);
            Type hType = arrayFieldScehma.getType();
            if(hType == Type.STRUCT){
              for(HowlFieldSchema structFieldInBag : arrayFieldScehma.getStructSubSchema().getFields()){
                if(structFieldInBag.getType() == Type.STRUCT || structFieldInBag.getType() == Type.ARRAY){
                  throw new FrontendException("Nested Complex types not allowed "+ howlField, PigHowlUtil.PIG_EXCEPTION_CODE);
                }
              }
            }
            if(hType == Type.MAP){
              if(arrayFieldScehma.getMapKeyType() != Type.STRING){
                throw new FrontendException("Key Type of map must be String "+howlField, PigHowlUtil.PIG_EXCEPTION_CODE);
              }
              if(arrayFieldScehma.getMapValueSchema().get(0).isComplex()){
                throw new FrontendException("Value type of map cannot be complex "+howlField, PigHowlUtil.PIG_EXCEPTION_CODE);
              }
            }
            if(hType == Type.ARRAY) {
              throw new FrontendException("Arrays cannot contain array within it. "+howlField, PigHowlUtil.PIG_EXCEPTION_CODE);
            }
          }
          break;

        case DataType.TUPLE:
          validateUnNested(pigField.schema);
          if(howlField != null){
            for(HowlFieldSchema structFieldSchema : howlField.getStructSubSchema().getFields()){
              if(structFieldSchema.isComplex()){
                throw new FrontendException("Nested Complex types are not allowed."+howlField, PigHowlUtil.PIG_EXCEPTION_CODE);
              }
            }
          }
          break;

        default:
          throw new FrontendException("Internal Error.", PigHowlUtil.PIG_EXCEPTION_CODE);
        }
      }
    }

    for(HowlFieldSchema howlField : tblSchema.getFields()){

      // We dont do type promotion/demotion.
      Type hType = howlField.getType();
      switch(hType){
      case SMALLINT:
      case TINYINT:
      case BOOLEAN:
        throw new FrontendException("Incompatible type found in howl table schema: "+howlField, PigHowlUtil.PIG_EXCEPTION_CODE);
View Full Code Here

      return transformToTuple(hr.getAll(),hs);
    }

  @SuppressWarnings("unchecked")
public static Object extractPigObject(Object o, HowlFieldSchema hfs) throws Exception {
      Type itemType = hfs.getType();
      if ( ! hfs.isComplex()){
        return o;
      } else  if (itemType == Type.STRUCT) {
        return transformToTuple((List<Object>)o,hfs);
      } else  if (itemType == Type.ARRAY) {
View Full Code Here

  }


  public static void validateHowlTableSchemaFollowsPigRules(HowlSchema howlTableSchema) throws IOException {
      for (HowlFieldSchema hfs : howlTableSchema.getFields()){
          Type htype = hfs.getType();
          if (htype == Type.ARRAY){
              validateIsPigCompatibleArrayWithPrimitivesOrSimpleComplexTypes(hfs);
          }else if (htype == Type.STRUCT){
              validateIsPigCompatibleStructWithPrimitives(hfs);
          }else if (htype == Type.MAP){
View Full Code Here

          validateIsPigCompatiblePrimitive(subField);
      }
  }

  private static void validateIsPigCompatiblePrimitive(HowlFieldSchema hfs) throws IOException {
      Type htype = hfs.getType();
      if (
              (hfs.isComplex()) ||
              (htype == Type.TINYINT) ||
              (htype == Type.SMALLINT)
              ){
View Full Code Here

TOP

Related Classes of org.apache.howl.data.schema.HowlFieldSchema.Type

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.