Examples of BackendException


Examples of org.apache.pig.backend.BackendException

  protected void setValueType(Class<?> valueClass) throws BackendException {
    this.valType |= inferPigDataType(valueClass);
    if (keyType == DataType.ERROR) {
      LOG.warn("Unable to translate key "+key.getClass()+" to a Pig datatype");
      throw new BackendException("Unable to translate "+key.getClass()+" to a Pig datatype");
    }
  }
View Full Code Here

Examples of org.apache.pig.backend.BackendException

      outgoing.add(getJavaObj(tuple.get(i++), fSchema));
    }
    try {
      writer.write(null, new DefaultHCatRecord(outgoing));
    } catch (InterruptedException e) {
      throw new BackendException("Error while writing tuple: "+tuple, PigHCatUtil.PIG_EXCEPTION_CODE, e);
    }
  }
View Full Code Here

Examples of org.apache.pig.backend.BackendException

        return pigObj;
      case SMALLINT:
      case TINYINT:
      case BOOLEAN:
        // would not pass schema validation anyway
        throw new BackendException("Incompatible type "+type+" found in hcat table schema: "+hcatFS, PigHCatUtil.PIG_EXCEPTION_CODE);
      default:
        throw new BackendException("Unexpected type "+type+" for value "+pigObj + (pigObj == null ? "" : " of class " + pigObj.getClass().getName()), PigHCatUtil.PIG_EXCEPTION_CODE);
      }
    } catch (BackendException e) {
      // provide the path to the field in the error message
      throw new BackendException(
          (hcatFS.getName() == null ? " " : hcatFS.getName()+".") + e.getMessage(),
          e.getCause() == null ? e : e.getCause());
    }
  }
View Full Code Here

Examples of org.apache.pig.backend.BackendException

  protected void setKeyType(Class<?> keyClass) throws BackendException {
    this.keyType |= inferPigDataType(keyClass);
    if (keyType == DataType.ERROR) {
      LOG.warn("Unable to translate key "+key.getClass()+" to a Pig datatype");
      throw new BackendException("Unable to translate "+key.getClass()+" to a Pig datatype");
    }
  }
View Full Code Here

Examples of org.apache.pig.backend.BackendException

 
  protected void setValueType(Class<?> valueClass) throws BackendException {
    this.valType |= inferPigDataType(valueClass);
    if (keyType == DataType.ERROR) {
      LOG.warn("Unable to translate key "+key.getClass()+" to a Pig datatype");
      throw new BackendException("Unable to translate "+key.getClass()+" to a Pig datatype");
    }
  }
View Full Code Here

Examples of org.apache.pig.backend.BackendException

      outgoing.add(getJavaObj(tuple.get(i++), fSchema));
    }
    try {
      writer.write(null, new DefaultHCatRecord(outgoing));
    } catch (InterruptedException e) {
      throw new BackendException("Error while writing tuple: " + tuple, PigHCatUtil.PIG_EXCEPTION_CODE, e);
    }
  }
View Full Code Here

