What data type should be used for a time column

后端 未结 1 2012
我在风中等你
我在风中等你 2021-01-28 07:28

In my Spark appliction, I had to split the time and data and store them in separate column as follow:

val df5=df4.withColumn(\"read_date\",date_format(df4.col(\         


        
相关标签:
1条回答
  • 2021-01-28 08:32

    There is no DataType in Spark to hold 'HH:mm:ss' values. Instead you can use hour(), minute() and second() functions to represent the values respectively.

    All these functions return int types.

    hour(string date) -- Returns the hour of the timestamp: hour('2009-07-30 12:58:59') = 12, hour('12:58:59') = 12.
    
    minute(string date) -- Returns the minute of the timestamp.
    
    second(string date) -- Returns the second of the timestamp.
    
    0 讨论(0)
提交回复
热议问题