[fix](statistics) Use one algorithm decision to pick both params and template in sample analyze - #66578
Open
yujun777 wants to merge 2 commits into
Open
[fix](statistics) Use one algorithm decision to pick both params and template in sample analyze#66578yujun777 wants to merge 2 commits into
yujun777 wants to merge 2 commits into
Conversation
…template in sample analyze Sample analyze used two independent decisions when building the SQL: getSampleParams filled params based on tableRowCount/scanFullTable, while doSample picked the template via useLinearAnalyzeTemplate(). When a debug point forced the DUJ1 template on a small table, the FULL-scan branch still filled LINEAR-style params that referenced the raw column name, which does not exist in the DUJ1 template's cte1, causing the analyze task to fail with "Unknown column 'id' in 'table list' in PROJECT clause". Key changes: - Add AnalyzeSampleAlgorithm enum (FULL/LINEAR/DUJ1) in BaseAnalysisTask. - Rename getAnalyzeAlgorithm to getSampleCollectInfo: decide the algorithm once and return it together with the picked sample tablets. - Fill params (getSampleParams/setSampleParamsByAlgorithm) and pick the SQL template (doSample) from the same algorithm decision, so params always match the template. - Remove the scanFullTable field, its setter/getter, and all related checks. Unit Test: - Updated OlapAnalysisTaskTest to cover FULL/LINEAR/DUJ1 param filling, template selection driven by the algorithm, and the sample-tablets-not-enough fallback.
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 28854 ms |
Contributor
TPC-DS: Total hot run time: 157825 ms |
Contributor
ClickBench: Total hot run time: 23.74 s |
…nt FULL fallback The useDUJ1Template debug point only affected template selection inside useLinearAnalyzeTemplate. When a small table's row count was not fully reported to FE yet (tableRowCount <= targetSampleRows), getSampleCollectInfo returned FULL before reaching that check, so the test's forced DUJ1 path was skipped and params were filled with LINEAR style while the DUJ1 template was used, causing "Unknown column" failures. The regression test was flaky because it depended on BE row count report timing. Key changes: - In getSampleCollectInfo, check the useDUJ1Template debug point before the row-count based FULL decision and force the DUJ1 algorithm. Unit Test: - Extended OlapAnalysisTaskTest.testGetSampleCollectInfo to assert the debug point forces DUJ1 even when row count would fall back to a full table scan.
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 28908 ms |
Contributor
TPC-DS: Total hot run time: 158520 ms |
Contributor
ClickBench: Total hot run time: 23.92 s |
Contributor
FE Regression Coverage ReportIncrement line coverage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Proposed changes
Fix sample analyze generating invalid SQL when the DUJ1 template is forced on a small table.
doSample()previously filled SQL params and selected the SQL template through two independent decisions:getSampleParams()decided based ontableRowCount/scanFullTable(filling LINEAR-style params that reference the raw column name), while the template was picked separately viauseLinearAnalyzeTemplate(). WhenuseDUJ1Templatewas forced, the DUJ1 template was chosen but the params were still filled by the FULL-scan branch with${colName}references. The DUJ1 template'scte1only exposescol_value/count/column_length, so the generated SQL failed to bind, e.g.Unknown column 'id' in 'table list' in PROJECT clause, which madetest_analyze_long_stringflaky.This PR makes the algorithm a single decision:
getSampleCollectInfo()decidesAnalyzeSampleAlgorithm { FULL, LINEAR, DUJ1 }once, and both param filling and template selection derive from the same algorithm, so params always match the template.Key changes
AnalyzeSampleAlgorithmenum (FULL/LINEAR/DUJ1) inBaseAnalysisTask.getAnalyzeAlgorithmtogetSampleCollectInfo: decide the algorithm once and return it together with the picked sample tablets.getSampleParams/setSampleParamsByAlgorithm) and pick the SQL template (doSample) from the same algorithm decision.scanFullTablefield, its setter/getter, and all related checks.Unit test
OlapAnalysisTaskTestto cover FULL/LINEAR/DUJ1 param filling, template selection driven by the algorithm, and the sample-tablets-not-enough fallback.