2

I'm trying to run the following command:

df = df.withColumn("DATATmp", to_date($"DATA", "yyyyMMdd")) 

And getting this error:

<console>:34: error: too many arguments for method to_date: (e: org.apache.spark.sql.Column)org.apache.spark.sql.Column 

How could I specify the exactly function to import? Has another way to avoid this error?

EDIT: Spark version 2.1

2
  • Thats strange. Can you share sample input data so that we can try to. That error should not have occured at all Commented Mar 3, 2018 at 3:18
  • As Andrey specified only works for 2.2, my spark is 2.1, as a "recent" version I did not expect to have version issues and thought was a spark issue. Commented Mar 3, 2018 at 18:10

1 Answer 1

5

As can be seen in the detailed scaladoc, the to_date function with two parameters has been added in 2.2.0, whereas the one-argument version existed since 1.5.

If you are working with an older Spark version, either upgrade, or don't use this function.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.