Is it possible to check if a date(yyymmdd) is valid in spark SQL? I have tried the following:
TO_DATE(CAST(UNIX_TIMESTAMP(CAST(UNIX_TIMESTAMP(colname, 'yyyymmdd') AS TIMESTAMP))) IS NOT NULL
Thanks, Bharath
You could try
set spark.sql.legacy.timeParserPolicy=CORRECTED;
before the select. This policy allows invalid dates to be casted as null.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With