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 the problem that PlanBuilder.buildWindowFunctions may change sub operator's schema. #27176

Merged
merged 6 commits into from
Aug 13, 2021

Conversation

LittleFall
Copy link
Contributor

@LittleFall LittleFall commented Aug 12, 2021

What problem does this PR solve?

Issue Number: close #27148

Problem Summary: buildWindowFunctions will use sub operator's schema as itself's, for example, here

		switch newArg.(type) {
		case *expression.Column, *expression.Constant:
			newArgList = append(newArgList, newArg)
			continue
		}

obtains the sub operator's schema, and then changed them here

		if col, ok := a.Args[i].(*expression.Column); ok {
			col.RetType = types.NewFieldType(col.RetType.Tp)
		}
		// originTp is used when the the `Tp` of column is TypeFloat32 while
		// the type of the aggregation function is TypeFloat64.
		originTp := a.Args[i].GetType().Tp
		*(a.Args[i].GetType()) = *(a.RetTp)
		a.Args[i].GetType().Tp = originTp

This may cause some unexpected behaviors, for example in mpp query, making the schema of exchangeReceiver and exchangeSender not equal and then throw errors as the issue said.

for example, it will build a plan like:

Proj <- Proj <- Window       <- Proj   <- Proj <- Agg  <- DataSource
47,1    47,1    47,1            47,1              47,1
        25,1    25,1            3,1              sum, arg=3,1, ret=25,1
                3,1
                sum
                retTp=47,1
                argTp=47,1

the (3,1), (25,1), (47,1) means output schema's attribute flen and decimal in typeDecimal, but the excepted is

Proj <- Proj <- Window       <- Proj   <- Proj <- Agg  <- DataSource
47,1    47,1    47,1            25,1              25,1
        25,1    25,1            3,1              sum, arg=3,1, ret=25,1
                3,1
                sum
                retTp=47,1
                argTp=25,1

What is changed and how it works?

Proposal: xxx

What's Changed: let it obtain a column's clone.

Are there any suggestions for fixing it better?

Check List

Tests

  • Integration test
  • Manual test (issue fixed.)

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 12, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lzmhhh123
  • winoros

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 12, 2021
@LittleFall
Copy link
Contributor Author

[2021-08-12T20:04:28.602Z] cd tools/check; \

[2021-08-12T20:04:28.602Z] GO111MODULE=on go build -o ../bin/failpoint-ctl github.com/pingcap/failpoint/failpoint-ctl

[2021-08-12T20:04:33.881Z] /bin/sh: Rewrite: command not found

[2021-08-12T20:04:33.881Z] make: *** [failpoint-enable] Error 127

@LittleFall
Copy link
Contributor Author

/run-check_dev_2

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 13, 2021
@LittleFall
Copy link
Contributor Author

[2021-08-13T06:22:47.994Z] FAIL

[2021-08-13T06:22:47.994Z] + cat test.log

[2021-08-13T06:22:47.994Z] + grep -Ev '^[[[:digit:]]{4}(/[[:digit:]]{2}){2}'

[2021-08-13T06:22:47.994Z] + grep -A 30 '-------'

[2021-08-13T06:22:47.994Z] + grep -A 29 '^FAIL:'

[2021-08-13T06:22:47.994Z] FAIL: ddl_test.go:1302: testSuite6.TestSetDDLErrorCountLimit

[2021-08-13T06:22:47.994Z]

[2021-08-13T06:22:47.994Z] ddl_test.go:1324:

[2021-08-13T06:22:47.994Z] c.Assert(variable.GetDDLErrorCountLimit(), Equals, int64(100))

[2021-08-13T06:22:47.994Z] ... obtained int64 = 512

[2021-08-13T06:22:47.994Z] ... expected int64 = 100

@LittleFall
Copy link
Contributor Author

/run_check_dev_2

@LittleFall
Copy link
Contributor Author

/run-check_dev_2

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 13, 2021
@lzmhhh123
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: bd9716f

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 13, 2021
@LittleFall
Copy link
Contributor Author

[2021-08-13T07:43:16.286Z] + grep -A 29 '^FAIL:'

[2021-08-13T07:43:16.286Z] FAIL: infoschema_reader_test.go:561: testInfoschemaTableSuite.TestForAnalyzeStatus

[2021-08-13T07:43:16.286Z]

[2021-08-13T07:43:16.286Z] infoschema_reader_test.go:595:

[2021-08-13T07:43:16.286Z] c.Assert(len(resultT1.Rows()), Greater, 0)

[2021-08-13T07:43:16.286Z] ... compare_one int = 0

[2021-08-13T07:43:16.286Z] ... compare_two int = 0

[2021-08-13T07:43:16.286Z]

[2021-08-13T07:43:16.286Z] PASS: write_test.go:2076: testSuite4.TestIssue18681 0.034s

[2021-08-13T07:43:16.286Z] PASS: adm

@LittleFall
Copy link
Contributor Author

/run_check_dev_2

@LittleFall
Copy link
Contributor Author

/merge

@LittleFall
Copy link
Contributor Author

/run-all-tests

@LittleFall
Copy link
Contributor Author

/merge

@ti-chi-bot ti-chi-bot merged commit cd5499e into pingcap:master Aug 13, 2021
@LittleFall LittleFall deleted the bugfix/mismatch branch August 13, 2021 08:58
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 13, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0 in PR #27201

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 13, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.1 in PR #27202

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 13, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.2 in PR #27203

LittleFall added a commit to LittleFall/tidb that referenced this pull request Aug 13, 2021
@LittleFall
Copy link
Contributor Author

/run-cherry-picker

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 13, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #27204

ti-chi-bot pushed a commit that referenced this pull request Aug 13, 2021
ti-chi-bot pushed a commit that referenced this pull request Aug 13, 2021
ti-chi-bot pushed a commit that referenced this pull request Aug 13, 2021
ti-chi-bot pushed a commit that referenced this pull request Aug 13, 2021
windtalker pushed a commit to windtalker/tidb that referenced this pull request Sep 3, 2021
zhouqiang-cl pushed a commit that referenced this pull request Sep 3, 2021
…change sub operator's schema. (#27176) (#27201) (#27783)

Co-authored-by: ti-srebot <66930949+ti-srebot@users.noreply.github.com>
@fzhedu fzhedu added the MPP related to MPP in tiflash label Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MPP related to MPP in tiflash needs-cherry-pick-release-5.0 needs-cherry-pick-release-5.1 needs-cherry-pick-release-5.2 release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TiDB throw error for mpp queries
6 participants