-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
release-21.2: sql: do not collect statistics on virtual columns #71234
Conversation
PR #68312 intended to update the behavior of `CREATE STATISTICS` to prevent statistics collection on virtual computed columns. However, it failed to account for multi-column statistics and for `CREATE STATISTICS` statements that explicitly reference virtual columns. This commit accounts for these two cases. This prevents internal errors from occuring when the system tries to collect statistics on `NOT NULL` virtual columns. Virtual column values are not included in the primary index. So when the statistics job reads the primary index to sample the virtual column, it assumes the value is null, which violates the column's `NOT NULL` constraint. This violation causes an error. Fixes #71080 Release note (bug fix): A bug has been fixed which caused internal errors when collecting statistics on tables with virtual computed columns.
152a365
to
bb0bd11
Compare
Thanks for opening a backport. Please check the backport criteria before merging:
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
Add a brief release justification to the body of your PR to justify this backport. Some other things to consider:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for 21.2.1 (unless you think this is a release blocker?)
Do we need to backport #68312 as well, or is that already included in 21.2?
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @cucaroach)
I think this can wait for 21.2.1. I've confirmed that #68312 is already included in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 2 of 0 LGTMs obtained (waiting on @mgartner)
Backport 1/1 commits from #71105 on behalf of @mgartner.
/cc @cockroachdb/release
PR #68312 intended to update the behavior of
CREATE STATISTICS
toprevent statistics collection on virtual computed columns. However, it
failed to account for multi-column statistics and for
CREATE STATISTICS
statements that explicitly reference virtualcolumns. This commit accounts for these two cases.
This prevents internal errors from occuring when the system tries to
collect statistics on
NOT NULL
virtual columns. Virtual column valuesare not included in the primary index. So when the statistics
job reads the primary index to sample the virtual column, it assumes the
value is null, which violates the column's
NOT NULL
constraint. Thisviolation causes an error.
Fixes #71080
Release note (bug fix): A bug has been fixed which caused internal
errors when collecting statistics on tables with virtual computed
columns.
Release justification: This fixes internal errors when collecting statistics
on tables with virtual computed columns.