Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
improve Coerce to cast all columns with '*' [nt]
Browse files Browse the repository at this point in the history
  • Loading branch information
flarco committed Nov 25, 2023
1 parent bc540fe commit 3c22382
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions iop/datatype.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,18 @@ func (cols Columns) Coerce(castCols Columns, hasHeader bool) (newCols Columns) {
newCols[i].Type = StringType
}
}

if len(castCols) == 1 && castCols[0].Name == "*" {
col = castCols[0]
if col.Type.IsValid() {
g.Debug("casting column '%s' as '%s'", newCols[i].Name, col.Type)
newCols[i].Type = col.Type
} else {
g.Warn("Provided unknown column type (%s) for column '%s'. Using string.", col.Type, col.Name)
newCols[i].Type = StringType
}

}
}
return newCols
}
Expand Down

0 comments on commit 3c22382

Please sign in to comment.