Hive和sparksql中的dayofweek

dayofweek在hive2.2.0开始支持
低版本的sparksql和hive中可用以下方式实现

 select 7- datediff(next_day('2018-03-12',"Sunday"),'2018-03-12').  
 select date_format('2018-03-12' ,'u').   
 select date_format(from_unixtime(unix_timestamp('20180313','yyyyMMdd'),'yyyy-MM-dd'),'u')

参考
Hive UDF
sparksql function

猜你喜欢

转载自blog.csdn.net/hjw199089/article/details/79526362