spark.sql("select CASE WHEN ((from_unixtime(unix_timestamp(dt,'yyyyMMdd'),'yyyyMMdd') == dt) or (from_unixtime(unix_timestamp(dt,'MMddyyyy'),'MMddyyyy') == dt)) then dt else '' end as dt, case WHEN ((from_unixtime(unix_timestamp(dt,'yyyyMMdd'),'yyyyMMdd') == dt) or (from_unixtime(unix_timestamp(dt,'MMddyyyy'),'MMddyyyy') == dt)) then 'Y' else 'dt: should be present in \"yyyyMMdd\" or \"MMddyyyy\" format' end as dt_flag from input").show(false)
In the above code I've written the query for accepting two formats yyyyMMdd and MMddyyyy
In this , multiple delimiters should be accepted like no delimiters,periods,commas,slashes,dashes for date type.
I'm not sure how to add those, please help me on this! Thanks in advance