Skip to content
Advertisement

spark java how to select newly added column using withcolumn

I am trying to create java spark program and trying to add anew column using

JavaScript

and when I am trying to select with

JavaScript

its saying Cannot reslove column name newColumn. Can some one please help me how to do this in Java?

Advertisement

Answer

qdf is the dataframe before you added the newColumn which is why you are unable to select it with qdf.col("newColumn").

To get a handle on it you can use functions.col("newColumn") e.g.

JavaScript

Alternatively you can store the dataframe after calling withColumn and it should then be accessible e.g.

JavaScript

Or you can use raw strings as in Srinivas’s answer.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement