@mickaellcr , Can you elaborate more regarding "We should write the right primitive type while we are reading the data and not at the end"?  The problem here is that column type could be changed AFTER data has already been written.  Parquet Hive's RecordReader returns an ArrayWritable (based on schema stored in footers of parquet files); ParquetHiveSerDe also creates an corresponding ArrayWritableObjectInspector (but using column type info from metastore). Whenever there is column type change, the objector inspector will throw exception, since WritableLongObjectInspector cannot inspect an IntWritable etc...

Conversion has to happen somewhere if we want to allow type change.  SerDe's deserialize method seems a natural place for it.  I joined parquet project only recently hence probably missed the earlier discussion on that.

@jqcoffey I see that createPrimitive is originally only for serialize method , except that it tries to create a new primitive type object regardless, which seems expensive. I think that could be optimized a bit by just returning the object passed if already of the right type. Please correct me if I am wrong.

The reason deserialize method also uses createPrimitive method is mentioned above (for conversion in case of type change).  

If you think we should do conversion some other places (instead of in SerDe), I would be happy to explore that.

I refactored try catch out of switch statement, catching more specific exception and cleaned up some code formatting issues.