Cast in a field filter hinders optimization

Hi, thanks for the great product. I have a large PostgreSQL table partitioned by month. When using a field filter with the date, Metabase generates the following SQL:

... where CAST("public"."table"."event_date" AS date) between $1 and $2

Unfortunately, this SQL statement scans all partitions (try EXPLAIN ANALYZE) and thus is very slow. If you remove the CAST, PostgreSQL version 11 will be able to optimize it to access only the relevant partition:

... where "public"."table"."event_date" between '2019-06-01' and '2019-06-30 23:59:59'

Can you please remove the CAST? Thanks again and keep up the great work!

Hi @W7T4
Have a read at this issue - there’s a PR already, which hasn’t been merged yet, but it’s scheduled for version 0.33 (that’s not always a guarantee)