Comments (2)
This is like an optimization for empty tables. The result above is when both t3 and t4 are empty. After insert some values, the plan displayed correctly.
> insert into t3 values (1,2), (2,3)
;
+-------+
| count |
+-------+
| 2 |
+-------+
1 row(s) fetched.
Elapsed 0.004 seconds.
> explain select count(*) from ((select distinct c1, c2 from t3 order by c1 ) union all (select distinct c2, c1 from t4 order by c1));
+---------------+-------------------------------------------------------------------------------------------+
| plan_type | plan |
+---------------+-------------------------------------------------------------------------------------------+
| logical_plan | Aggregate: groupBy=[[]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]] |
| | Union |
| | Projection: |
| | Sort: t3.c1 ASC NULLS LAST |
| | Projection: t3.c1 |
| | Aggregate: groupBy=[[t3.c1, t3.c2]], aggr=[[]] |
| | TableScan: t3 projection=[c1, c2] |
| | Projection: |
| | Sort: t4.c1 ASC NULLS LAST |
| | Projection: t4.c1 |
| | Aggregate: groupBy=[[t4.c2, t4.c1]], aggr=[[]] |
| | Projection: t4.c2, t4.c1 |
| | TableScan: t4 projection=[c1, c2] |
| physical_plan | AggregateExec: mode=Final, gby=[], aggr=[COUNT(*)] |
| | CoalescePartitionsExec |
| | AggregateExec: mode=Partial, gby=[], aggr=[COUNT(*)] |
| | RepartitionExec: partitioning=RoundRobinBatch(14), input_partitions=28 |
| | UnionExec |
| | ProjectionExec: expr=[] |
| | AggregateExec: mode=FinalPartitioned, gby=[c1@0 as c1, c2@1 as c2], aggr=[] |
| | CoalesceBatchesExec: target_batch_size=8192 |
| | RepartitionExec: partitioning=Hash([c1@0, c2@1], 14), input_partitions=14 |
| | RepartitionExec: partitioning=RoundRobinBatch(14), input_partitions=1 |
| | AggregateExec: mode=Partial, gby=[c1@0 as c1, c2@1 as c2], aggr=[] |
| | MemoryExec: partitions=1, partition_sizes=[1] |
| | ProjectionExec: expr=[] |
| | AggregateExec: mode=FinalPartitioned, gby=[c2@0 as c2, c1@1 as c1], aggr=[] |
| | CoalesceBatchesExec: target_batch_size=8192 |
| | RepartitionExec: partitioning=Hash([c2@0, c1@1], 14), input_partitions=1 |
| | AggregateExec: mode=Partial, gby=[c2@0 as c2, c1@1 as c1], aggr=[] |
| | MemoryExec: partitions=1, partition_sizes=[0] |
| | |
+---------------+-------------------------------------------------------------------------------------------+
2 row(s) fetched.
Elapsed 0.018 seconds.
> select count(*) from ((select distinct c1, c2 from t3 order by c1 ) union all (select distinct c2, c1 from t4 order by c1));
+----------+
| COUNT(*) |
+----------+
| 2 |
+----------+
1 row(s) fetched.
Elapsed 0.019 seconds.
from datafusion.
This is like an optimization for empty tables. The result above is when both t3 and t4 are empty. After insert some values, the plan displayed correctly.
I believe that is correct
You can see how the optimizer transforms the plan using EXPLAIN VERBOSE
from datafusion.
Related Issues (20)
- Ability to chunk download from object store HOT 3
- Improve consistency and documentation on error handling in in UDFs HOT 11
- Incorrect predicate evaluation result in a query (SQLancer-NoREC) HOT 1
- Internal error when regex operator `~` is used with `List`s (SQLancer)
- Incorrect `NULL` handling for regex match `~` (SQLancer)
- Document why nullable of list item does not map to schema of first argument
- Reduce copying in `CoalesceBatchesExec` for StringViews HOT 3
- Rewrite UDAF reversed expression name HOT 2
- Blog post with DataFusion July - Sep 2024 HOT 6
- A valid SQL query returned 'Schema error: ...' (SQLancer) HOT 1
- Optimize CASE expression for "expr or expr" usage HOT 1
- Allow custom planning behavior for selecting wildcard expression HOT 11
- functions_aggregate::expr_fn::approx_distinct should expose the function, not the module
- Support per-option value normalization
- Clippy CI failures on main after Rust 1.80 release HOT 2
- Allow comparison of Timestamps with different Timezones HOT 4
- Get Clippy clean for Rust 1.80 and run it on CI HOT 5
- `join_inner_two`, `join_inner_one_two_parts_left` and `join_inner_one_two_parts_right` fail with `force_hash_collisions` HOT 2
- `equijoin_full_and_condition_from_both` slt test fails with `force_hash_collisions`
- Window function test fails when `force_hash_collisions` is enabled
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 datafusion.