Created
September 13, 2019 16:55
-
-
Save dgadiraju/7f88e20d72fbc09b2f6b6fee1abed4ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def toDate(d: String) = { | |
val a = d.split("/") | |
(a(2) + "%02d".format(a(0).toInt) + "%02d".format(a(1).toInt)).toInt | |
} | |
toDate("7/3/2019") | |
toDate("10/3/2019") | |
val toDateUDF = org.apache.spark.sql.functions.udf(toDate _) | |
val df = Seq("7/3/2019", "10/3/2019", "10/10/2019", "3/10/2019").toDF | |
df.select(toDateUDF($"value")).show |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment