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


##########
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:
   should we bother actively listing these out? it might make more sense to 
just explicitly have cases for the types we don't support to return false and 
then just default return true?
   
   just to shrink this



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to