forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opt: move self-join equality inference to join elimination rules
PR cockroachdb#105214 added logic to infer equivalences for a join that is performing a self-join with an equality between the same columns, and those columns form a key over both inputs. This missed the fact that, for nullable columns from the self-join table, the inferred equivalences are actually *lax*, as opposed to strict. A strict equivalence captures the behavior of the SQL `=` operator; strictly equivalent columns have the same value for every row and no NULL values. A lax equivalence is similar, but without the restriction on NULL values. If one column is NULL for a given row, the other must still be NULL at that row. Adding all the inferred equivalences as strict could cause other rules that depend on functional dependencies to perform incorrect transformations; e.g. adding an invalid filter. This patch moves the equivalence-inference logic to the join-elimination rules. This is valid because column remapping only cares about the "col1 and col2 have the same values for every row" semantics of lax equivalences. If some of those values are NULL, the remapping is still valid. This ensures that the inferred lax equivalences are only seen by the join-elimination rules, which know how to handle them. Fixes cockroachdb#105608 Release note: None
- Loading branch information
1 parent
fa47de0
commit 845db73
Showing
11 changed files
with
375 additions
and
306 deletions.
There are no files selected for viewing
148 changes: 100 additions & 48 deletions
148
pkg/sql/opt/exec/execbuilder/testdata/sql_activity_stats_compaction
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.