-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
When pushing predicates down into various storage systems, it is common for them to support single column predicates of the form
const OP column
SQL allows users to write predicates against columns using whatever format they deem useful, and inserts the appropriate CAST functions where needed.
For example
echo "1" > /tmp/foo.csv
cargo run -p datafusion-cli
And then run:
> CREATE EXTERNAL TABLE foo(ts double)
STORED AS CSV
LOCATION '/tmp/foo.csv';
0 rows in set. Query took 0 seconds.
> explain verbose select * from foo where ts < 5;
+-----------------------------------------+--------------------------------------------------------------------------+
| plan_type | plan |
+-----------------------------------------+--------------------------------------------------------------------------+
| logical_plan | Projection: #ts |
| | Filter: #ts Lt Int64(5) |
| | TableScan: foo projection=None |
| logical_plan after projection_push_down | Projection: #ts |
| | Filter: #ts Lt Int64(5) |
| | TableScan: foo projection=Some([0]) |
| logical_plan after projection_push_down | Projection: #ts |
| | Filter: #ts Lt Int64(5) |
| | TableScan: foo projection=Some([0]) |
| physical_plan | ProjectionExec: expr=[ts] |
| | FilterExec: ts < CAST(5 AS Float64) |
| | CsvExec: source=Path(/tmp/foo.csv: [/tmp/foo.csv]), has_header=false |
+-----------------------------------------+--------------------------------------------------------------------------+
4 rows in set. Query took 0 seconds.
You can see that the filter that was pushed down was ts < CAST(5 AS Float64) which is correct, but it will likely not be recognized by some storage systems (such as IOx).
Describe the solution you'd like
What I would like to see is the expression rewriter pass rewrite ts < CAST(5 AS Float64) into ts < 5.0 (aka do the cast at plan time)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request