1

I am trying to replace a column in Dataset with value Y if it contains X.

import org.apache.spark.sql.functions.*;

public static void main(String[] args) {
    Dataset<Row> DS;//already created dataset
    DS = DS.withColumn(column,when(col(column) === "X", "Y"));
}

It is giving me compilation error of The method col(String) undefined in Eclipse. I dont know what I am doing wrong. Please help.

1 Answer 1

1

functions is a Scala object, so if you import * it has to be static:

import static org.apache.spark.sql.functions.*;
Sign up to request clarification or add additional context in comments.

1 Comment

Like stated at the beginning - function is a Scala object, which translates to Java singleton. Simplifying, you import static methods from the object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.