diff --git a/csharp.test/TestRowOrientedParquetFile.cs b/csharp.test/TestRowOrientedParquetFile.cs index 0b02b845..d97290e1 100644 --- a/csharp.test/TestRowOrientedParquetFile.cs +++ b/csharp.test/TestRowOrientedParquetFile.cs @@ -80,6 +80,28 @@ public static void TestWriterDoubleDispose() } } + [Test] + public static void TestCompressionArgument([Values(Compression.Uncompressed, Compression.Brotli)] Compression compression) + { + using (var buffer = new ResizableBuffer()) + { + using (var outputStream = new BufferOutputStream(buffer)) + using (var writer = ParquetFile.CreateRowWriter<(int, float)>(outputStream, compression: compression)) + { + writer.WriteRows(new[] {(42, 3.14f)}); + } + + using (var inputStream = new BufferReader(buffer)) + using (var reader = new ParquetFileReader(inputStream)) + using (var group = reader.RowGroup(0)) + { + Assert.AreEqual(2, group.MetaData.NumColumns); + Assert.AreEqual(compression, group.MetaData.GetColumnChunkMetaData(0).Compression); + Assert.AreEqual(compression, group.MetaData.GetColumnChunkMetaData(1).Compression); + } + } + } + private static void TestRoundtrip(TTuple[] rows) { using (var buffer = new ResizableBuffer()) diff --git a/csharp/ParquetSharp.csproj b/csharp/ParquetSharp.csproj index b6e10959..e2134cfb 100644 --- a/csharp/ParquetSharp.csproj +++ b/csharp/ParquetSharp.csproj @@ -12,7 +12,7 @@ true true 1591; - 2.0.2-beta3 + 2.0.2-beta4 G-Research G-Research ParquetSharp diff --git a/csharp/RowOriented/ParquetFile.cs b/csharp/RowOriented/ParquetFile.cs index 81fb1bf8..1812da69 100644 --- a/csharp/RowOriented/ParquetFile.cs +++ b/csharp/RowOriented/ParquetFile.cs @@ -45,7 +45,7 @@ public static ParquetRowWriter CreateRowWriter( IReadOnlyDictionary keyValueMetadata = null) { var (columns, writeDelegate) = GetOrCreateWriteDelegate(columnNames); - return new ParquetRowWriter(path, columns, writeDelegate); + return new ParquetRowWriter(path, columns, compression, keyValueMetadata, writeDelegate); } /// @@ -58,7 +58,7 @@ public static ParquetRowWriter CreateRowWriter( IReadOnlyDictionary keyValueMetadata = null) { var (columns, writeDelegate) = GetOrCreateWriteDelegate(columnNames); - return new ParquetRowWriter(outputStream, columns, writeDelegate); + return new ParquetRowWriter(outputStream, columns, compression, keyValueMetadata, writeDelegate); } private static ParquetRowReader.ReadAction GetOrCreateReadDelegate() diff --git a/csharp/RowOriented/ParquetRowWriter.cs b/csharp/RowOriented/ParquetRowWriter.cs index 80db6f67..342e8888 100644 --- a/csharp/RowOriented/ParquetRowWriter.cs +++ b/csharp/RowOriented/ParquetRowWriter.cs @@ -13,13 +13,23 @@ public sealed class ParquetRowWriter : IDisposable { internal delegate void WriteAction(ParquetRowWriter parquetRowWriter, TTuple[] rows, int length); - internal ParquetRowWriter(string path, Column[] columns, WriteAction writeAction) - : this(new ParquetFileWriter(path, columns), writeAction) + internal ParquetRowWriter( + string path, + Column[] columns, + Compression compression, + IReadOnlyDictionary keyValueMetadata, + WriteAction writeAction) + : this(new ParquetFileWriter(path, columns, compression, keyValueMetadata), writeAction) { } - internal ParquetRowWriter(OutputStream outputStream, Column[] columns, WriteAction writeAction) - : this(new ParquetFileWriter(outputStream, columns), writeAction) + internal ParquetRowWriter( + OutputStream outputStream, + Column[] columns, + Compression compression, + IReadOnlyDictionary keyValueMetadata, + WriteAction writeAction) + : this(new ParquetFileWriter(outputStream, columns, compression, keyValueMetadata), writeAction) { }