Skip to content

Conversation

@Tmonster
Copy link
Contributor

fixes https://github.com/duckdblabs/duckdb-internal/issues/1807

In queries where a correlated subquery requires a delim get, we want to preserve positionally of columns. Operators can get moved around and when operators get moved around the positionally of columns can change. This is especially bad when you have set operations, where positionally is important.

A delim_get is introduced with a cross product. The children of a cross product can be flipped around by the join order optimizer, affecting the positionally of the columns. With this fix, if a projecition wants to introduce a delim get, the delim get cross product is produced under it.

@Tmonster Tmonster requested review from Mytherin and lnkuiper April 24, 2024 12:54
@Tmonster Tmonster changed the title BUGFix Introducing Introducing Delim Joins and Denim gets should respect positionally BugFix: Introducing Introducing Delim Joins and Denim gets should respect positionally Apr 24, 2024
@Tmonster Tmonster changed the title BugFix: Introducing Introducing Delim Joins and Denim gets should respect positionally BugFix: Introducing Introducing Delim Joins and Delim_Get(s) should respect positionally Apr 24, 2024
@duckdb-draftbot duckdb-draftbot marked this pull request as draft April 26, 2024 08:33
@Tmonster Tmonster marked this pull request as ready for review April 26, 2024 08:34
Copy link
Collaborator

@lnkuiper lnkuiper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just two minor comments:

)
FROM all_types outer_alltypes GROUP BY ALL;

mode skip
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the skip here intentional?

// first check if the logical operator has correlated expressions
auto entry = has_correlated_expressions.find(*plan);
bool exit_projection = false;
unique_ptr<LogicalDelimGet> delim_scan = nullptr;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: unique_ptr is initialized to nullptr by default

@duckdb-draftbot duckdb-draftbot marked this pull request as draft April 29, 2024 14:35
Copy link
Collaborator

@lnkuiper lnkuiper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now, thanks!

@Tmonster Tmonster marked this pull request as ready for review April 29, 2024 15:04
@Mytherin Mytherin merged commit 7a66e2e into duckdb:main Apr 30, 2024
@Mytherin
Copy link
Collaborator

Thanks!

github-actions bot pushed a commit to duckdb/duckdb-r that referenced this pull request May 5, 2024
Merge pull request duckdb/duckdb#11812 from Tmonster/delim_joins_and_reordering
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants