TangSiyang2001 opened a new issue, #39798: URL: https://github.com/apache/doris/issues/39798
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues. ### Version all ### What's Wrong? Due to historical reasons, there are currently bugs when increasing the length of varchar types for dup key and uniq key: the agg type is not unified. ```java public void checkSchemaChangeAllowed(Column other) throws DdlException { if (Strings.isNullOrEmpty(other.name)) { throw new DdlException("Dest column name is empty"); } if (!ColumnType.isSchemaChangeAllowed(type, other.type)) { throw new DdlException("Can not change " + getDataType() + " to " + other.getDataType()); } if (type.isNumericType() && other.type.isStringType()) { try { Integer lSize = type.getColumnStringRepSize(); Integer rSize = other.type.getColumnStringRepSize(); if (rSize < lSize) { throw new DdlException( "Can not change from wider type " + type.toSql() + " to narrower type " + other.type.toSql()); } } catch (TypeException e) { throw new DdlException(e.getMessage()); } } if (!Objects.equals(this.aggregationType, other.aggregationType)) { throw new DdlException("Can not change aggregation type"); } ... ``` ```java private boolean processModifyColumn(ModifyColumnClause alterClause, OlapTable olapTable, Map<Long, LinkedList<Column>> indexSchemaMap) throws DdlException { Column modColumn = alterClause.getColumn(); boolean lightSchemaChange = false; if (KeysType.AGG_KEYS == olapTable.getKeysType()) { if (modColumn.isKey() && null != modColumn.getAggregationType()) { throw new DdlException("Can not assign aggregation method on key column: " + modColumn.getName()); } else if (!modColumn.isKey() && null == modColumn.getAggregationType()) { throw new DdlException("Aggregate method must be specified for value column: " + modColumn.getName()); } } else if (KeysType.UNIQUE_KEYS == olapTable.getKeysType()) { if (null != modColumn.getAggregationType()) { throw new DdlException("Can not assign aggregation method" + " on column in Unique data model table: " + modColumn.getName()); } if (!modColumn.isKey()) { if (olapTable.getEnableUniqueKeyMergeOnWrite()) { modColumn.setAggregationType(AggregateType.NONE, true); } else { modColumn.setAggregationType(AggregateType.REPLACE, true); } } } else { if (null != modColumn.getAggregationType()) { throw new DdlException( "Can not assign aggregation method" + " on column in Duplicate data model table: " + modColumn.getName()); } if (!modColumn.isKey()) { modColumn.setAggregationType(AggregateType.NONE, true); } } ... ``` The agg type check fails because in this (referring to the OlapTable's Column), the agg type is null, as it is considered a key during table creation, and the agg type should be null. However, the modColumn generated by the alter statement is set to None in the above place, because during the alter, it is considered that for dup key isKey() should return false. ### What You Expected? This problem resolved ### How to Reproduce? Create a duplicate or unique table with key columns and varchar type, and try to modify their length with alter operation. ### Anything Else? This problem is discovered and remained unsolved in #39319. ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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: commits-unsubscr...@doris.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org