Class ParquetRewriter

java.lang.Object
org.apache.parquet.hadoop.rewrite.ParquetRewriter
All Implemented Interfaces:
Closeable, AutoCloseable

public class ParquetRewriter extends Object implements Closeable
Rewrites multiple input files into a single output file.

Supported functionality:

  • Merging multiple files into a single one
  • Applying column transformations
  • Joining with extra files with a different schema

Note that the total number of row groups from all input files is preserved in the output file. This may not be optimal if row groups are very small and will not solve small file problems. Instead, it will make it worse to have a large file footer in the output file.

Merging multiple files into a single output files

Use RewriteOptions.Builder's constructor or methods to provide inputFiles. Please note the schema of all inputFiles must be the same, otherwise the rewrite will fail.

Applying column transformations

Some supported column transformations: pruning, masking, renaming, encrypting, changing a codec. See RewriteOptions and RewriteOptions.Builder for the full list with description.

Joining with extra files with a different schema

Use RewriteOptions.Builder's constructor or methods to provide inputFilesToJoin. Please note the schema of all inputFilesToJoin must be the same, otherwise the rewrite will fail. Requirements for a joining the main inputFiles(left) and inputFilesToJoin(right):
  • the number of files might be different on the left and right,
  • the schema of files inside of each group(left/right) must be the same, but those two schemas not necessarily should be equal,
  • the total number of row groups must be the same on the left and right,
  • the total number of rows must be the same on the left and right,
  • the global ordering of rows must be the same on the left and right.