-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
opt: remove non-equivalent group columns in OrderingChoice.Simplify #64342
Conversation
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! 1 of 0 LGTMs obtained (waiting on @mgartner and @rytaft)
pkg/sql/opt/props/physical/ordering_choice.go, line 523 at r1 (raw file):
} // Check whether new equivalent columns can be added by the FD set.
[nit] Check whether the equivalency group needs to change.
Previously, `OrderingChoice.Simplify` would add but never remove columns from ordering column groups based on equivalency in an FD. In rare cases, this could cause the optimizer to generate expressions which violated an invariant that all columns in an ordering column group are equivalent according to the expression's FD. Violation of this invariant only panics in test builds, and in the test cases found that trigger this panic, there is likely no correctness issues with the expression. Therefore, there was probably no impact in any release builds. This commit updates `OrderingChoice.Simplify` so that non-equivalent columns in an ordering column group are removed from the group, satisfying the invariant. Fixes cockroachdb#63794 Release note: None
a0dd8b4
to
ecfff8c
Compare
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! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @rytaft)
pkg/sql/opt/props/physical/ordering_choice.go, line 523 at r1 (raw file):
Previously, RaduBerinde wrote…
[nit] Check whether the equivalency group needs to change.
Done.
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.
Reviewed 3 of 4 files at r1, 1 of 1 files at r2.
Reviewable status: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @mgartner)
TFTRs! bors r+ |
Build succeeded: |
Previously, `projectCanProvideOrdering` did not simplify an ordering base on an FD set if the original ordering could be provided, while `projectBuildChildReqOrdering` always attempted to simplify an ordering. In cockroachdb#64342 the behavior of `OrderingChoice.Simplify` changed to remove columns in groups that are not known to be equivalent by the FD. As a result, `projectCanProvideOrdering` could return true in cases where the simplified ordering, with some columns removed, could not be provided, causing `ordering.projectBuildChildReqOrdering` to panic. This commit updates `ordering.projectCanProvideOrdering` so that the ordering is always simplified, matching the behavior of `ordering.projectBuildChildReqOrdering`. Fixes cockroachdb#64399 Release note: None
Previously, `projectCanProvideOrdering` did not simplify an ordering base on an FD set if the original ordering could be provided, while `projectBuildChildReqOrdering` always attempted to simplify an ordering. In cockroachdb#64342 the behavior of `OrderingChoice.Simplify` changed to remove columns in groups that are not known to be equivalent by the FD. As a result, `projectCanProvideOrdering` could return true in cases where the simplified ordering, with some columns removed, could not be provided, causing `ordering.projectBuildChildReqOrdering` to panic. This commit updates `ordering.projectCanProvideOrdering` so that the ordering is always simplified, matching the behavior of `ordering.projectBuildChildReqOrdering`. Fixes cockroachdb#64399 Release note: None
64306: pgcode: remove a couple of deprecated errors r=yuzefovich a=yuzefovich Release note: None 64441: ccl/sqlproxyccl: fix a broken test in bazel r=darinpp a=darinpp This fixes #61915 by adding the required data files. Release note: None 64444: opt: do not provide project ordering for columns removed when simplified r=mgartner a=mgartner Previously, `projectCanProvideOrdering` did not simplify an ordering base on an FD set if the original ordering could be provided, while `projectBuildChildReqOrdering` always attempted to simplify an ordering. In #64342 the behavior of `OrderingChoice.Simplify` changed to remove columns in groups that are not known to be equivalent by the FD. As a result, `projectCanProvideOrdering` could return true in cases where the simplified ordering, with some columns removed, could not be provided, causing `ordering.projectBuildChildReqOrdering` to panic. This commit updates `ordering.projectCanProvideOrdering` so that the ordering is always simplified, matching the behavior of `ordering.projectBuildChildReqOrdering`. Fixes #64399 Release note: None 64483: bazel: prefer `exec_tools` to `tools` in `BUILD` files r=rail a=rickystewart The [documentation](https://docs.bazel.build/versions/master/be/general.html#genrule_args) specifies that `exec_tools` is preferred to `tools` wherever possible. It doesn't matter in our case, so let's just standardize on `exec_tools` everywhere. Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]> Co-authored-by: Darin Peshev <[email protected]> Co-authored-by: Marcus Gartner <[email protected]> Co-authored-by: Ricky Stewart <[email protected]>
Previously, `projectCanProvideOrdering` did not simplify an ordering base on an FD set if the original ordering could be provided, while `projectBuildChildReqOrdering` always attempted to simplify an ordering. In cockroachdb#64342 the behavior of `OrderingChoice.Simplify` changed to remove columns in groups that are not known to be equivalent by the FD. As a result, `projectCanProvideOrdering` could return true in cases where the simplified ordering, with some columns removed, could not be provided, causing `ordering.projectBuildChildReqOrdering` to panic. This commit updates `ordering.projectCanProvideOrdering` so that the ordering is always simplified, matching the behavior of `ordering.projectBuildChildReqOrdering`. Fixes cockroachdb#64399 Release note: None
Previously,
OrderingChoice.Simplify
would add but never remove columnsfrom ordering column groups based on equivalency in an FD. In rare
cases, this could cause the optimizer to generate expressions which
violated an invariant that all columns in an ordering column group are
equivalent according to the expression's FD.
Violation of this invariant only panics in test builds, and in the test
cases found that trigger this panic, there is likely no correctness
issues with the expression. Therefore, there was probably no impact in
any release builds.
This commit updates
OrderingChoice.Simplify
so that non-equivalentcolumns in an ordering column group are removed from the group,
satisfying the invariant.
Fixes #63794
Release note: None