fix(updater): process nested columns (#20088)

- fixed updater to process nested columns properly
This commit is contained in:
Imri Paran 2025-03-06 10:28:53 +01:00 committed by GitHub
parent 3980d030b9
commit 5261cd9713
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 7 deletions

View File

@ -3849,7 +3849,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
continue;
}
updateColumnDescription(stored, updated);
updateColumnDescription(fieldName, stored, updated);
updateColumnDisplayName(stored, updated);
updateColumnDataLength(stored, updated);
updateColumnPrecision(stored, updated);
@ -3871,13 +3871,15 @@ public abstract class EntityRepository<T extends EntityInterface> {
majorVersionChange = majorVersionChange || !deletedColumns.isEmpty();
}
private void updateColumnDescription(Column origColumn, Column updatedColumn) {
private void updateColumnDescription(
String fieldName, Column origColumn, Column updatedColumn) {
if (operation.isPut() && !nullOrEmpty(origColumn.getDescription()) && updatedByBot()) {
// Revert the non-empty task description if being updated by a bot
updatedColumn.setDescription(origColumn.getDescription());
return;
}
String columnField = getColumnField(origColumn, FIELD_DESCRIPTION);
String columnField =
EntityUtil.getFieldName(fieldName, origColumn.getName(), FIELD_DESCRIPTION);
recordChange(columnField, origColumn.getDescription(), updatedColumn.getDescription());
}

View File

@ -102,7 +102,6 @@ import org.openmetadata.service.jdbi3.FeedRepository.ThreadContext;
import org.openmetadata.service.resources.databases.DatabaseUtil;
import org.openmetadata.service.resources.databases.TableResource;
import org.openmetadata.service.resources.feeds.MessageParser.EntityLink;
import org.openmetadata.service.search.SearchClient;
import org.openmetadata.service.security.mask.PIIMasker;
import org.openmetadata.service.util.EntityUtil;
import org.openmetadata.service.util.EntityUtil.Fields;
@ -138,8 +137,6 @@ public class TableRepository extends EntityRepository<Table> {
private static final Set<String> CHANGE_SUMMARY_FIELDS =
Set.of("description", "owners", "columns.description");
private static final SearchClient searchClient = Entity.getSearchRepository().getSearchClient();
public TableRepository() {
super(
TableResource.COLLECTION_PATH,

View File

@ -1988,9 +1988,14 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
@Test
void patch_withChangeSource(TestInfo test) throws IOException {
Column nestedColumns = getColumn("testNested", INT, null);
CreateTable create =
createRequest(test)
.withColumns(List.of(getColumn(C1, INT, null), getColumn(C2, BIGINT, null)));
.withColumns(
List.of(
getColumn(C1, INT, null),
getColumn(C2, BIGINT, null),
getColumn("withNested", STRUCT, null).withChildren(List.of(nestedColumns))));
Table table = createAndCheckEntity(create, ADMIN_AUTH_HEADERS);
Table updated = JsonUtils.deepCopy(table, Table.class);
@ -2074,6 +2079,35 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
.get(
FullyQualifiedName.build(
"columns", automatedUpdate.getColumns().get(0).getName(), "description")));
Table nestedColumnUpdate = JsonUtils.deepCopy(columnDelete, Table.class);
nestedColumnUpdate
.getColumns()
.get(1)
.getChildren()
.get(0)
.setDescription("nested description");
nestedColumnUpdate =
patchEntity(
table.getId(),
JsonUtils.pojoToJson(columnDelete),
nestedColumnUpdate,
ADMIN_AUTH_HEADERS,
ChangeSource.AUTOMATED);
assertEquals(
nestedColumnUpdate
.getChangeDescription()
.getChangeSummary()
.getAdditionalProperties()
.get(
FullyQualifiedName.build(
"columns",
nestedColumnUpdate.getColumns().get(1).getName(),
nestedColumnUpdate.getColumns().get(1).getChildren().get(0).getName(),
"description"))
.getChangeSource(),
ChangeSource.AUTOMATED);
}
private void assertChangeSummaryInSearch(EntityInterface entity) throws IOException {