SQL 及 spark.sql.function的时间转换
时间转换
从时间戳转化到date: FROM_UNIXTIME(sample_timestamp/1000)
从date到时间戳: UNIX_TIMESTAMP(date)
spark.sql.function
具体函数
from pyspark.sql.functions import lead, lag, max, min, date_format, weekofyear, month,hour
转换到小时:df = df.withColumn(‘hour’, hour(‘sample_time’))