yujun777 opened a new pull request, #69286: URL: https://github.com/apache/doris/pull/69286
### What problem does this PR solve? Incremental refresh of a MIN/MAX materialized view currently falls back to a complete refresh whenever a deleted row could be the current extreme. Deleting one of several rows that share the minimum value is a common case, yet the MV does not remember how many rows hold that extreme, so the refresh cannot tell that the extreme survives. This PR adds `COUNT_AT_MIN` / `COUNT_AT_MAX` and stores that count as a hidden IVM state column. The delta plan now emits the count at the insert-side and delete-side extreme. Apply keeps the old extreme while its surviving count is positive; only deleting the last row at the extreme still falls back to a complete refresh. Trace issue: https://github.com/apache/doris/issues/65418 ### What changed? - Add public `COUNT_AT_MIN(expr)` / `COUNT_AT_MAX(expr)` aggregate functions. They return the number of input rows equal to the group's minimum/maximum, ignore NULLs, return 0 for empty or all-NULL input, and reject DISTINCT. They are equivalent to Oracle's `COUNT(*) KEEP (DENSE_RANK FIRST/LAST ORDER BY expr)`. - Add `MIN_COUNT` / `MAX_COUNT` IVM hidden state keys and hidden columns named in the existing `__DORIS_IVM_AGG_{ordinal}_{STATE}_COL__` format. - Emit insert/delete extreme counts in the delta aggregate. - Use the surviving extreme count in the apply guard and update the hidden count state. - Add BE/FE unit coverage and a regression suite. ### Testing - FE unit tests: `IvmAggMinProcessorTest`, `IvmAggMaxProcessorTest`, `IvmAggDeltaHandlerTest`, `IvmNormalizeUniqKeysMTMVTest`. - Regression: `test_ivm_minmax_count`, plus existing `test_ivm_minmax_runtime_fallback`, `test_ivm_agg_1`, `test_ivm_agg_2`, and `test_ivm_agg_shared_columns`. - SQL verification of duplicate extremes, all-NULL input, and DISTINCT rejection. - FE build/checkstyle, BE build, clang-format/check-format, and build hygiene pass. - A BE unit test for the new aggregate is included. The local BE unit-test target could not link in this environment because the toolchain already provides glibc-compatibility symbols; the main BE build succeeded. -- 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]
