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

Simplify planning of MERGE #23684

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

martint
Copy link
Member

@martint martint commented Oct 4, 2024

Currently, the planner inserts a projection of the following shape to assemble the merged row:

merge_row := (
    CASE
        WHEN ... THEN
            ROW(..., $not((present IS NULL)), <operation>, 0)
        WHEN ... THEN
            ROW(..., $not((present IS NULL)), <operation>, 1)
        ...
        ELSE
            ROW(<nulls>, $not((present IS NULL)), -1, -1)
    END)

This change replaces the ELSE branch to return a single null instead of a synthetic value with nulls. By reducing the size of the projection, it allows for wider tables to be used with MERGE.

Related to #15848

Release notes

(x) Release notes are required, with the following suggested text:

## Section
* TBD. ({issue}`issuenumber`)

@cla-bot cla-bot bot added the cla-signed label Oct 4, 2024
Copy link
Member

@djsstarburst djsstarburst left a comment

Choose a reason for hiding this comment

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

This looked good to me and it looks like all the CI tests pass. I wondered why the first test in TestDeleteAndInsertMergeProcessor was removed.

Currently, the planner inserts a projection of the following shape
to assemble the merged row:

    merge_row := (
        CASE
            WHEN ... THEN
                ROW(..., $not((present IS NULL)), <operation>, 0)
            WHEN ... THEN
                ROW(..., $not((present IS NULL)), <operation>, 1)
            ...
            ELSE
                ROW(<nulls>, $not((present IS NULL)), -1, -1)
        END)

This change replaces the ELSE branch to return a single null instead of a synthetic
value with nulls. By reducing the size of the projection, it allows for wider
tables to be used with MERGE.
@dougb
Copy link

dougb commented Oct 8, 2024

Hi, I tried this PR and it seems to help with one of the tables I was having trouble MERGING, thank you!
Will do some more testing tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants