Skip to content

Commit 42c3d1f

Browse files
committed
add option to ParquetOutputFormat
1 parent cd877c6 commit 42c3d1f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetOutputFormat.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public static enum JobSummaryLevel {
163163
public static final String PAGE_WRITE_CHECKSUM_ENABLED = "parquet.page.write-checksum.enabled";
164164
public static final String STATISTICS_ENABLED = "parquet.column.statistics.enabled";
165165
public static final String SIZE_STATISTICS_ENABLED = "parquet.size.statistics.enabled";
166+
public static final String WRITE_PATH_IN_SCHEMA_ENABLED = "parquet.path-in-schema.enabled";
166167

167168
public static JobSummaryLevel getJobSummaryLevel(Configuration conf) {
168169
String level = conf.get(JOB_SUMMARY_LEVEL);
@@ -448,6 +449,14 @@ public static boolean getSizeStatisticsEnabled(Configuration conf, String path)
448449
return conf.getBoolean(SIZE_STATISTICS_ENABLED + "#" + path, getSizeStatisticsEnabled(conf));
449450
}
450451

452+
public static boolean getWritePathInSchemaEnabled(Configuration conf) {
453+
return conf.getBoolean(WRITE_PATH_IN_SCHEMA_ENABLED, ParquetProperties.DEFAULT_WRITE_PATH_IN_SCHEMA_ENABLED);
454+
}
455+
456+
public static void setWritePathInSchemaEnabled(Configuration conf, boolean enabled) {
457+
conf.setBoolean(WRITE_PATH_IN_SCHEMA_ENABLED, enabled);
458+
}
459+
451460
private WriteSupport<T> writeSupport;
452461
private ParquetOutputCommitter committer;
453462

@@ -508,7 +517,6 @@ public RecordWriter<Void, T> getRecordWriter(Configuration conf, Path file, Comp
508517
throws IOException, InterruptedException {
509518
final WriteSupport<T> writeSupport = getWriteSupport(conf);
510519

511-
// TODO(ets): add write_path_in_schema to conf?
512520
ParquetProperties.Builder propsBuilder = ParquetProperties.builder()
513521
.withPageSize(getPageSize(conf))
514522
.withDictionaryPageSize(getDictionaryPageSize(conf))
@@ -527,7 +535,8 @@ public RecordWriter<Void, T> getRecordWriter(Configuration conf, Path file, Comp
527535
.withRowGroupRowCountLimit(getBlockRowCountLimit(conf))
528536
.withPageRowCountLimit(getPageRowCountLimit(conf))
529537
.withPageWriteChecksumEnabled(getPageWriteChecksumEnabled(conf))
530-
.withStatisticsEnabled(getStatisticsEnabled(conf));
538+
.withStatisticsEnabled(getStatisticsEnabled(conf))
539+
.withWritePathInSchemaEnabled(getWritePathInSchemaEnabled(conf));
531540
new ColumnConfigParser()
532541
.withColumnConfig(
533542
ENABLE_DICTIONARY, key -> conf.getBoolean(key, false), propsBuilder::withDictionaryEncoding)

0 commit comments

Comments
 (0)