Created
June 13, 2017 14:29
-
-
Save TomLous/ae2c14633ab1df4349eb7595c988e84b 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
| import org.apache.spark.sql.SparkSession | |
| import org.apache.spark.sql.functions.from_unixtime | |
| val spark = SparkSession.builder() | |
| .master("local[2]") | |
| .appName("test") | |
| .getOrCreate() | |
| import spark.implicits._ | |
| val input = List( | |
| ("a",1497348453L), | |
| ("b",1497345453L), | |
| ("c",1497341453L), | |
| ("d",1497340453L) | |
| ).toDF("name", "timestamp") | |
| input.select( | |
| 'name, | |
| from_unixtime('timestamp, "yyyy.MM.dd.HH.mm.ss").alias("timestamp_formatted") | |
| ).show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment