cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

raise Py4JJavaError while changing data type of a column

Marinagomes
New Contributor

Hi

I'm using Azure databricks 10.4 LTS (includes Apache Spark 3.2.1, Scala 2.12). I'm trying to convert 2 columns from string data type to timestamp data type . My date columns are in below format

2/18/2021 7:20:12 PM

So I wrote following command

from pyspark.sql.functions import to_timestamp


(
spark.read
.table("convertToTimeStamp")
.withColumn("JoiningDate",to_timestamp("JoiningDate", "dd/MM/yyyy HH:mm:ss"))
.withColumn("EndDate",to_timestamp("EndDate", "dd/MM/yyyy HH:mm:ss"))
.write
.format("delta")
.mode("overwrite")
.option("overwriteSchema", True)
.saveAsTable("convertToTimeStamp")
)

But I'm getting error message saying that

raise Py4JJavaError(
"An error occurred while calling {0}{1}{2}.\n".
format(target_id, ".", name), value)

Can you please help me to resolve the issue?

0 REPLIES 0

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group