mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-28 02:46:09 +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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateColumnDescription(stored, updated);
|
updateColumnDescription(fieldName, stored, updated);
|
||||||
updateColumnDisplayName(stored, updated);
|
updateColumnDisplayName(stored, updated);
|
||||||
updateColumnDataLength(stored, updated);
|
updateColumnDataLength(stored, updated);
|
||||||
updateColumnPrecision(stored, updated);
|
updateColumnPrecision(stored, updated);
|
||||||
@ -3871,13 +3871,15 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
majorVersionChange = majorVersionChange || !deletedColumns.isEmpty();
|
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()) {
|
if (operation.isPut() && !nullOrEmpty(origColumn.getDescription()) && updatedByBot()) {
|
||||||
// Revert the non-empty task description if being updated by a bot
|
// Revert the non-empty task description if being updated by a bot
|
||||||
updatedColumn.setDescription(origColumn.getDescription());
|
updatedColumn.setDescription(origColumn.getDescription());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String columnField = getColumnField(origColumn, FIELD_DESCRIPTION);
|
String columnField =
|
||||||
|
EntityUtil.getFieldName(fieldName, origColumn.getName(), FIELD_DESCRIPTION);
|
||||||
recordChange(columnField, origColumn.getDescription(), updatedColumn.getDescription());
|
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.DatabaseUtil;
|
||||||
import org.openmetadata.service.resources.databases.TableResource;
|
import org.openmetadata.service.resources.databases.TableResource;
|
||||||
import org.openmetadata.service.resources.feeds.MessageParser.EntityLink;
|
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.security.mask.PIIMasker;
|
||||||
import org.openmetadata.service.util.EntityUtil;
|
import org.openmetadata.service.util.EntityUtil;
|
||||||
import org.openmetadata.service.util.EntityUtil.Fields;
|
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 =
|
private static final Set<String> CHANGE_SUMMARY_FIELDS =
|
||||||
Set.of("description", "owners", "columns.description");
|
Set.of("description", "owners", "columns.description");
|
||||||
|
|
||||||
private static final SearchClient searchClient = Entity.getSearchRepository().getSearchClient();
|
|
||||||
|
|
||||||
public TableRepository() {
|
public TableRepository() {
|
||||||
super(
|
super(
|
||||||
TableResource.COLLECTION_PATH,
|
TableResource.COLLECTION_PATH,
|
||||||
|
@ -1988,9 +1988,14 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void patch_withChangeSource(TestInfo test) throws IOException {
|
void patch_withChangeSource(TestInfo test) throws IOException {
|
||||||
|
Column nestedColumns = getColumn("testNested", INT, null);
|
||||||
CreateTable create =
|
CreateTable create =
|
||||||
createRequest(test)
|
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 table = createAndCheckEntity(create, ADMIN_AUTH_HEADERS);
|
||||||
|
|
||||||
Table updated = JsonUtils.deepCopy(table, Table.class);
|
Table updated = JsonUtils.deepCopy(table, Table.class);
|
||||||
@ -2074,6 +2079,35 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
|||||||
.get(
|
.get(
|
||||||
FullyQualifiedName.build(
|
FullyQualifiedName.build(
|
||||||
"columns", automatedUpdate.getColumns().get(0).getName(), "description")));
|
"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 {
|
private void assertChangeSummaryInSearch(EntityInterface entity) throws IOException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user