You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ze...@apache.org on 2022/05/14 17:08:12 UTC

[arrow] branch master updated: ARROW-16561 [Go][Parquet] test for parquet root node configuration

This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 089592f606 ARROW-16561 [Go][Parquet] test for parquet root node configuration
089592f606 is described below

commit 089592f6060405e3067abcddca608c2b41193bb5
Author: Mark Wolfe <ma...@wolfe.id.au>
AuthorDate: Sat May 14 13:08:06 2022 -0400

    ARROW-16561 [Go][Parquet] test for parquet root node configuration
    
    As requested in #13139 I have added a test with some example configuration to verify it works as intended.
    
    I added it to the schema test as well as that is where I am using it, hopefully that is fine @zeroshade .
    
    Closes #13156 from wolfeidau/ARROW-16561-customise-root-node-test
    
    Authored-by: Mark Wolfe <ma...@wolfe.id.au>
    Signed-off-by: Matt Topol <zo...@gmail.com>
---
 go/parquet/pqarrow/schema_test.go           | 31 +++++++++++++++++++++++++++++
 go/parquet/reader_writer_properties_test.go |  6 +++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/go/parquet/pqarrow/schema_test.go b/go/parquet/pqarrow/schema_test.go
index ae82e65d93..ae17ec057f 100644
--- a/go/parquet/pqarrow/schema_test.go
+++ b/go/parquet/pqarrow/schema_test.go
@@ -61,6 +61,37 @@ func TestGetOriginSchemaBase64(t *testing.T) {
 	}
 }
 
+func TestToParquetWriterConfig(t *testing.T) {
+	origSc := arrow.NewSchema([]arrow.Field{
+		{Name: "f1", Type: arrow.BinaryTypes.String},
+		{Name: "f2", Type: arrow.PrimitiveTypes.Int64},
+	}, nil)
+
+	tests := []struct {
+		name           string
+		rootRepetition parquet.Repetition
+	}{
+		{"test1", parquet.Repetitions.Required},
+		{"test2", parquet.Repetitions.Repeated},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+
+			pqschema, err := pqarrow.ToParquet(origSc,
+				parquet.NewWriterProperties(
+					parquet.WithRootName(tt.name),
+					parquet.WithRootRepetition(tt.rootRepetition),
+				),
+				pqarrow.DefaultWriterProps())
+			require.NoError(t, err)
+
+			assert.Equal(t, tt.name, pqschema.Root().Name())
+			assert.Equal(t, tt.rootRepetition, pqschema.Root().RepetitionType())
+		})
+	}
+}
+
 func TestConvertArrowFlatPrimitives(t *testing.T) {
 	parquetFields := make(schema.FieldList, 0)
 	arrowFields := make([]arrow.Field, 0)
diff --git a/go/parquet/reader_writer_properties_test.go b/go/parquet/reader_writer_properties_test.go
index 714fa59185..d500a8814a 100644
--- a/go/parquet/reader_writer_properties_test.go
+++ b/go/parquet/reader_writer_properties_test.go
@@ -48,7 +48,9 @@ func TestWriterPropAdvanced(t *testing.T) {
 		parquet.WithCompression(compress.Codecs.Snappy),
 		parquet.WithEncoding(parquet.Encodings.DeltaBinaryPacked),
 		parquet.WithEncodingFor("delta-length", parquet.Encodings.DeltaLengthByteArray),
-		parquet.WithDataPageVersion(parquet.DataPageV2))
+		parquet.WithDataPageVersion(parquet.DataPageV2),
+		parquet.WithRootName("test2"),
+		parquet.WithRootRepetition(parquet.Repetitions.Required))
 
 	assert.Equal(t, compress.Codecs.Gzip, props.CompressionPath(parquet.ColumnPathFromString("gzip")))
 	assert.Equal(t, compress.Codecs.Zstd, props.CompressionFor("zstd"))
@@ -56,6 +58,8 @@ func TestWriterPropAdvanced(t *testing.T) {
 	assert.Equal(t, parquet.Encodings.DeltaBinaryPacked, props.EncodingFor("gzip"))
 	assert.Equal(t, parquet.Encodings.DeltaLengthByteArray, props.EncodingPath(parquet.ColumnPathFromString("delta-length")))
 	assert.Equal(t, parquet.DataPageV2, props.DataPageVersion())
+	assert.Equal(t, "test2", props.RootName())
+	assert.Equal(t, parquet.Repetitions.Required, props.RootRepetition())
 }
 
 func TestReaderPropsGetStreamInsufficient(t *testing.T) {