Skip to content

[Epic] Transform Correlated Subquery Into Dependent Join #16173

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

Open
7 tasks
Tracked by #16059
irenjj opened this issue May 24, 2025 · 0 comments
Open
7 tasks
Tracked by #16059

[Epic] Transform Correlated Subquery Into Dependent Join #16173

irenjj opened this issue May 24, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@irenjj
Copy link
Contributor

irenjj commented May 24, 2025

Is your feature request related to a problem or challenge?

As the first step implementation of the HyPer paper 'Unnesting Arbitrary Queries', it will converts correlated subqueries into the form of dependent joins.
In DuckDB:

┌─────────────────────────────┐
│┌───────────────────────────┐│
││ Unoptimized Logical Plan  ││
│└───────────────────────────┘│
└─────────────────────────────┘
┌───────────────────────────┐
│         PROJECTION        │
│    ────────────────────   │
│        Expressions:       │
│             id            │
│           value           │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│           FILTER          │
│    ────────────────────   │
│        Expressions:       │
│  (CAST(value AS BIGINT) > │
│          SUBQUERY)        │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│       DEPENDENT_JOIN      │
│    ────────────────────   ├──────────────┐
│     Join Type: SINGLE     │              │
└─────────────┬─────────────┘              │
┌─────────────┴─────────────┐┌─────────────┴─────────────┐
│          SEQ_SCAN         ││         PROJECTION        │
│    ────────────────────   ││    ────────────────────   │
│       Table: table1       ││        Expressions:       │
│   Type: Sequential Scan   ││        count_star()       │
└───────────────────────────┘└─────────────┬─────────────┘
                             ┌─────────────┴─────────────┐
                             │         AGGREGATE         │
                             │    ────────────────────   │
                             │        Expressions:       │
                             │        count_star()       │
                             └─────────────┬─────────────┘
                             ┌─────────────┴─────────────┐
                             │           FILTER          │
                             │    ────────────────────   │
                             │        Expressions:       │
                             │       (ref_id = id)       │
                             │ (CAST(quantity AS BIGINT) │
                             │        = SUBQUERY)        │
                             └─────────────┬─────────────┘
                             ┌─────────────┴─────────────┐
                             │       DEPENDENT_JOIN      │
                             │    ────────────────────   ├──────────────┐
                             │     Join Type: SINGLE     │              │
                             └─────────────┬─────────────┘              │
                             ┌─────────────┴─────────────┐┌─────────────┴─────────────┐
                             │          SEQ_SCAN         ││         PROJECTION        │
                             │    ────────────────────   ││    ────────────────────   │
                             │       Table: table2       ││        Expressions:       │
                             │   Type: Sequential Scan   ││        count_star()       │
                             └───────────────────────────┘└─────────────┬─────────────┘
                                                          ┌─────────────┴─────────────┐
                                                          │         AGGREGATE         │
                                                          │    ────────────────────   │
                                                          │        Expressions:       │
                                                          │        count_star()       │
                                                          └─────────────┬─────────────┘
                                                          ┌─────────────┴─────────────┐
                                                          │           FILTER          │
                                                          │    ────────────────────   │
                                                          │        Expressions:       │
                                                          │         (id = id)         │
                                                          └─────────────┬─────────────┘
                                                          ┌─────────────┴─────────────┐
                                                          │          SEQ_SCAN         │
                                                          │    ────────────────────   │
                                                          │       Table: table1       │
                                                          │   Type: Sequential Scan   │
                                                          └───────────────────────────┘

Describe the solution you'd like

I'd like to split into follow small tasks:

  • Transform scalar correlated subqueries in WHERE to DependentJoin: Transform scalar correlated subqueries in Where to DependentJoin #16172
  • Transform scalar correlated subqueries in SELECT to DependentJoin:
  • Transform scalar correlated subqueries in FROM to DependentJoin:
  • Transform scalar correlated subqueries in PROJECTION to DependentJoin:
  • Transform scalar correlated subqueries in UNNEST to DependentJoin:
  • Transform scalar correlated subqueries in WINDOW to DependentJoin:
  • Other subquery type support:
    ...

Describe alternatives you've considered

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant