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

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


The following commit(s) were added to refs/heads/main by this push:
     new 9a829b2fbe GH-35302: [Go] Improve unsupported type error message in 
pqarrow (#35303)
9a829b2fbe is described below

commit 9a829b2fbecc21d55f6d18cc9e845873994cceec
Author: Herman Schaaf <[email protected]>
AuthorDate: Tue Apr 25 15:53:30 2023 +0100

    GH-35302: [Go] Improve unsupported type error message in pqarrow (#35303)
    
    
    * Closes: #35302
    
    Authored-by: Herman Schaaf <[email protected]>
    Signed-off-by: Matt Topol <[email protected]>
---
 go/parquet/pqarrow/schema.go      |  2 +-
 go/parquet/pqarrow/schema_test.go | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/go/parquet/pqarrow/schema.go b/go/parquet/pqarrow/schema.go
index 3b926242d6..4505cea3db 100644
--- a/go/parquet/pqarrow/schema.go
+++ b/go/parquet/pqarrow/schema.go
@@ -388,7 +388,7 @@ func fieldToNode(name string, field arrow.Field, props 
*parquet.WriterProperties
                }
                return schema.MapOf(field.Name, keyNode, valueNode, 
repFromNullable(field.Nullable), -1)
        default:
-               return nil, xerrors.New("not implemented yet")
+               return nil, fmt.Errorf("%w: support for %s", 
arrow.ErrNotImplemented, field.Type.ID())
        }
 
        return schema.NewPrimitiveNodeLogical(name, repType, logicalType, typ, 
length, fieldIDFromMeta(field.Metadata))
diff --git a/go/parquet/pqarrow/schema_test.go 
b/go/parquet/pqarrow/schema_test.go
index 219528a2e3..6862028169 100644
--- a/go/parquet/pqarrow/schema_test.go
+++ b/go/parquet/pqarrow/schema_test.go
@@ -410,3 +410,30 @@ func TestListStructBackwardCompatible(t *testing.T) {
        assert.NoError(t, err)
        assert.True(t, arrowSchema.Equal(arrsc))
 }
+
+// TestUnsupportedTypes tests the error message for unsupported types. This 
test should be updated
+// when support for these types is added.
+func TestUnsupportedTypes(t *testing.T) {
+       unsupportedTypes := []struct {
+               typ arrow.DataType
+       }{
+               // Non-exhaustive list of unsupported types
+               {typ: &arrow.Float16Type{}},
+               {typ: &arrow.DurationType{}},
+               {typ: &arrow.DayTimeIntervalType{}},
+               {typ: &arrow.MonthIntervalType{}},
+               {typ: &arrow.MonthDayNanoIntervalType{}},
+               {typ: &arrow.DenseUnionType{}},
+               {typ: &arrow.SparseUnionType{}},
+       }
+       for _, tc := range unsupportedTypes {
+               t.Run(tc.typ.ID().String(), func(t *testing.T) {
+                       arrowFields := make([]arrow.Field, 0)
+                       arrowFields = append(arrowFields, arrow.Field{Name: 
"unsupported", Type: tc.typ, Nullable: true})
+                       arrowSchema := arrow.NewSchema(arrowFields, nil)
+                       _, err := pqarrow.ToParquet(arrowSchema, nil, 
pqarrow.NewArrowWriterProperties())
+                       assert.ErrorIs(t, err, arrow.ErrNotImplemented)
+                       assert.ErrorContains(t, err, "support for 
"+tc.typ.ID().String())
+               })
+       }
+}

Reply via email to