Skip to content

Commit 5577bb9

Browse files
committed
test(write): cover single-file, compression, retain semantics
1 parent d94d946 commit 5577bb9

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

‎src/test/java/org/apache/datafusion/DataFrameWriteParquetTest.java‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,43 @@ void writeParquetRoundTripsRowCount(@TempDir Path tempDir) throws Exception {
7070

7171
assertEquals(LINEITEM_ROWS, countRowsAt(out));
7272
}
73+
74+
@Test
75+
void writeParquetSingleFileProducesOneFile(@TempDir Path tempDir) throws Exception {
76+
assumeLineitem();
77+
Path out = tempDir.resolve("out.parquet");
78+
79+
try (SessionContext ctx = new SessionContext();
80+
DataFrame df = ctx.readParquet(LINEITEM.toAbsolutePath().toString())) {
81+
df.writeParquet(out.toString(), new ParquetWriteOptions().singleFileOutput(true));
82+
}
83+
84+
assertTrue(Files.isRegularFile(out), "expected single file at " + out);
85+
assertEquals(LINEITEM_ROWS, countRowsAt(out));
86+
}
87+
88+
@Test
89+
void writeParquetWithCompressionRoundTrips(@TempDir Path tempDir) throws Exception {
90+
assumeLineitem();
91+
Path out = tempDir.resolve("zstd-out");
92+
93+
try (SessionContext ctx = new SessionContext();
94+
DataFrame df = ctx.readParquet(LINEITEM.toAbsolutePath().toString())) {
95+
df.writeParquet(out.toString(), new ParquetWriteOptions().compression("zstd(3)"));
96+
}
97+
98+
assertEquals(LINEITEM_ROWS, countRowsAt(out));
99+
}
100+
101+
@Test
102+
void writeParquetRetainsDataFrame(@TempDir Path tempDir) throws Exception {
103+
assumeLineitem();
104+
Path out = tempDir.resolve("retained");
105+
106+
try (SessionContext ctx = new SessionContext();
107+
DataFrame df = ctx.readParquet(LINEITEM.toAbsolutePath().toString())) {
108+
df.writeParquet(out.toString());
109+
assertEquals(LINEITEM_ROWS, df.count());
110+
}
111+
}
73112
}

0 commit comments

Comments
 (0)