โ11-11-2024 03:31 AM
Hi there i have a simple Pyspark To_date function but fails due to days or months from 1-9 so
is there a nice easy way to get round this at all
Regards
Rob
โ11-13-2024 07:45 AM
Resolved using format_string
โ11-11-2024 03:52 AM
Hi @RobDineen,
You may try setting the timeParserPolicy to meet your use case needs.
When LEGACY, java.text.SimpleDateFormat is used for formatting and parsing dates/timestamps in a locale-sensitive manner, which is the approach before Spark 3.0.
When set to CORRECTED, classes from java.time.* packages are used for the same purpose. The default value is EXCEPTION, RuntimeException is thrown when we will get different results.
spark.conf.set("spark.sql.legacy.timeParserPolicy","LEGACY")
or
spark.sql("set spark.sql.legacy.timeParserPolicy=LEGACY")
โ11-11-2024 05:47 AM - edited โ11-11-2024 05:52 AM
i have been trying to solve it with the following New column on the fly,
if DayofMonth in (1,2,3,4,5,6,7,8,9) then put a 0 before, else leave as is.
obviously I'm trying to insert the 0 incorrectly. but wondering how?
nearly there
โ11-12-2024 01:53 AM
Hi @VZLA
any idea with the below work around, I'm nearly there.
โ11-13-2024 07:45 AM
Resolved using format_string
Passionate about hosting events and connecting people? Help us grow a vibrant local communityโsign up today to get started!
Sign Up Now