mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-27 18:36:08 +00:00
fix(updater): process nested columns (#20088)
- fixed updater to process nested columns properly
This commit is contained in:
parent
3980d030b9
commit
5261cd9713
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user