Package org.apache.hcatalog.data.schema.HCatFieldSchema

Examples of org.apache.hcatalog.data.schema.HCatFieldSchema.Type


  }

  @SuppressWarnings("unchecked")
  public static Object extractPigObject(Object o, HCatFieldSchema hfs) throws Exception {
    Object result;
    Type itemType = hfs.getType();
    switch (itemType) {
    case BINARY:
      result = (o == null) ? null : new DataByteArray((byte[]) o);
      break;
    case STRUCT:
View Full Code Here


    }
  }

  private static void validateHcatFieldFollowsPigRules(HCatFieldSchema hcatField) throws PigException {
    try {
      Type hType = hcatField.getType();
      switch (hType) {
      case BOOLEAN:
        if (!pigHasBooleanSupport) {
          throw new PigException("Incompatible type found in HCat table schema: "
              + hcatField, PigHCatUtil.PIG_EXCEPTION_CODE);
View Full Code Here

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

  @SuppressWarnings("unchecked")
public static Object extractPigObject(Object o, HCatFieldSchema 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 validateHCatTableSchemaFollowsPigRules(HCatSchema hcatTableSchema) throws IOException {
      for (HCatFieldSchema hfs : hcatTableSchema.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(HCatFieldSchema hfs) throws IOException {
      Type htype = hfs.getType();
      if (
              (hfs.isComplex()) ||
              (htype == Type.TINYINT) ||
              (htype == Type.SMALLINT)
              ){
View Full Code Here

      HCatFieldSchema mapField = getTableCol(fSchema.alias, hcatTblSchema);
      HCatFieldSchema valFS;
      List<HCatFieldSchema> valFSList = new ArrayList<HCatFieldSchema>(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, HCatFieldSchema hcatFS) throws ExecException, HCatException{

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

    switch(type){

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

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

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

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

    for(HCatFieldSchema hcatField : tblSchema.getFields()){

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

    }

    @SuppressWarnings("unchecked")
    public static Object extractPigObject(Object o, HCatFieldSchema hfs) throws Exception {
        Object result;
        Type itemType = hfs.getType();
        switch (itemType) {
        case BINARY:
            result = (o == null) ? null : new DataByteArray((byte[]) o);
            break;
        case STRUCT:
View Full Code Here

        }
    }

    private static void validateHcatFieldFollowsPigRules(HCatFieldSchema hcatField) throws PigException {
        try {
            Type hType = hcatField.getType();
            switch (hType) {
            case BOOLEAN:
                if (!pigHasBooleanSupport) {
                    throw new PigException("Incompatible type found in HCat table schema: "
                            + hcatField, PigHCatUtil.PIG_EXCEPTION_CODE);
View Full Code Here

TOP

Related Classes of org.apache.hcatalog.data.schema.HCatFieldSchema.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.