Reputation: 3392
This seems to be a simple task, but I cannot figure out how to do it with Scala in Spark (not PySpark).
I have a DataFrame df
with different columns. One of the columns has a type String
that should be changed to Long
. How can I do it?
If I execute this code, I get the compilation error Cannot resolve symbol col
:
df.withColumn("timestamp", col("timestamp").cast(LongType))
Upvotes: 5
Views: 15189
Reputation: 6095
I think you need to import org.apache.spark.sql.functions.col
to use col()
function.
Upvotes: 5