Imbar M. Imbar M. - 28 days ago 7x
Java Question

create parquet files in java

Is there a way to create parquet files from java?

I have data in memory (java classes) and I want to write it into a parquet file, to later read it from apache-drill.

Is there an simple way to do this, like inserting data into a sql table?


Thanks for the help.

Combining the answers and this link, I was able to create a parquet file and read it back with drill.


ParquetWriter's constructors are deprecated(1.8.1) but not ParquetWriter itself, you can still create ParquetWriter by extending abstract Builder subclass inside of it.

Here an example from parquet creators themselves ExampleParquetWriter:

  public static class Builder extends ParquetWriter.Builder<Group, Builder> {
    private MessageType type = null;
    private Map<String, String> extraMetaData = new HashMap<String, String>();

    private Builder(Path file) {

    public Builder withType(MessageType type) {
      this.type = type;
      return this;

    public Builder withExtraMetaData(Map<String, String> extraMetaData) {
      this.extraMetaData = extraMetaData;
      return this;

    protected Builder self() {
      return this;

    protected WriteSupport<Group> getWriteSupport(Configuration conf) {
      return new GroupWriteSupport(type, extraMetaData);


If you don't want to use Group and GroupWriteSupport(bundled in Parquet) you can go with Avro, Protocol Buffers, or Thrift in-memory data models.