Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: nest materialized cte within [materialized] cte #12322

Merged
merged 13 commits into from
Aug 9, 2023

Conversation

xudong963
Copy link
Member

@xudong963 xudong963 commented Aug 2, 2023

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

Support nesting materialized cte within [materialized]cte, such as

explain with t1 as materialized (select number as a from numbers(10)), t2 as (select a as b from t1) select t1.a from t1 join t2 on t1.a = t2.b;
----
MaterializedCTE
├── EvalScalar
│   ├── expressions: [numbers.number (#0)]
│   ├── estimated rows: 10.00
│   └── TableScan
│       ├── table: default.system.numbers
│       ├── read rows: 10
│       ├── read bytes: 80
│       ├── partitions total: 1
│       ├── partitions scanned: 1
│       ├── push downs: [filters: [], limit: NONE]
│       └── estimated rows: 10.00
└── EvalScalar
    ├── expressions: [t1.a (#0)]
    ├── estimated rows: 100.00
    └── HashJoin
        ├── join type: INNER
        ├── build keys: [t2.b (#0)]
        ├── probe keys: [t1.a (#0)]
        ├── filters: []
        ├── estimated rows: 100.00
        ├── EvalScalar(Build)
        │   ├── expressions: [t1.a (#0)]
        │   ├── estimated rows: 10.00
        │   └── CTEScan
        │       └── CTE index: 0
        └── CTEScan(Probe)
            └── CTE index: 0

Part of #12266


This change is Reviewable

@vercel
Copy link

vercel bot commented Aug 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
databend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 9, 2023 4:00am

@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Aug 2, 2023
@xudong963 xudong963 marked this pull request as draft August 2, 2023 03:02
@xudong963 xudong963 changed the title feat: nest materialized cte within cte feat: nest materialized cte within [materialized] cte Aug 2, 2023
@xudong963 xudong963 marked this pull request as ready for review August 7, 2023 03:45
@xudong963 xudong963 requested review from leiysky and Dousir9 August 7, 2023 03:45
@xudong963 xudong963 merged commit dc621fb into databendlabs:main Aug 9, 2023
@xudong963 xudong963 deleted the nest branch August 9, 2023 04:49
andylokandy pushed a commit to andylokandy/databend that referenced this pull request Nov 27, 2023
…2322)

* feat: nest materialized cte within cte

* nest materialized cte

* add test

* keep order

* fix binder

* use indexmap and fix subquery

* update

* delete some tests

* update

* refactor

* refactor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants