I have a table that is partitioned by date in the format yyyyMMdd. If I do a simple query like this:
SELECT COUNT(*) FROM MyTable WHERE Date >= '20140924'
then it will scan 3 days of data (today is the 26th). However I would like my query to always look at the last 3 days, so I write it like this
SELECT COUNT(*) FROM MyTable
WHERE date >= from_unixtime(unix_timestamp() - 259200, 'yyyyMMdd')
The problem is that now it scans every partition. Is there a way to get it to pre-calculate the part of the query after the greater than?