Hi,
1. ATLAS-4181 <https://issues.apache.org/jira/browse/ATLAS-4181> is created to provide option for adding mandatory attributes to existing entity definitions and it is available in atlas versions 3.0.0 & 2.2.0 On a high level, this feature is supported by the Typedef patch with action "ADD_MANDATORY_ATTRIBUTE", more details can be found in Jira ATLAS-4181 <https://issues.apache.org/jira/browse/ATLAS-4181> Thanks, Radhika On Wed, Jan 20, 2021 at 5:13 PM Jiaxin Ye <jiaxin...@airbnb.com> wrote: > Hey Sreeni, > > > > Have you found the solution yet? We are facing the same issue when deleted > an entity def and then recreated it with mandatory field. > > > > Thanks, > > Jiaxin > > > > *From: *Nallapati, Sreenivasulu <sreenivasulu_nallap...@intuit.com> > *Date: *Thursday, October 1, 2020 at 5:27 AM > *To: *d...@atlas.apache.org <d...@atlas.apache.org>, user@atlas.apache.org < > user@atlas.apache.org> > *Subject: *Adding mandatory attribute to an existing entity type > > Hi, > > > > We have an entity type (schema) with name, environment, schema_format as > attributes and we have created few entities for this type. > > We want to add new mandatory attribute data_format to *schema* type. As > atlas is not allowing to add a mandatory attribute, we followed the below > steps to add the mandatory attribute > > > > 1. Delete all the entities of this type from atlas. > 2. Delete the existing type using *curl -negotiate -u user:pwd -X > DELETE -H 'Content-Type: application/json' -H 'Accept: application/json' > "http://localhost:21000/api/atlas/v2/types/typedef/name/schema > <http://localhost:21000/api/atlas/v2/types/typedef/name/schema>"* API. > 1. > org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphManagement.deletePropertyKey(String) > method renamed all the three properties to schema.name_deleted_0, > schema.environment_deleted_0 and schema.schema_format_deleted_0 > 3. After deleting the model, we posted the updated model with new > mandatory attribute using *curl -negotiate -u user:pwd -X POST -H > 'Content-Type: application/json' -H 'Accept: application/json' > "http://localhost:21000/api/atlas/v2/types/typedefs > <http://localhost:21000/api/atlas/v2/types/typedefs>" -d "@./schema.json"* > 4. Now graph management has new properties *name, environment, > schema_format, data_format* and previously renamed properties > *name_deleted_0, > environment_deleted_0, schema_format_deleted_0* > 5. When we try to create a new entity with the new model, the entity > got created successfully in the backend store and failing to create the > entity in the search store with the below error (because of mapped-type) > > > > Multiple entries with same key: schema.name > =org.janusgraph.diskstorage.indexing.StandardKeyInformation@55e7c2b4 and > schema.name > =org.janusgraph.diskstorage.indexing.StandardKeyInformation@b884972 > > at > com.google.common.collect.ImmutableMap.conflictException(ImmutableMap.java:215) > > at > com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:209) > > at > com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:147) > > at > com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:110) > > at > com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:393) > > at > org.janusgraph.graphdb.database.IndexSerializer$IndexInfoRetriever$1.get(IndexSerializer.java:162) > > > > 1. The renamed attributes (schema.name_deleted_0) has a property > “mapped-name” to the schema.type attribute. While building the > ImmutableMap, “mapped-name” of schema.name_deleted_0 is colliding with the > schema.name > > > > > > Have few queries about this functionality. > > 1. Is there any reason why properties are getting renamed instead of > delete when we delete the model? > 2. Is there any configuration setting to tweak this functionality or > How to add a mandatory attribute to the existing model type? > 3. Is it ok if we delete the renamed > (m.getPropertyKey('schema.name_deleted_0').remove())properties from graph > management using gremlin console? > > > > Please guide us in the proper direction if we are not doing the right > thing. > > > > > > > > --- > > Regards, > > Sreeni >