eldenmoon opened a new pull request, #68195: URL: https://github.com/apache/doris/pull/68195
### What problem does this PR solve? Issue Number: None Related PR: None Problem Summary: `ALTER TABLE ... ADD ROLLUP r (v, id) DUPLICATE KEY(v)` is accepted by FE when `v` is a VARIANT column, but the asynchronous rollup job then fails in BE and ends up CANCELLED: ``` rollup tasks failed on same tablet reach threshold 1, reason=task type: ALTER, status_code: NOT_IMPLEMENTED_ERROR, status_message: [NOT_IMPLEMENTED_ERROR] not implemented ``` Root cause: when the user lists the duplicate keys explicitly, `MaterializedViewHandler.checkAndPrepareMaterializedView(AddRollupOp ...)` never checks the key column type. The implicit branch stops at the first column that `couldBeShortKey()` rejects, and CREATE MATERIALIZED VIEW rejects these types too, but the explicit branch lets them through. BE sorts the rollup rows by the duplicate keys and cannot compare these types. Checked on a cluster before the fix: | duplicate key type | rollup job result | |---|---| | VARIANT | CANCELLED, NOT_IMPLEMENTED_ERROR | | ARRAY / MAP / STRUCT | CANCELLED, `OlapColumnDataConvertor* not support get_data_at` | | JSON | CANCELLED, INTERNAL_ERROR `value 65537 cast to type t out of range` | | STRING / DOUBLE / IPV6 | FINISHED | Fix: reject a duplicate key whose type `isOnlyMetricType()` (hll, bitmap, quantile_state, array, map, struct, jsonb, variant) when the statement is submitted, with the same `Type.OnlyMetricTypeErrorMsg` that CREATE MATERIALIZED VIEW uses. Types that BE can sort, such as STRING and DOUBLE, keep working as before. The same function also serves the ROLLUP clause of CREATE TABLE, which now reports this reason too. ### Release note ADD ROLLUP with an explicit DUPLICATE KEY on a VARIANT, ARRAY, MAP, STRUCT, JSON, HLL, BITMAP or QUANTILE_STATE column is now rejected immediately instead of creating a job that fails later. ### Check List (For Author) - Test: Regression test (rollup_p0/test_rollup_dup_key_type) - Behavior changed: Yes. These rollups are rejected when submitted instead of being cancelled asynchronously. - Does this need documentation: No 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
