opteryx
opteryx copied to clipboard
[Optimizer] Function to pushable ops
trafficstars
Summary
The expression EXTRACT(YEAR FROM x) = n is not currently pushable, which results in a full table scan even when the filter is selective. We should rewrite this filter into an equivalent range predicate that can be pushed to the storage engine.
Example
Before (unpushable):
SELECT *
FROM data.missions
WHERE EXTRACT(YEAR FROM launch_date) = 2020;
After (pushable)
SELECT *
FROM data.missions
WHERE launch_date >= DATE '2020-01-01'
AND launch_date < DATE '2021-01-01';