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

planner: fix column evaluator can not detect input's column-ref and thus swapping and destroying later column ref projection logic #53794

Merged
merged 13 commits into from
Aug 2, 2024

Conversation

AilinKid
Copy link
Contributor

@AilinKid AilinKid commented Jun 4, 2024

What problem does this PR solve?

Issue Number: close #53713

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    use the valid SQL and error SQL inside issue to produce result
    and compare it with MySQL output, both them output like below:
mysql> source /Users/arenatlx/Downloads/error.txt
+------+------+------+------+
| c1   | c3   | c4   | c5   |
+------+------+------+------+
| NULL | NULL | 4    | NULL |
+------+------+------+------+
1 row in set (0.04 sec)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Fixed an issue where the column evaluator could not detect column references in the input chunk. This bug caused the column evaluator to potentially lose the original input column data during projection, disrupting subsequent reference projection logic.
修复了 column evaluator 无法识别输入 chunk 中的列引用的问题。该问题会导致在投影过程中,column evaluator 可能丢失原始输入列的内容,从而破坏后续引用投影逻辑。


@ti-chi-bot ti-chi-bot bot added do-not-merge/invalid-title do-not-merge/needs-triage-completed release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 4, 2024
Copy link

tiprow bot commented Jun 4, 2024

Hi @AilinKid. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@AilinKid AilinKid changed the title fix column evaluator can not detect input's column-ref and thus swapping and destorying later ref projection logic fix column evaluator can not detect input's column-ref and thus swapping and destroying later column ref projection logic Jun 4, 2024
Comment on lines 106 to 127
for inputIdx, outputIdxes := range inputIdxToOutputIdxes {
find = false
root = inputIdx
for k, v := range selfRef {
for _, one := range v {
// if current inputIdx is in the value set of one selfRef. output the Root.
if inputIdx == one {
find = true
root = k
break
}
}
if find {
break
}
}
// if we found, root should be redirected to real root of inputIdx (link the real root)
// if we didn't, root should be the original inputIdx as it was. (inputIdx itself is a root)
if _, ok := rootIdxToOutputIdxes[root]; ok {
rootIdxToOutputIdxes[root] = append(rootIdxToOutputIdxes[root], outputIdxes...)
} else {
// if not find in any value set, it means input idx itself is a root.
rootIdxToOutputIdxes[root] = append(rootIdxToOutputIdxes[root], outputIdxes...)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I think we're doing things like the disjoint set? There's already a implemented disjoint set in util

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense

Copy link

codecov bot commented Jun 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.8522%. Comparing base (a187e9d) to head (bd0803b).
Report is 781 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #53794        +/-   ##
================================================
+ Coverage   72.8506%   74.8522%   +2.0016%     
================================================
  Files          1562       1568         +6     
  Lines        439181     442974      +3793     
================================================
+ Hits         319946     331576     +11630     
+ Misses        99531      91060      -8471     
- Partials      19704      20338       +634     
Flag Coverage Δ
integration 49.4644% <100.0000%> (?)
unit 71.7530% <100.0000%> (-0.0935%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9567% <ø> (ø)
parser ∅ <ø> (∅)
br 52.5288% <ø> (+6.6287%) ⬆️

Copy link

ti-chi-bot bot commented Jul 24, 2024

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 24, 2024
@AilinKid AilinKid changed the title fix column evaluator can not detect input's column-ref and thus swapping and destroying later column ref projection logic planner: fix column evaluator can not detect input's column-ref and thus swapping and destroying later column ref projection logic Jul 25, 2024
@AilinKid
Copy link
Contributor Author

/retest-required

Copy link

tiprow bot commented Jul 29, 2024

@AilinKid: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest-required

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@AilinKid
Copy link
Contributor Author

/retest-required

Copy link

tiprow bot commented Jul 29, 2024

@AilinKid: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest-required

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@AilinKid
Copy link
Contributor Author

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Jul 29, 2024
pkg/expression/evaluator.go Outdated Show resolved Hide resolved
pkg/expression/evaluator.go Outdated Show resolved Hide resolved
pkg/util/disjointset/set.go Outdated Show resolved Hide resolved
pkg/util/disjointset/set.go Outdated Show resolved Hide resolved
@AilinKid
Copy link
Contributor Author

/retest-required

@AilinKid
Copy link
Contributor Author

/test fast_test_tiprow

Copy link

ti-chi-bot bot commented Jul 30, 2024

@AilinKid: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-br-integration-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test canary-notify-when-compatibility-sections-changed
  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test

Use /test all to run the following jobs that were automatically triggered:

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/test fast_test_tiprow

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Jul 30, 2024

release note provided by gpt:

Release Note - Chinese Version

修复:

修复了 column evaluator 无法识别输入 chunk 中的列引用的问题。该问题会导致在投影过程中,column evaluator 可能丢失原始输入列的内容,从而破坏后续引用投影逻辑。

Release Note - English Version

Fix:

Fixed an issue where the column evaluator could not detect column references in the input chunk. This bug caused the column evaluator to potentially lose the original input column data during projection, disrupting subsequent reference projection logic.

Copy link

ti-chi-bot bot commented Aug 1, 2024

@AilinKid: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-br-integration-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test canary-notify-when-compatibility-sections-changed
  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test

Use /test all to run the following jobs that were automatically triggered:

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/test fast_test_tiprow

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

.
Signed-off-by: AilinKid <[email protected]>
@AilinKid
Copy link
Contributor Author

AilinKid commented Aug 1, 2024

tidb> source /Users/arenatlx/Downloads/error.txt
+------+------+----+------+
| c1   | c3   | c4 | c5   |
+------+------+----+------+
| NULL | NULL | 4  | NULL |
+------+------+----+------+
1 row in set (0.01 sec)

should be ok

.
Signed-off-by: AilinKid <[email protected]>
@AilinKid
Copy link
Contributor Author

AilinKid commented Aug 1, 2024

/retest-required

1 similar comment
@AilinKid
Copy link
Contributor Author

AilinKid commented Aug 1, 2024

/retest-required

@AilinKid
Copy link
Contributor Author

AilinKid commented Aug 1, 2024

/test check-dev2

Copy link

tiprow bot commented Aug 1, 2024

@AilinKid: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test check-dev2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@AilinKid
Copy link
Contributor Author

AilinKid commented Aug 1, 2024

/retest-required

2 similar comments
@AilinKid
Copy link
Contributor Author

AilinKid commented Aug 1, 2024

/retest-required

@AilinKid
Copy link
Contributor Author

AilinKid commented Aug 1, 2024

/retest-required

Copy link

ti-chi-bot bot commented Aug 1, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: winoros, XuHuaiyu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 1, 2024
Copy link

ti-chi-bot bot commented Aug 1, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-30 10:16:22.202515182 +0000 UTC m=+264498.482563250: ☑️ agreed by XuHuaiyu.
  • 2024-08-01 13:33:53.353108829 +0000 UTC m=+10030.571870438: ☑️ agreed by winoros.

@winoros
Copy link
Member

winoros commented Aug 1, 2024

/retest

Signed-off-by: AilinKid <[email protected]>
.
Signed-off-by: AilinKid <[email protected]>
@ti-chi-bot ti-chi-bot bot merged commit 801d5d6 into pingcap:master Aug 2, 2024
12 checks passed
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Sep 20, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #56199.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Sep 20, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Sep 26, 2024
…hus swapping and destroying later column ref projection logic (#53794) (#56199)

close #53713
@AilinKid AilinKid added the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label Nov 14, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Nov 14, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #57380.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect swaping column leads to nil pointer
4 participants