Add option to avoid additional generated EquivalenceCalss for RelabelType in cdb_pull_up_eclass. #1305
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix issue #1301
For partition tables, cdb_pull_up_eclass will call get_eclass_for_sort_expr to find an existing equivalence class it is a member of. It will fail and build a new single-member EquivalenceClass for it when there is RelabelType. That will cause cdbpath_match_preds_to_both_distkeys return false even the locus are compatible because the RestrictInfo's left_ec/right_ec and rel's distribution key's dk_eclasses are two different pointers.
And unnecessary Motions will be added in that case.
cdbpullup_findEclassInTargetList() will ignore the presence or absence of a RelabelType node atop either expr in determining whether an EC member expr matches a targetlist expr. But get_eclass_for_sort_expr() didn't handle additional RelabelType and a new EC may be generated. We should not disturb get_eclass_for_sort_expr() as it's used at many places and UPSTREAM didn't add RelabelType to EC for that case.
If find a sub_distkeyexpr from cdbpullup_findEclassInTargetList and we know that there is RelabelType stripped inside, we don't need to try to fetch or generate new EC in get_eclass_for_sort_expr(). So, add options for cdb_pull_up_eclass to ignore RelabelType when needed.
Authored-by: Zhang Mingli [email protected]
Fixes #ISSUE_Number
What does this PR do?
Type of Change
Breaking Changes
Test Plan
make installcheckmake -C src/test installcheck-cbdb-parallelImpact
Performance:
User-facing changes:
Dependencies:
Checklist
Additional Context
CI Skip Instructions