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

   ### Background
   
   Partitioned asynchronous materialized views retain both their query output 
partition column and the base-table expression inferred from partition lineage. 
A base-table schema change causes refresh to reanalyze the stored MV query and 
validate its compatibility.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: None
   PR Type: Bugfix
   
   Problem Summary:
   
   After a base-table schema change, refreshing an MV whose date partition 
output has an alias can fail with `partition column can not find from sql 
select column`. Reanalysis parses the stored base-table expression and 
incorrectly searches for its base column in the query outputs. Render the 
partition expression using the MV output column, reusing the existing SHOW 
CREATE expression service, before parsing it again. Existing MVs benefit 
without metadata migration or changes to schema compatibility checks.
   
   ### Details
   
   - **Frequency:** Reproducible when schema-change reanalysis encounters a 
partition expression whose base-column name differs from its MV output alias.
   - **Root cause:** The persisted lineage expression belongs to the base-table 
namespace, while partition definition analysis resolves names against query 
outputs.
   - **Why existing tests missed it:** The existing reanalysis coverage did not 
exercise the mismatch between stored base-column names and MV output aliases 
after VARCHAR widening. The new test covers a single source and an aggregated 
UNION ALL, with implicit and explicit expression partition definitions.
   - **Fix:** Reuse 
`MTMVPartitionExprFactory.getExprService(expr).toSql(mvPartitionInfo)` to 
reconstruct the analysis input. Do not mutate stored lineage or bypass 
partition/type compatibility checks.
   - **Other paths and branches:** SHOW CREATE already uses this renderer; 
null-expression partition definitions remain unchanged. This PR targets master 
only.
   
   ### Testing
   
   - `./build.sh --fe`: passed, including FE Checkstyle.
   - `./run-fe-ut.sh --run MTMVPartitionReanalysisTest,MTMVPlanUtilTest`: 29 
tests passed, with no failures or skips.
   - The four new parameterized cases cover single-source and aggregated UNION 
ALL queries, implicit and explicit date-trunc partition definitions, actual 
VARCHAR widening, refresh-time compatibility validation, and unchanged stored 
lineage.
   - Local review: no blocking findings. Service-level refresh execution and 
deployment validation were not run locally.
   
   ### Release note
   
   Fix asynchronous materialized view refresh failures after base-table schema 
changes when a date partition expression uses a query output alias.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes. Compatible schema changes no longer cause a 
spurious partition-column lookup failure.
   - Does this need documentation: No
   - Pre-submission status: Partially verified: build and focused FE tests 
pass; end-to-end refresh execution remains for CI.
   


-- 
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