fix: conditioned call to getColumnTags to columns fields (#13652)

This commit is contained in:
Teddy 2023-10-20 17:50:52 +02:00 committed by GitHub
parent 096a08ce57
commit feb52647d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 7 deletions

View File

@ -367,7 +367,7 @@ class OMetaPatchMixin(OMetaPatchMixinBase):
Updated Entity
"""
instance: Optional[Table] = self._fetch_entity_if_exists(
entity=Table, entity_id=table.id, fields=["tags"]
entity=Table, entity_id=table.id, fields=["tags", "columns"]
)
if not instance:

View File

@ -88,9 +88,9 @@ import org.openmetadata.service.util.ResultList;
public class TableRepository extends EntityRepository<Table> {
// Table fields that can be patched in a PATCH request
static final String PATCH_FIELDS = "tableConstraints,tablePartition";
static final String PATCH_FIELDS = "tableConstraints,tablePartition,columns";
// Table fields that can be updated in a PUT request
static final String UPDATE_FIELDS = "tableConstraints,tablePartition,dataModel,sourceUrl";
static final String UPDATE_FIELDS = "tableConstraints,tablePartition,dataModel,sourceUrl,columns";
public static final String FIELD_RELATION_COLUMN_TYPE = "table.columns.column";
public static final String FIELD_RELATION_TABLE_TYPE = "table";
@ -126,7 +126,10 @@ public class TableRepository extends EntityRepository<Table> {
? EntityUtil.getLatestUsage(daoCollection.usageDAO(), table.getId())
: table.getUsageSummary());
}
if (fields.contains(COLUMN_FIELD)) {
// We'll get column tags only if we are getting the column fields
getColumnTags(fields.contains(FIELD_TAGS), table.getColumns());
}
table.setJoins(fields.contains("joins") ? getJoins(table) : table.getJoins());
table.setTableProfilerConfig(
fields.contains(TABLE_PROFILER_CONFIG) ? getTableProfilerConfig(table) : table.getTableProfilerConfig());

View File

@ -84,7 +84,7 @@ import org.openmetadata.service.util.ResultList;
public class TableResource extends EntityResource<Table, TableRepository> {
public static final String COLLECTION_PATH = "v1/tables/";
static final String FIELDS =
"tableConstraints,tablePartition,usageSummary,owner,customMetrics,"
"tableConstraints,tablePartition,usageSummary,owner,customMetrics,columns,"
+ "tags,followers,joins,viewDefinition,dataModel,extension,testSuite,domain,dataProducts,lifeCycle";
@Override

View File

@ -147,7 +147,7 @@ public class PIIMasker {
MessageParser.EntityLink testCaseLink = MessageParser.EntityLink.parse(testCase.getEntityLink());
Table table =
Entity.getEntityByName(
Entity.TABLE, testCaseLink.getEntityFQN(), "owner,tags", Include.NON_DELETED);
Entity.TABLE, testCaseLink.getEntityFQN(), "owner,tags,columns", Include.NON_DELETED);
// Ignore table tests
if (testCaseLink.getFieldName() == null) return testCase;

View File

@ -595,7 +595,7 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
// Task can be resolved by the User2 to whom the task is assigned
resolveTask(taskId, resolveTask, USER2_AUTH_HEADERS);
Table table = TABLE_RESOURCE_TEST.getEntity(TABLE.getId(), "tags", USER_AUTH_HEADERS);
Table table = TABLE_RESOURCE_TEST.getEntity(TABLE.getId(), "tags,columns", USER_AUTH_HEADERS);
List<TagLabel> tags = EntityUtil.getColumn(table, C1).getTags();
assertEquals(USER_ADDRESS_TAG_LABEL.getTagFQN(), tags.get(0).getTagFQN());