Spark DataFrame批量修改数据类型

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_33625560/article/details/84258344

rdd的算子分成Transformation和action算子,其中Transformation算子的操作每次都会生成一个新的rdd,所以在进行数据转换的时候如果单个列进行转换的话性能消耗比较严重,所以批量的操作进行都要减少执行次数。

	val colNames = df.schema.fieldNames
    val cols = colNames.map(f => df(f).cast(DoubleType))
    val test: DataFrame = testDf.select(cols: _*)

猜你喜欢

转载自blog.csdn.net/sinat_33625560/article/details/84258344
今日推荐