我正在运行pyspark。我正在尝试将日期格式保存为'YYYY-MM-DD HH:MM:SS',但它使用的是错误的数字格式。
您能帮我解决这个问题吗?
将数据帧保存到CSV文件中的代码:
df.repartition(1).write.format('com.databricks.spark.csv').mode('overwrite').option('dateFormat', 'yyyy-MM-dd HH:mm:ss').save(row['TargetPath'], quote='',sep='|',header='True',nullValue=None)
查询我正在运行:
select ROW_NUMBER() OVER(Order by null) as channel_id, a.*,from_utc_timestamp(current_timestamp(), 'YYYY-MM-DD HH:MM:SS') AS IM_INSERT_DT from (select distinct intrctn_mode as channel,''as sub_channel from vw_call union select distinct src as channel,sub_src as sub_channel from vw_case)a
我得到的输出:
channel_id|channel|sub_channel|IM_INSERT_DT
1|Phone|VIRAI Vendor|1579855481246000
2|Web|J&J.com|1579855481246000
3|Over the Counter||1579855481246000
4|Phone|Consumer Prezista|1579855481246000