github-actions[bot] commented on code in PR #65329:
URL: https://github.com/apache/doris/pull/65329#discussion_r3581138255
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java:
##########
@@ -848,42 +956,61 @@ public void renameColumn(ExternalTable dorisTable, String
oldName, String newNam
refreshTable(dorisTable, updateTime);
}
+ @Override
+ public void renameColumn(ExternalTable dorisTable, ColumnPath columnPath,
String newName, long updateTime)
+ throws UserException {
+ if (!columnPath.isNested()) {
+ renameColumn(dorisTable, columnPath.getTopLevelName(), newName,
updateTime);
+ return;
+ }
+ Table icebergTable = IcebergUtils.getIcebergTable(dorisTable);
+ ResolvedColumnPath resolvedPath =
validateNestedStructFieldPath(icebergTable.schema(), columnPath, "rename");
+ ResolvedColumnPath parentPath =
resolveColumnPath(icebergTable.schema(), columnPath.getParentPath(), "rename");
+
validateNoCaseInsensitiveSiblingCollision(parentPath.getType().asStructType(),
+ parentPath.getColumnPath(), newName, resolvedPath.getField(),
"rename");
+
+ UpdateSchema updateSchema = icebergTable.updateSchema();
+ updateSchema.renameColumn(resolvedPath.getFullPath(), newName);
+ try {
+ executionAuthenticator.execute(() -> updateSchema.commit());
+ } catch (Exception e) {
+ throw new UserException("Failed to rename nested column: " +
columnPath.getFullPath() + " to " + newName
+ + " in table: " + icebergTable.name() + ", error message
is: " + e.getMessage(), e);
+ }
+ refreshTable(dorisTable, updateTime);
+ }
+
@Override
public void modifyColumn(ExternalTable dorisTable, Column column,
ColumnPosition position, long updateTime)
throws UserException {
Table icebergTable = IcebergUtils.getIcebergTable(dorisTable);
- NestedField currentCol =
icebergTable.schema().findField(column.getName());
+ NestedField currentCol =
icebergTable.schema().caseInsensitiveFindField(column.getName());
if (currentCol == null) {
throw new UserException("Column " + column.getName() + " does not
exist");
}
+ ResolvedColumnPath columnPath = new
ResolvedColumnPath(ColumnPath.of(currentCol.name()),
+ currentCol.type(), currentCol);
validateCommonColumnInfo(column);
UpdateSchema updateSchema = icebergTable.updateSchema();
if (column.getType().isComplexType()) {
// Complex type processing branch
validateForModifyComplexColumn(column, currentCol);
- applyComplexTypeChange(updateSchema, column.getName(),
currentCol.type(), column.getType());
- if (column.isAllowNull()) {
- updateSchema.makeColumnOptional(column.getName());
- }
+ applyComplexTypeChange(updateSchema, columnPath.getFullPath(),
currentCol.type(), column.getType());
if (!Objects.equals(currentCol.doc(), column.getComment())) {
- updateSchema.updateColumnDoc(column.getName(),
column.getComment());
+ updateSchema.updateColumnDoc(columnPath.getFullPath(),
column.getComment());
}
} else {
// Primitive type processing (existing logic)
validateForModifyColumn(column, currentCol);
Type icebergType =
IcebergUtils.dorisTypeToIcebergType(column.getType());
- updateSchema.updateColumn(column.getName(),
icebergType.asPrimitiveType(), column.getComment());
- if (column.isAllowNull()) {
- // we can change a required column to optional, but not the
other way around
- // because we don't know whether there is existing data with
null values.
- updateSchema.makeColumnOptional(column.getName());
- }
+ updateSchema.updateColumn(columnPath.getFullPath(),
icebergType.asPrimitiveType(), column.getComment());
}
Review Comment:
This top-level Iceberg MODIFY path still accepts default metadata but drops
it before reaching Iceberg. The Iceberg-specific command gate only rejects
`DEFAULT`/`ON UPDATE` after `getNestedColumnPath(...)` returns a nested path,
while `translateToCatalogStyleForSchemaChange()` carries those clauses onto the
`Column`. In this top-level branch the primitive case sends only type/comment
to `updateColumn(...)` and then applies nullable intent, so `ALTER TABLE
iceberg_t MODIFY COLUMN id BIGINT DEFAULT 7` can succeed without changing the
Iceberg default. Please reject default/on-update clauses for top-level Iceberg
MODIFY before the type-specific branch, or implement the default update
explicitly, and add coverage for a top-level column.
--
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]