yujun777 opened a new pull request, #66578:
URL: https://github.com/apache/doris/pull/66578

   ## 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 on 
`tableRowCount`/`scanFullTable` (filling LINEAR-style params that reference the 
raw column name), while the template was picked separately via 
`useLinearAnalyzeTemplate()`. When `useDUJ1Template` was forced, the DUJ1 
template was chosen but the params were still filled by the FULL-scan branch 
with `${colName}` references. The DUJ1 template's `cte1` only exposes 
`col_value`/`count`/`column_length`, so the generated SQL failed to bind, e.g. 
`Unknown column 'id' in 'table list' in PROJECT clause`, which made 
`test_analyze_long_string` (DORIS-26343) flaky.
   
   This PR makes the algorithm a single decision: `getSampleCollectInfo()` 
decides `AnalyzeSampleAlgorithm { FULL, LINEAR, DUJ1 }` once, and both param 
filling and template selection derive from the same algorithm, so params always 
match the template.
   
   ## 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.
   - 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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to