tidb icon indicating copy to clipboard operation
tidb copied to clipboard

Optimizer: Refactor and simplify outer to inner join conversion rule #50971

Open ghazalfamilyusa opened this issue 1 year ago • 12 comments

What problem does this PR solve?

Issue Number: Ref #51664

Problem Summary: Currently, the outer to inner join rewrite is part of the predicate push down. This is causing confusion and difficulty in extending of both rewrites. Also, the current implementation of outer to inner join rewrite has unnecessary special cases.

What changed and how does it work?

A new logical optimization is added to the list of rules. Also, a simple solution of null filtering (or NF) predicate check is used. The solution is simply:

  • NF(A AND B) = NF(A) OR NF(B)
  • NF(A OR B) = NF(A) AND NF(B)

Check List

Tests

  • [X] Unit test
  • [] Integration test
  • [ ] Manual test (add detailed scripts or steps below)
  • [ ] 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.

None

ghazalfamilyusa avatar Apr 27 '24 20:04 ghazalfamilyusa

Hi @ghazalfamilyusa. 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/test-infra repository.

tiprow[bot] avatar Apr 27 '24 20:04 tiprow[bot]

Codecov Report

Attention: Patch coverage is 43.62416% with 84 lines in your changes are missing coverage. Please review.

Project coverage is 73.5124%. Comparing base (acdb6f5) to head (15a2ba2). Report is 12 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #52941        +/-   ##
================================================
+ Coverage   72.4943%   73.5124%   +1.0180%     
================================================
  Files          1493       1498         +5     
  Lines        429359     434713      +5354     
================================================
+ Hits         311261     319568      +8307     
+ Misses        98889      95083      -3806     
- Partials      19209      20062       +853     
Flag Coverage Δ
integration 24.4896% <43.6241%> (?)

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 50.1812% <ø> (+8.7242%) :arrow_up:

codecov[bot] avatar Apr 27 '24 20:04 codecov[bot]

/retest

ghazalfamilyusa avatar Apr 27 '24 23:04 ghazalfamilyusa

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

In response to this:

/retest

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.

tiprow[bot] avatar Apr 27 '24 23:04 tiprow[bot]

/retest

ghazalfamilyusa avatar Apr 28 '24 04:04 ghazalfamilyusa

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

In response to this:

/retest

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.

tiprow[bot] avatar Apr 28 '24 04:04 tiprow[bot]

/retest

ghazalfamilyusa avatar Apr 28 '24 21:04 ghazalfamilyusa

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

In response to this:

/retest

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.

tiprow[bot] avatar Apr 28 '24 21:04 tiprow[bot]

/retest

ghazalfamilyusa avatar Apr 29 '24 04:04 ghazalfamilyusa

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

In response to this:

/retest

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.

tiprow[bot] avatar Apr 29 '24 04:04 tiprow[bot]

/retest

ghazalfamilyusa avatar May 07 '24 19:05 ghazalfamilyusa

/test mysql-test

elsa0520 avatar May 11 '24 09:05 elsa0520

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

In response to this:

/test mysql-test

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.

tiprow[bot] avatar May 11 '24 09:05 tiprow[bot]

/test mysql-test

ghazalfamilyusa avatar May 11 '24 22:05 ghazalfamilyusa

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

In response to this:

/test mysql-test

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.

tiprow[bot] avatar May 11 '24 22:05 tiprow[bot]

/retest unit-test

ghazalfamilyusa avatar May 11 '24 23:05 ghazalfamilyusa

@ghazalfamilyusa: The /retest command does not accept any targets. 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:

/retest unit-test

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[bot] avatar May 11 '24 23:05 ti-chi-bot[bot]

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

In response to this:

/retest unit-test

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.

tiprow[bot] avatar May 11 '24 23:05 tiprow[bot]

/test unit_test

ghazalfamilyusa avatar May 11 '24 23:05 ghazalfamilyusa

@ghazalfamilyusa: 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 unit_test

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[bot] avatar May 11 '24 23:05 ti-chi-bot[bot]

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

In response to this:

/test unit_test

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.

tiprow[bot] avatar May 11 '24 23:05 tiprow[bot]

/test unit-test

ghazalfamilyusa avatar May 11 '24 23:05 ghazalfamilyusa

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

In response to this:

/test unit-test

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.

tiprow[bot] avatar May 11 '24 23:05 tiprow[bot]

/test unit_test

ghazalfamilyusa avatar May 12 '24 20:05 ghazalfamilyusa

@ghazalfamilyusa: 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 unit_test

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[bot] avatar May 12 '24 20:05 ti-chi-bot[bot]

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

In response to this:

/test unit_test

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.

tiprow[bot] avatar May 12 '24 20:05 tiprow[bot]

BTW, your linked issue is incorrect. Could you please link a correct issue? If there is no related issue, it will better to create a new issue for this PR ~

elsa0520 avatar May 14 '24 14:05 elsa0520

BTW, your linked issue is incorrect. Could you please link a correct issue? If there is no related issue, it will better to create a new issue for this PR ~

Done : https://github.com/pingcap/tidb/issues/53278

ghazalfamilyusa avatar May 14 '24 19:05 ghazalfamilyusa

[LGTM Timeline notifier]

Timeline:

  • 2024-05-15 07:39:47.762672961 +0000 UTC m=+1638941.519808534: :ballot_box_with_check: agreed by qw4990.
  • 2024-05-16 03:12:09.78056395 +0000 UTC m=+1709283.537699522: :ballot_box_with_check: agreed by elsa0520.

ti-chi-bot[bot] avatar May 16 '24 03:05 ti-chi-bot[bot]

/retest

qw4990 avatar May 16 '24 03:05 qw4990