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

sql: add assignment casts for UPSERTs #74763

Merged
merged 2 commits into from
Jan 13, 2022

Conversation

mgartner
Copy link
Collaborator

sql: add assignment casts for UPSERTs

Assignment casts are now added to query plans for upserts, including
UPSERT, INSERT .. ON CONFLICT DO NOTHING, and
INSERT .. ON CONFLICT DO UPDATE .. statements.

Assignment casts are a more general form of the logic for rounding
decimal values, so the use of round_decimal_values in mutations is no
longer needed. This logic has been removed.

Fixes #67083

There is no release note because the behavior of upserts should not
change with this commit.

Release note: None

sql: add logic tests for assignment casts of ON UPDATE expressions

Release note: None

@mgartner mgartner requested review from rytaft, RaduBerinde and a team January 12, 2022 20:31
@mgartner mgartner requested a review from a team as a code owner January 12, 2022 20:31
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm_strong: Nice work!

Reviewed 11 of 12 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner and @rytaft)


pkg/sql/opt/optbuilder/mutation_builder.go, line 724 at r1 (raw file):

}

// roundDecimalValues wraps each DECIMAL-related column (including arrays of

🥳

Assignment casts are now added to query plans for upserts, including
`UPSERT`, `INSERT .. ON CONFLICT DO NOTHING`, and
`INSERT .. ON CONFLICT DO UPDATE ..` statements.

Assignment casts are a more general form of the logic for rounding
decimal values, so the use of `round_decimal_values` in mutations is no
longer needed. This logic has been removed.

Fixes cockroachdb#67083

There is no release note because the behavior of upserts should not
change with this commit.

Release note: None
@mgartner mgartner force-pushed the assignment-cast-upsert branch from 7fefa78 to e7cab43 Compare January 12, 2022 22:44
Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

:lgtm: Awesome!

Reviewed 11 of 12 files at r1, 1 of 1 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @mgartner)

@mgartner mgartner force-pushed the assignment-cast-upsert branch from e7cab43 to ec66320 Compare January 13, 2022 14:52
@mgartner
Copy link
Collaborator Author

TFTRs!

bors r+

@craig
Copy link
Contributor

craig bot commented Jan 13, 2022

Build succeeded:

@craig craig bot merged commit ac5f637 into cockroachdb:master Jan 13, 2022
@mgartner mgartner deleted the assignment-cast-upsert branch January 13, 2022 16:27
@RaduBerinde
Copy link
Member


pkg/sql/opt/optbuilder/mutation_builder.go, line 724 at r1 (raw file):

Previously, RaduBerinde wrote…

🥳

I think @andy-kimball might be happy to see this complication now being naturally handled through assignment casts.

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

Successfully merging this pull request may close these issues.

opt: revisit use of round_decimal_values in optbuilder
4 participants