Uh oh!
There was an error while loading. Please reload this page.
Fix Predicate Pushdown: split_members should be able to split aliased predicate - #1368
Conversation
viirya
commented
Nov 26, 2021
cc @Dandandan |
| Projection: #test.a\ | ||
| \n Filter: NOT #test.c AS test.c = Boolean(false)\ | ||
| \n Filter: #test.b AS test.b = Boolean(true)\ | ||
| \n Filter: NOT #test.c\ |
Dandandan
commented
Nov 27, 2021
thanks @viirya for the quick change / PR! I think this is a good change. I am wondering if there's more places where we don't want to add an alias. Also we probably need some more tests to cover filter pushdown in combination with other optimization passes like this one. Another thing to consider might be for the filter operation to ignore the alias. FYI @alamb WDYT |
alamb
left a comment
There was a problem hiding this comment.
I don't really understand how aliases can mess up filter push down (perhaps filter pushdown should be stripping off the aliases)?
| } else { | ||
| Ok(new_e) | ||
| match plan { | ||
| LogicalPlan::Filter { .. } => Ok(new_e), |
There was a problem hiding this comment.
I would like to recommend adding a comment here about why we don't add aliases for filter.
alamb
commented
Nov 27, 2021
Yeah, I suggest:
I "feel" like there should be nothing wrong with aliasing the output of a |
viirya
commented
Nov 28, 2021
Thanks. I'm adding a test for TPCH plans. I will take a look on Filter pushdown with aliases later. |
viirya
commented
Nov 28, 2021
Currently the filter_push_down rule fails on TPCH q10 with aliased on Filter because By adding |
| } | ||
| #[tokio::test] | ||
| async fn tpch_explain_q10() -> Result<()> { |
There was a problem hiding this comment.
Nice 👍
Maybe it would be good to have those in the tpch crate instead?
In that case we could include some / all other queries as well.
alamb
left a comment
There was a problem hiding this comment.
Thank you @viirya !
Would it be possible to move the tpch tests into the tpch crate, as suggested by @Dandandan as part of this PR?
Someone can add explain plans for the other TPCH queries as part of #1377 so I don't think that is necessary.
Thanks for sticking with this one and finding the elegant solution
| split_members(left, predicates); | ||
| split_members(right, predicates); | ||
| } | ||
| Expr::Alias(expr, _) => { |
| } | ||
| #[tokio::test] | ||
| async fn tpch_explain_q10() -> Result<()> { |
| \n Join: #customer.c_custkey = #orders.o_custkey\ | ||
| \n TableScan: customer projection=Some([0, 1, 2, 3, 4, 5, 7])\ | ||
| \n Filter: #orders.o_orderdate >= Date32(\"8674\") AND #orders.o_orderdate < Date32(\"8766\")\ | ||
| \n TableScan: orders projection=Some([0, 1, 4]), filters=[#orders.o_orderdate >= Date32(\"8674\"), #orders.o_orderdate < Date32(\"8766\")]\ |
There was a problem hiding this comment.
so lovely to see those filters pushed down ❤️
Thanks @alamb@Dandandan ! Yeah, if I find some time later to (or someone can) add tests for the other TPCH queries, we can move the test together. |
Which issue does this PR close?
Closes#1367.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?