注意檢查是否指定了分區,如果使用datediff篩選一段時間內的數據,容易踩坑
where datediff(from_unixtime(unix_timestamp(${sdate},'yyyyMMdd'),'yyyy-MM-dd'),from_unixtime(unix_timestamp(sdt,'yyyyMMdd'),'yyyy-MM-dd'))>=0 -- 日期格式:yyyyMMdd and datediff(from_unixtime(unix_timestamp(${sdate},'yyyyMMdd'),'yyyy-MM-dd'),from_unixtime(unix_timestamp(sdt,'yyyyMMdd'),'yyyy-MM-dd'))<=90
hive sql無法識別上述這種指定分區的方式,可以指定具體的日期或其他方式解決,如sdt>=date_format(date_sub(from_unixtime(unix_timestamp(${sdate},'yyyyMMdd'),'yyyy-MM-dd'),90),'yyyyMMdd')