convertTo
Converts all columns in the DataFrame to match a given schema Schema.
Related operations: Adjust schema, convert
Conversion to match the target schema is done mostly automatically; DataFrame knows how to convert between many types (see convert for details and the supported types).
However, if you have a custom type in your target schema, or the automatic conversion fails, you can provide a custom converter, parser, or filler for it. These have priority over the automatic ones.
Customization DSL:
convert<A>.with { it.toB() }Provides
convertTo<>()with the knowledge of how to convertAtoB
parser { YourType.fromString(it) }Provides
convertTo<>()with the knowledge of how to parse strings/chars intoYourTypeShortcut for
convert<String>().with { YourType.fromString(it) }Chars are treated as strings unless you explicitly specify
convert<Char>().with { YourType.fromChar(it) }
fill { some cols }.with { rowExpression }Makes
convertTo<>()fill missing (or existing) columns from the target schema with values computed by the given row expression