注意检查是否指定了分区,如果使用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')