candiduslynx commented on code in PR #41595:
URL: https://github.com/apache/arrow/pull/41595#discussion_r1594509669


##########
go/arrow/csv/common.go:
##########
@@ -239,21 +239,31 @@ func WithStringsReplacer(replacer *strings.Replacer) 
Option {
 
 func validate(schema *arrow.Schema) {
        for i, f := range schema.Fields() {
-               switch ft := f.Type.(type) {
-               case *arrow.BooleanType:
-               case *arrow.Int8Type, *arrow.Int16Type, *arrow.Int32Type, 
*arrow.Int64Type:
-               case *arrow.Uint8Type, *arrow.Uint16Type, *arrow.Uint32Type, 
*arrow.Uint64Type:
-               case *arrow.Float16Type, *arrow.Float32Type, *arrow.Float64Type:
-               case *arrow.StringType, *arrow.LargeStringType:
-               case *arrow.TimestampType:
-               case *arrow.Date32Type, *arrow.Date64Type:
-               case *arrow.Decimal128Type, *arrow.Decimal256Type:
-               case *arrow.ListType, *arrow.LargeListType, 
*arrow.FixedSizeListType:
-               case *arrow.BinaryType, *arrow.LargeBinaryType, 
*arrow.FixedSizeBinaryType:
-               case arrow.ExtensionType:
-               case *arrow.NullType:
-               default:
-                       panic(fmt.Errorf("arrow/csv: field %d (%s) has invalid 
data type %T", i, f.Name, ft))
+               if !typeSupported(f.Type) {
+                       panic(fmt.Errorf("arrow/csv: field %d (%s) has invalid 
data type %T", i, f.Name, f.Type))
                }
        }
 }
+
+func typeSupported(dt arrow.DataType) bool {
+       switch dt := dt.(type) {
+       case *arrow.BooleanType:
+       case *arrow.Int8Type, *arrow.Int16Type, *arrow.Int32Type, 
*arrow.Int64Type:
+       case *arrow.Uint8Type, *arrow.Uint16Type, *arrow.Uint32Type, 
*arrow.Uint64Type:
+       case *arrow.Float16Type, *arrow.Float32Type, *arrow.Float64Type:
+       case *arrow.StringType, *arrow.LargeStringType:
+       case *arrow.TimestampType:
+       case *arrow.Date32Type, *arrow.Date64Type:
+       case *arrow.Decimal128Type, *arrow.Decimal256Type:

Review Comment:
   I'd say `no`, as this allows explicitly listing what's supported, & won't 
fail on the newly added types (string view, list view?)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to