cast
Casts the type of values in the columns previously selected by gather without modifying the values themselves.
This is useful when the type cannot be automatically inferred and needs to be explicitly specified for further Gather operations such as filter, notNull, or mapValues. It does not affect the actual content of the values — only the type used for compile-time safety and transformation configuration.
This is an intermediate step; returns a new Gather instance with an updated value type parameter.
For more information, see: See gather on the documentation website.
See also: Grammar.
Example
// Gather all subcolumns in the "results" column group into a single "value" column,
// with the "series" column containing a key.
// After `cast`, values are treated as Float in `filter` and `mapValues`.
df.gather { results.cols() }
.cast<Float>()
.filter { it > 0.05 }
.mapValues { (it + 0.5f).toDouble() }
.into("series", "value")Content copied to clipboard
Return
A new Gather instance with the specified value type.