Examples of org.apache.pig.backend.BackendException

            return Boolean.FALSE;
          }
          if( ((String)pigObj).trim().compareTo("1") == 0 ) {
            return Boolean.TRUE;
          }
          throw new BackendException("Unexpected type " + type + " for value " + pigObj
            + " of class " + pigObj.getClass().getName(), PigHCatUtil.PIG_EXCEPTION_CODE);
        }
        return Boolean.parseBoolean( pigObj.toString() );
      case DECIMAL:
        BigDecimal bd = (BigDecimal)pigObj;
        DecimalTypeInfo dti = (DecimalTypeInfo)hcatFS.getTypeInfo();
        if(bd.precision() > dti.precision() || bd.scale() > dti.scale()) {
          handleOutOfRangeValue(pigObj, hcatFS);
          return null;
        }
        return HiveDecimal.create(bd);
      case CHAR:
        String charVal = (String)pigObj;
        CharTypeInfo cti = (CharTypeInfo)hcatFS.getTypeInfo();
        if(charVal.length() > cti.getLength()) {
          handleOutOfRangeValue(pigObj, hcatFS);
          return null;
        }
        return new HiveChar(charVal, cti.getLength());
      case VARCHAR:
        String varcharVal = (String)pigObj;
        VarcharTypeInfo vti = (VarcharTypeInfo)hcatFS.getTypeInfo();
        if(varcharVal.length() > vti.getLength()) {
          handleOutOfRangeValue(pigObj, hcatFS);
          return null;
        }
        return new HiveVarchar(varcharVal, vti.getLength());
      case TIMESTAMP:
        DateTime dt = (DateTime)pigObj;
        return new Timestamp(dt.getMillis());//getMillis() returns UTC time regardless of TZ
      case DATE:
        /**
         * We ignore any TZ setting on Pig value since java.sql.Date doesn't have it (in any
         * meaningful way).  So the assumption is that if Pig value has 0 time component (midnight)
         * we assume it reasonably 'fits' into a Hive DATE.  If time part is not 0, it's considered
         * out of range for target type.
         */
        DateTime dateTime = ((DateTime)pigObj);
        if(dateTime.getMillisOfDay() != 0) {
          handleOutOfRangeValue(pigObj, hcatFS, "Time component must be 0 (midnight) in local timezone; Local TZ val='" + pigObj + "'");
          return null;
        }
        /*java.sql.Date is a poorly defined API.  Some (all?) SerDes call toString() on it
        [e.g. LazySimpleSerDe, uses LazyUtils.writePrimitiveUTF8()],  which automatically adjusts
          for local timezone.  Date.valueOf() also uses local timezone (as does Date(int,int,int).
          Also see PigHCatUtil#extractPigObject() for corresponding read op.  This way a DATETIME from Pig,
          when stored into Hive and read back comes back with the same value.*/
        return new Date(dateTime.getYear() - 1900, dateTime.getMonthOfYear() - 1, dateTime.getDayOfMonth());
      default:
        throw new BackendException("Unexpected HCat type " + type + " for value " + pigObj
          + " of class " + pigObj.getClass().getName(), PigHCatUtil.PIG_EXCEPTION_CODE);
      }
    } catch (BackendException e) {
      // provide the path to the field in the error message
      throw new BackendException(
        (hcatFS.getName() == null ? " " : hcatFS.getName() + ".") + e.getMessage(), e);
    }
  }
View Full Code Here

Examples of org.apache.pig.backend.BackendException

    String msg = "Pig value '" + pigObj + "' is outside the bounds of column " + hcatFS.getName() +
      " with type " + (hcatFS.getTypeInfo() == null ? hcatFS.getType() : hcatFS.getTypeInfo().getTypeName()) +
      (additionalMsg == null ? "" : "[" + additionalMsg + "]");
    switch (onOutOfRange) {
      case Throw:
        throw new BackendException(msg, PigHCatUtil.PIG_EXCEPTION_CODE);
      case Null:
        dataLossLogger.logDataLossMsg(hcatFS, pigObj, msg);
        break;
      default:
        throw new BackendException("Unexpected " + ON_OOR_VALUE_OPT + " value: '" + onOutOfRange + "'");
    }
  }
View Full Code Here

Examples of org.apache.pig.backend.BackendException

      outgoing.add(getJavaObj(tuple.get(i++), fSchema));
    }
    try {
      writer.write(null, new DefaultHCatRecord(outgoing));
    } catch (InterruptedException e) {
      throw new BackendException("Error while writing tuple: " + tuple, PigHCatUtil.PIG_EXCEPTION_CODE, e);
    }
  }
View Full Code Here

Examples of org.apache.pig.backend.BackendException

      case SMALLINT:
        if (pigObj == null) {
          return null;
        }
        if ((Integer) pigObj < Short.MIN_VALUE || (Integer) pigObj > Short.MAX_VALUE) {
          throw new BackendException("Value " + pigObj + " is outside the bounds of column " +
            hcatFS.getName() + " with type " + hcatFS.getType(), PigHCatUtil.PIG_EXCEPTION_CODE);
        }
        return ((Integer) pigObj).shortValue();
      case TINYINT:
        if (pigObj == null) {
          return null;
        }
        if ((Integer) pigObj < Byte.MIN_VALUE || (Integer) pigObj > Byte.MAX_VALUE) {
          throw new BackendException("Value " + pigObj + " is outside the bounds of column " +
            hcatFS.getName() + " with type " + hcatFS.getType(), PigHCatUtil.PIG_EXCEPTION_CODE);
        }
        return ((Integer) pigObj).byteValue();
      case BOOLEAN:
        // would not pass schema validation anyway
        throw new BackendException("Incompatible type " + type + " found in hcat table schema: " + hcatFS, PigHCatUtil.PIG_EXCEPTION_CODE);
      default:
        throw new BackendException("Unexpected type " + type + " for value " + pigObj + (pigObj == null ? "" : " of class " + pigObj.getClass().getName()), PigHCatUtil.PIG_EXCEPTION_CODE);
      }
    } catch (BackendException e) {
      // provide the path to the field in the error message
      throw new BackendException(
        (hcatFS.getName() == null ? " " : hcatFS.getName() + ".") + e.getMessage(),
        e.getCause() == null ? e : e.getCause());
    }
  }
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.