yujun777 opened a new pull request, #67837:
URL: https://github.com/apache/doris/pull/67837
### What problem does this PR solve?
Problem Summary:
A light schema change on an IVM base table (`DROP COLUMN`, usually followed
by an `ADD COLUMN` with the same name) only changes metadata and emits no row
binlog. When the dropped column is one the MV uses, the next `REFRESH ...
INCREMENTAL` consumes an empty delta and reports **SUCCESS**, while the MV
silently keeps the rows that were computed under the old column.
Dropping the column did reach the MTMV hook, but that only moved the MV
status to `SCHEMA_CHANGE`. That state merely re-analyses the MV query on the
next refresh - and by then the column is usually back under the same name, so
the analysis succeeds and the incremental refresh proceeds. The IVM baseline
barrier (`requireCompleteBaselineRebuild`) was never raised on this path: it is
only set for `REPLACE TABLE`, `REPLACE PARTITION` and partition changes.
### What this PR does
Re-analyse the MV query on the `alterTable` path, right after the alter was
applied, and invalidate the IVM baseline when the query no longer binds.
This needs no lineage machinery: dropping or renaming a column the MV uses
makes the query unanalysable, so the failure itself is the dependency signal -
and dropping a column the MV does not reference leaves the incremental path
untouched.
Scope: on an IVM base table only `DROP COLUMN` and `RENAME TABLE` can change
a referenced column at all (row binlog tables reject `MODIFY COLUMN`, `RENAME
COLUMN` and `REORDER COLUMNS`), so those two operations are the whole surface.
A dropped base table needs no handling - the IVM stream records the base table
id and stops being usable, which already fails the refresh.
The analysis runs in a context of its own rather than the session that
issued the alter, because the underlying `analyzeQueryWithSql` reuses and
closes the statement context it is handed.
### Release note
None
### Check List (For Author)
- Test
- [x] Regression test
- [x] Unit Test
- Behavior changed:
- [x] Yes. Dropping or renaming a column an IVM references now marks the
IVM baseline as needing a rebuild, so a strict `REFRESH ... INCREMENTAL` is
rejected with `IVM baseline rebuild is pending ... run an AUTO or COMPLETE
refresh first` instead of silently reporting SUCCESS. Dropping a column the MV
does not use is unaffected.
- Does this need documentation?
- [x] No.
--
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]