Skip to content

Commit

Permalink
regen test data
Browse files Browse the repository at this point in the history
  • Loading branch information
candiduslynx committed May 9, 2024
1 parent 7fe7b10 commit 51c9c6f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion csv/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func castFromString(rec arrow.Record, arrowSchema *arrow.Schema) (arrow.Record,
cols := make([]arrow.Array, rec.NumCols())
for c, f := range arrowSchema.Fields() {
col := rec.Column(c)
if isTypeSupported(f.Type) {
if typeSupported(f.Type) {
cols[c] = col
continue
}
Expand Down
4 changes: 2 additions & 2 deletions csv/testdata/TestWriteRead-default.csv

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions csv/testdata/TestWriteRead-with_delimiter.csv

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions csv/testdata/TestWriteRead-with_delimiter_headers.csv

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions csv/testdata/TestWriteRead-with_headers.csv

Large diffs are not rendered by default.

28 changes: 16 additions & 12 deletions csv/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func convertSchema(sch *arrow.Schema) *arrow.Schema {
fields := make([]arrow.Field, len(oldFields))
copy(fields, oldFields)
for i, f := range fields {
if !isTypeSupported(f.Type) {
if !typeSupported(f.Type) {
fields[i].Type = arrow.BinaryTypes.String
}
fields[i].Metadata = stripCQExtensionMetadata(fields[i].Metadata)
Expand All @@ -68,24 +68,28 @@ func convertSchema(sch *arrow.Schema) *arrow.Schema {
return newSchema
}

func isTypeSupported(t arrow.DataType) bool {
// list from arrow/csv/common.go
switch t.(type) {
// typeSupported copied from arrow/csv/common.go
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.Float32Type, *arrow.Float64Type:
case *arrow.StringType:
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:
case *arrow.BinaryType:
case *arrow.MapType:
return false
case arrow.ListLikeType:
return typeSupported(dt.Elem())
case *arrow.BinaryType, *arrow.LargeBinaryType, *arrow.FixedSizeBinaryType:
case arrow.ExtensionType:
return true
case *arrow.NullType:
default:
return false
}

return false
return true
}

// castToString casts extension columns or unsupported columns to string. It does not release the original record.
Expand All @@ -94,7 +98,7 @@ func castToString(rec arrow.Record) arrow.Record {
cols := make([]arrow.Array, rec.NumCols())
for c := 0; c < int(rec.NumCols()); c++ {
col := rec.Column(c)
if isTypeSupported(col.DataType()) {
if typeSupported(col.DataType()) {
cols[c] = col
continue
}
Expand Down

0 comments on commit 51c9c6f

Please sign in to comment.