【发布时间】:2025-11-26 03:55:02
【问题描述】:
我已尝试使用此处指定的 withColumn 的解决方案:
How to cast all columns of Spark dataset to string using Java
但是,该解决方案会影响大量列(1k-6k)的性能。它需要超过 6 个小时,然后中止。
或者,我正在尝试使用 map 进行如下投射,但在这里出现错误:
MapFunction<Column, Column> mapFunction = (c) -> {
return c.cast("string");
};
dataset = dataset.map(mapFunction, Encoders.bean(Column.class));
上面的 sn-p 错误:
The method map(Function1<Row,U>, Encoder<U>) in the type Dataset<Row> is not applicable for the arguments (MapFunction<Column,Column>, Encoder<Column>)
进口使用:
import org.apache.spark.api.java.function.MapFunction;
【问题讨论】:
标签: java apache-spark casting