Search in sources :

Example 1 with TupleConversionException

use of org.apache.parquet.pig.TupleConversionException in project parquet-mr by apache.

the class TupleConverter method newConverter.

static Converter newConverter(FieldSchema pigField, Type type, final ParentValueContainer parent, boolean elephantBirdCompatible, boolean columnIndexAccess) {
    try {
        switch(pigField.type) {
            case DataType.BAG:
                return new BagConverter(type.asGroupType(), pigField, parent, elephantBirdCompatible, columnIndexAccess);
            case DataType.MAP:
                return new MapConverter(type.asGroupType(), pigField, parent, elephantBirdCompatible, columnIndexAccess);
            case DataType.TUPLE:
                return new TupleConverter(type.asGroupType(), pigField.schema, elephantBirdCompatible, columnIndexAccess) {

                    @Override
                    public void end() {
                        super.end();
                        parent.add(this.currentTuple);
                    }
                };
            case DataType.CHARARRAY:
                // a custom implementation will be needed for each type.  Just default to no dictionary.
                return new FieldStringConverter(parent, type.getOriginalType() == OriginalType.UTF8);
            case DataType.BYTEARRAY:
                return new FieldByteArrayConverter(parent);
            case DataType.INTEGER:
                return new FieldIntegerConverter(parent);
            case DataType.BOOLEAN:
                if (elephantBirdCompatible) {
                    return new FieldIntegerConverter(parent);
                } else {
                    return new FieldBooleanConverter(parent);
                }
            case DataType.FLOAT:
                return new FieldFloatConverter(parent);
            case DataType.DOUBLE:
                return new FieldDoubleConverter(parent);
            case DataType.LONG:
                return new FieldLongConverter(parent);
            case DataType.BIGDECIMAL:
                return new FieldBigDecimalConverter(type, parent);
            default:
                throw new TupleConversionException("unsupported pig type: " + pigField);
        }
    } catch (FrontendException e) {
        throw new TupleConversionException("error while preparing converter for:\n" + pigField + "\n" + type, e);
    } catch (RuntimeException e) {
        throw new TupleConversionException("error while preparing converter for:\n" + pigField + "\n" + type, e);
    }
}
Also used : TupleConversionException(org.apache.parquet.pig.TupleConversionException) FrontendException(org.apache.pig.impl.logicalLayer.FrontendException)

Aggregations

TupleConversionException (org.apache.parquet.pig.TupleConversionException)1 FrontendException (org.apache.pig.impl.logicalLayer.FrontendException)1