i have column in spark dataframe which has integer. how to generate a new column by adding one to each value in column using Spark Java
答案 0 :(得分:1)
You can use df.withColumn to add the new column to the Dataframe.
import static org.apache.spark.sql.functions.col;
DataFrame df2 = df1.withColumn("new_column", col("column_name").plus(1));