首页 > 代码库 > spark-sql case when 问题

spark-sql case when 问题

SELECT CASE (pmod(datediff(f0.`4168388__c_0`,‘1970-01-04‘),7)+1)  WHEN ‘1‘ THEN ‘星期日‘ WHEN ‘2‘ THEN ‘星期一‘ WHEN ‘3‘ THEN ‘星期二‘ WHEN ‘4‘ THEN ‘星期三‘ WHEN ‘5‘ THEN ‘星期四‘ WHEN ‘6‘ THEN ‘星期五‘ WHEN ‘7‘ THEN ‘星期六‘ ELSE ‘星期六‘ END AS d_4168393 FROM rr f0 ORDER BY d_4168393

2.0.1 中 case 后面不能直接跟 ( ,如果改成

SELECT CASE pmod(datediff(f0.`4168388__c_0`,‘1970-01-04‘),7)+1  WHEN ‘1‘ THEN ‘星期日‘ WHEN ‘2‘ THEN ‘星期一‘ WHEN ‘3‘ THEN ‘星期二‘ WHEN ‘4‘ THEN ‘星期三‘ WHEN ‘5‘ THEN ‘星期四‘ WHEN ‘6‘ THEN ‘星期五‘ WHEN ‘7‘ THEN ‘星期六‘ ELSE ‘星期六‘ END AS d_4168393 FROM user_96300_14776217442944168389 f0 ORDER BY d_4168393

则可以运行

在1.5.2中则不存在此问题


本文出自 “去买大白兔” 博客,转载请与作者联系!

spark-sql case when 问题