-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
parser: add new analyze option SAMPLERATE
#28961
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
planner/core/planbuilder.go
Outdated
return nil, err | ||
} | ||
if statsVer == statistics.Version1 && v > 0 { | ||
return nil, errors.Errorf("Version 1's statistics doesn't support the SAMPLE RATE option, please set tidb_analyze_version to 2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any UT to check if these checks work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current we don't actually support the analyze process for sample rate case, will be added in next pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, errors.Errorf("Version 1's statistics doesn't support the SAMPLE RATE option, please set tidb_analyze_version to 2") | |
return nil, errors.Errorf("Version 1's statistics doesn't support the SAMPLERATE option, please set tidb_analyze_version to 2.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@chrysan: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments. In response to this:
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 ti-community-infra/tichi repository. |
Technically you could use |
@kennytm |
@winoros yes. though this bit-twiddling hack won't work if in the future you need an option with string value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should change analyze options from a map into a struct someday.
planner/core/planbuilder.go
Outdated
return nil, err | ||
} | ||
if statsVer == statistics.Version1 && v > 0 { | ||
return nil, errors.Errorf("Version 1's statistics doesn't support the SAMPLE RATE option, please set tidb_analyze_version to 2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, errors.Errorf("Version 1's statistics doesn't support the SAMPLE RATE option, please set tidb_analyze_version to 2") | |
return nil, errors.Errorf("Version 1's statistics doesn't support the SAMPLERATE option, please set tidb_analyze_version to 2.") |
planner/core/planbuilder.go
Outdated
return nil, errors.Errorf("Version 1's statistics doesn't support the SAMPLE RATE option, please set tidb_analyze_version to 2") | ||
} | ||
if v > analyzeOptionLimit[opt.Type].(float64) || v <= 0 { | ||
return nil, errors.Errorf("value of analyze option %s should not larger than %f, and greater than 0", ast.AnalyzeOptionString[opt.Type], analyzeOptionLimit[opt.Type]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, errors.Errorf("value of analyze option %s should not larger than %f, and greater than 0", ast.AnalyzeOptionString[opt.Type], analyzeOptionLimit[opt.Type]) | |
return nil, errors.Errorf("value of analyze option %s should not be larger than %f, and should be greater than 0", ast.AnalyzeOptionString[opt.Type], analyzeOptionLimit[opt.Type]) |
planner/core/planbuilder.go
Outdated
switch opt.Type { | ||
case ast.AnalyzeOptNumTopN: | ||
v := datumValue.GetUint64() | ||
if v > analyzeOptionLimit[opt.Type].(uint64) { | ||
return nil, errors.Errorf("value of analyze option %s should not larger than %d", ast.AnalyzeOptionString[opt.Type], analyzeOptionLimit[opt.Type]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, errors.Errorf("value of analyze option %s should not larger than %d", ast.AnalyzeOptionString[opt.Type], analyzeOptionLimit[opt.Type]) | |
return nil, errors.Errorf("Value of analyze option %s should not be larger than %d", ast.AnalyzeOptionString[opt.Type], analyzeOptionLimit[opt.Type]) |
planner/core/planbuilder.go
Outdated
optMap[opt.Type] = v | ||
default: | ||
v := datumValue.GetUint64() | ||
if v == 0 || v > analyzeOptionLimit[opt.Type].(uint64) { | ||
return nil, errors.Errorf("value of analyze option %s should be positive and not larger than %d", ast.AnalyzeOptionString[opt.Type], analyzeOptionLimit[opt.Type]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, errors.Errorf("value of analyze option %s should be positive and not larger than %d", ast.AnalyzeOptionString[opt.Type], analyzeOptionLimit[opt.Type]) | |
return nil, errors.Errorf("Value of analyze option %s should be positive and not larger than %d.", ast.AnalyzeOptionString[opt.Type], analyzeOptionLimit[opt.Type]) |
Also please resolve the conflicts. |
ec376b9
to
74c01cc
Compare
planner/core/planbuilder.go
Outdated
} | ||
limit := math.Float64frombits(analyzeOptionLimit[opt.Type]) | ||
if fVal <= 0 || fVal > limit { | ||
return nil, errors.Errorf("Value of analyze option %s should not larger than %f, and should be greater than 0", limit, analyzeOptionLimit[opt.Type]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The arguments are wrong.
@@ -2065,6 +2068,7 @@ var analyzeOptionDefaultV2 = map[ast.AnalyzeOptionType]uint64{ | |||
ast.AnalyzeOptCMSketchWidth: 2048, | |||
ast.AnalyzeOptCMSketchDepth: 5, | |||
ast.AnalyzeOptNumSamples: 100000, | |||
ast.AnalyzeOptSampleRate: math.Float64bits(0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value of SAMPLE RATE is 0. When users doesn't set either NUM SAMPLES or SAMPLE RATE, the default values would be used. In that case, will ANALYZE execute with 10000 SAMPLES?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next pr will change the default config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
limit := math.Float64frombits(analyzeOptionLimit[opt.Type]) | ||
if fVal <= 0 || fVal > limit { | ||
return nil, errors.Errorf("Value of analyze option %s should not larger than %f, and should be greater than 0", ast.AnalyzeOptionString[opt.Type], limit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, errors.Errorf("Value of analyze option %s should not larger than %f, and should be greater than 0", ast.AnalyzeOptionString[opt.Type], limit) | |
return nil, errors.Errorf("Value of analyze option %s should not be larger than %f, and should be greater than 0", ast.AnalyzeOptionString[opt.Type], limit) |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: fb10d8b
|
@winoros the GitHub settings require at least 1 approving review which indicate a committer approve (green). You can ask for another committer to approve this PR. |
/merge |
@winoros: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. 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 ti-community-infra/tichi repository. |
What problem does this PR solve?
Issue Number: to #28960
Problem Summary:
Modify parser to support the new analyze option.
What is changed and how it works?
Since the new option needs float value, we not only modified the parser, but also modified the structure of the AnalyzeOption.
Check List
Tests
Documentation
Release note