Comments (11)
I confirm that 1b396c4 fixes our more involved case in practice.
from arrow-datafusion.
I think this is related #10660
from arrow-datafusion.
Thanks for the pointers @duongcongtoai
I think the recursive and max_depth options can be a special workaround, but introduce a good amount of complexity. Fixing the push down makes single unnest
composable in general.
from arrow-datafusion.
alternative query
Yes. The problem is that one can't move the filter to the inner query (views) or one shouldn't have to with other common sql constructs (sub queries, ctes).
from arrow-datafusion.
I think we can rewrite Unnest plan in push down filter
from arrow-datafusion.
Thanks for the swift action.
I just found out this second, that the change introduces a new issue when filtering on an unnested struct column (Optimizer rule 'common_sub_expression_eliminate' failed
). Sorry for being late.
I'll file a new issue. The reproducer is less trivial as here.
from arrow-datafusion.
I confirm that 1b396c4 fixes our more involved case in practice.
Thank you @jayzhan211 for the quick response
from arrow-datafusion.
For this kind of query select unnest(unnest([[1],[1,2],[1,2,3]]));
, I think we can follow what Duckdb does.
Unnest with recursive, and max_depth
select unnest([[1],[1,2],[1,2,3]], recursive := true);
or select unnest([[1],[1,2],[1,2,3]], max_depth := 2);
from arrow-datafusion.
@ahirner
I found an alternative query is to move filter into the query
select "unnest(v.column2)" from (select unnest(column2), column1 from v where column1=2);
query TT
explain select "unnest(v.column2)" from (select unnest(column2), column1 from v where column1=2);
----
logical_plan
01)Projection: unnest(v.column2)
02)--Unnest: lists[unnest(v.column2)] structs[]
03)----Projection: v.column2 AS unnest(v.column2), v.column1
04)------Filter: v.column1 = Int64(2)
05)--------TableScan: v projection=[column1, column2]
physical_plan
01)ProjectionExec: expr=[unnest(v.column2)@0 as unnest(v.column2)]
02)--UnnestExec
03)----RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
04)------ProjectionExec: expr=[column2@1 as unnest(v.column2), column1@0 as column1]
05)--------CoalesceBatchesExec: target_batch_size=8192
06)----------FilterExec: column1@0 = 2
07)------------MemoryExec: partitions=1, partition_sizes=[1]
Given that, it might not be necessary to support pushing down outer filter
from arrow-datafusion.
PR to do so: #10974
from arrow-datafusion.
Added issue that's quite minimal but maybe not entirely minimal: #10990
from arrow-datafusion.
Related Issues (20)
- `BinaryExpr` evaluate lacks optimization for `Or` and `And` scenarios HOT 14
- Register SQL planners in `SessionState::new()` HOT 4
- Implement user defined planner for `date_part`
- Implement user defined planner for `create_struct` HOT 1
- Implement user defined planner for `create_named_struct` HOT 1
- Implement user defined planner for `sql_overlay_to_expr` HOT 1
- BinaryOp supporting multiple parameters in Substrait
- Support `COUNT()` in addition to `COUNT(*)` HOT 1
- Replace `println!` with `assert!` if possible in DataFusion examples HOT 3
- Implement Substrait support for SubqueryType::Scalar
- HashJoin for nested types give wrong results
- Clean Up Data Page Statistics Tests and Fix Bug HOT 1
- Implement user defined planner for sql_position_to_expr
- Implement user defined planner for `sql_compound_identifier_to_expr`
- Implement user defined planner for `sql_substring_to_expr `
- Implement user defined planner for `sql_position_to_expr`
- `where` clause incorrectly reject `NULL` literal (by SQLancer-NoREC) HOT 1
- Make error message better when `bitwise_*` operator takes wrong argument type HOT 1
- Improve error message for wrong argument type in operators
- Error evaluating clause `where COL_BIGINT < 1e100` (Found by SQLancer-NoREC) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arrow-datafusion.