atlas git commit: ATLAS-2965: Duplicate entities are created when when same qualifiedName is given but different guids
Repository: atlas Updated Branches: refs/heads/branch-0.8 daabed131 -> a36b27ae7 ATLAS-2965: Duplicate entities are created when when same qualifiedName is given but different guids Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/a36b27ae Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/a36b27ae Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/a36b27ae Branch: refs/heads/branch-0.8 Commit: a36b27ae798d97b5b30238d13b8d63a3652a0260 Parents: daabed1 Author: Sarath Subramanian Authored: Thu Nov 15 15:43:29 2018 -0800 Committer: Sarath Subramanian Committed: Thu Nov 15 15:43:29 2018 -0800 -- .../test/java/org/apache/atlas/TestUtilsV2.java | 33 .../store/graph/v1/AtlasEntityStoreV1.java | 29 - .../store/graph/v1/EntityGraphMapper.java | 24 +- .../store/graph/v1/AtlasEntityStoreV1Test.java | 23 ++ 4 files changed, 107 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/atlas/blob/a36b27ae/intg/src/test/java/org/apache/atlas/TestUtilsV2.java -- diff --git a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java index 8470054..18f8b25 100755 --- a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java +++ b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java @@ -1057,6 +1057,39 @@ public final class TestUtilsV2 { return ret; } +public static AtlasEntityWithExtInfo createTableEntityDuplicatesV2(AtlasEntity dbEntity) { +AtlasEntity tblEntity = new AtlasEntity(TABLE_TYPE); + +tblEntity.setAttribute(NAME, RandomStringUtils.randomAlphanumeric(10)); +tblEntity.setAttribute("description", "random table"); +tblEntity.setAttribute("type", "type"); +tblEntity.setAttribute("tableType", "MANAGED"); +tblEntity.setAttribute("database", AtlasTypeUtil.getAtlasObjectId(dbEntity)); + +AtlasEntity col1 = createColumnEntity(tblEntity); +col1.setAttribute(NAME, "col1"); + +AtlasEntity col2 = createColumnEntity(tblEntity); +col2.setAttribute(NAME, "col1"); + +AtlasEntity col3 = createColumnEntity(tblEntity); +col3.setAttribute(NAME, "col1"); + +// all 3 columns have different guid but same typeName and unique attributes +tblEntity.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(AtlasTypeUtil.getAtlasObjectId(col1), + AtlasTypeUtil.getAtlasObjectId(col2), + AtlasTypeUtil.getAtlasObjectId(col3))); + +AtlasEntityWithExtInfo ret = new AtlasEntityWithExtInfo(tblEntity); + +ret.addReferredEntity(dbEntity); +ret.addReferredEntity(col1); +ret.addReferredEntity(col2); +ret.addReferredEntity(col3); + +return ret; +} + public static AtlasEntity createColumnEntity(AtlasEntity tableEntity) { return createColumnEntity(tableEntity, "col" + seq.addAndGet(1)); } http://git-wip-us.apache.org/repos/asf/atlas/blob/a36b27ae/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java -- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java index c98c8c4..f578ded 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java @@ -612,10 +612,10 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { RequestContextV1requestContext = RequestContextV1.get(); for (String guid : discoveryContext.getReferencedGuids()) { -AtlasVertex vertex = discoveryContext.getResolvedEntityVertex(guid); AtlasEntity entity = entityStream.getByGuid(guid); if (entity != null) { +AtlasVertex vertex = getResolvedEntityVertex(discoveryContext, entity); if (vertex != null) { // entity would be null if guid is not in the stream but referenced by an entity in the stream @@ -650,6 +650,8 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { discoveryContext.addResolvedGuid(guid, vertex); + discoveryContext.addResolvedIdByUniqAttribs(getAtlasObjectId(entity), vertex); + String generatedGuid = AtlasGraphUtilsV1.getIdFrom
atlas git commit: ATLAS-2965: Duplicate entities are created when when same qualifiedName is given but different guids
Repository: atlas Updated Branches: refs/heads/branch-1.0 7869c9a5f -> d3aaef05f ATLAS-2965: Duplicate entities are created when when same qualifiedName is given but different guids (cherry picked from commit 40329046a1d67059409c02396d696153bb2de653) Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/d3aaef05 Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/d3aaef05 Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/d3aaef05 Branch: refs/heads/branch-1.0 Commit: d3aaef05fa4fdae5e1a5dda4ac8cb6a40748f4c3 Parents: 7869c9a Author: Sarath Subramanian Authored: Thu Nov 15 15:42:19 2018 -0800 Committer: Sarath Subramanian Committed: Thu Nov 15 15:42:57 2018 -0800 -- .../test/java/org/apache/atlas/TestUtilsV2.java | 33 .../store/graph/v2/AtlasEntityStoreV2.java | 33 +++- .../store/graph/v2/EntityGraphRetriever.java| 21 + .../graph/v2/AtlasComplexAttributesTest.java| 21 ++--- .../store/graph/v2/AtlasEntityStoreV2Test.java | 21 + 5 files changed, 124 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/atlas/blob/d3aaef05/intg/src/test/java/org/apache/atlas/TestUtilsV2.java -- diff --git a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java index 4e9a651..093105b 100755 --- a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java +++ b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java @@ -1256,6 +1256,39 @@ public final class TestUtilsV2 { return newtestEntityDef; } +public static AtlasEntityWithExtInfo createTableEntityDuplicatesV2(AtlasEntity dbEntity) { +AtlasEntity tblEntity = new AtlasEntity(TABLE_TYPE); + +tblEntity.setAttribute(NAME, RandomStringUtils.randomAlphanumeric(10)); +tblEntity.setAttribute("description", "random table"); +tblEntity.setAttribute("type", "type"); +tblEntity.setAttribute("tableType", "MANAGED"); +tblEntity.setAttribute("database", AtlasTypeUtil.getAtlasObjectId(dbEntity)); + +AtlasEntity col1 = createColumnEntity(tblEntity); +col1.setAttribute(NAME, "col1"); + +AtlasEntity col2 = createColumnEntity(tblEntity); +col2.setAttribute(NAME, "col1"); + +AtlasEntity col3 = createColumnEntity(tblEntity); +col3.setAttribute(NAME, "col1"); + +// all 3 columns have different guid but same typeName and unique attributes +tblEntity.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(AtlasTypeUtil.getAtlasObjectId(col1), +AtlasTypeUtil.getAtlasObjectId(col2), +AtlasTypeUtil.getAtlasObjectId(col3))); + +AtlasEntityWithExtInfo ret = new AtlasEntityWithExtInfo(tblEntity); + +ret.addReferredEntity(dbEntity); +ret.addReferredEntity(col1); +ret.addReferredEntity(col2); +ret.addReferredEntity(col3); + +return ret; +} + public static AtlasEntity createColumnEntity(AtlasEntity tableEntity) { return createColumnEntity(tableEntity, "col" + seq.addAndGet(1)); } http://git-wip-us.apache.org/repos/asf/atlas/blob/d3aaef05/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java -- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java index ee8de1f..6ee0279 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java @@ -742,10 +742,11 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore { RequestContext requestContext = RequestContext.get(); for (String guid : discoveryContext.getReferencedGuids()) { -AtlasVertex vertex = discoveryContext.getResolvedEntityVertex(guid); AtlasEntity entity = entityStream.getByGuid(guid); if (entity != null) { // entity would be null if guid is not in the stream but referenced by an entity in the stream +AtlasVertex vertex = getResolvedEntityVertex(discoveryContext, entity); + if (vertex != null) { if (!isPartialUpdate) { graphDiscoverer.validateAndNormalize(entity); @@ -779,6 +780,8 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore { discoveryContext.addResolvedGuid(guid, vertex); + discov
atlas git commit: ATLAS-2965: Duplicate entities are created when when same qualifiedName is given but different guids
Repository: atlas Updated Branches: refs/heads/master d003ddb33 -> 40329046a ATLAS-2965: Duplicate entities are created when when same qualifiedName is given but different guids Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/40329046 Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/40329046 Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/40329046 Branch: refs/heads/master Commit: 40329046a1d67059409c02396d696153bb2de653 Parents: d003ddb Author: Sarath Subramanian Authored: Thu Nov 15 15:42:19 2018 -0800 Committer: Sarath Subramanian Committed: Thu Nov 15 15:42:19 2018 -0800 -- .../test/java/org/apache/atlas/TestUtilsV2.java | 33 .../store/graph/v2/AtlasEntityStoreV2.java | 33 +++- .../store/graph/v2/EntityGraphRetriever.java| 21 + .../graph/v2/AtlasComplexAttributesTest.java| 21 ++--- .../store/graph/v2/AtlasEntityStoreV2Test.java | 21 + 5 files changed, 124 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/atlas/blob/40329046/intg/src/test/java/org/apache/atlas/TestUtilsV2.java -- diff --git a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java index 4e9a651..093105b 100755 --- a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java +++ b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java @@ -1256,6 +1256,39 @@ public final class TestUtilsV2 { return newtestEntityDef; } +public static AtlasEntityWithExtInfo createTableEntityDuplicatesV2(AtlasEntity dbEntity) { +AtlasEntity tblEntity = new AtlasEntity(TABLE_TYPE); + +tblEntity.setAttribute(NAME, RandomStringUtils.randomAlphanumeric(10)); +tblEntity.setAttribute("description", "random table"); +tblEntity.setAttribute("type", "type"); +tblEntity.setAttribute("tableType", "MANAGED"); +tblEntity.setAttribute("database", AtlasTypeUtil.getAtlasObjectId(dbEntity)); + +AtlasEntity col1 = createColumnEntity(tblEntity); +col1.setAttribute(NAME, "col1"); + +AtlasEntity col2 = createColumnEntity(tblEntity); +col2.setAttribute(NAME, "col1"); + +AtlasEntity col3 = createColumnEntity(tblEntity); +col3.setAttribute(NAME, "col1"); + +// all 3 columns have different guid but same typeName and unique attributes +tblEntity.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(AtlasTypeUtil.getAtlasObjectId(col1), +AtlasTypeUtil.getAtlasObjectId(col2), +AtlasTypeUtil.getAtlasObjectId(col3))); + +AtlasEntityWithExtInfo ret = new AtlasEntityWithExtInfo(tblEntity); + +ret.addReferredEntity(dbEntity); +ret.addReferredEntity(col1); +ret.addReferredEntity(col2); +ret.addReferredEntity(col3); + +return ret; +} + public static AtlasEntity createColumnEntity(AtlasEntity tableEntity) { return createColumnEntity(tableEntity, "col" + seq.addAndGet(1)); } http://git-wip-us.apache.org/repos/asf/atlas/blob/40329046/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java -- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java index ee8de1f..6ee0279 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java @@ -742,10 +742,11 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore { RequestContext requestContext = RequestContext.get(); for (String guid : discoveryContext.getReferencedGuids()) { -AtlasVertex vertex = discoveryContext.getResolvedEntityVertex(guid); AtlasEntity entity = entityStream.getByGuid(guid); if (entity != null) { // entity would be null if guid is not in the stream but referenced by an entity in the stream +AtlasVertex vertex = getResolvedEntityVertex(discoveryContext, entity); + if (vertex != null) { if (!isPartialUpdate) { graphDiscoverer.validateAndNormalize(entity); @@ -779,6 +780,8 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore { discoveryContext.addResolvedGuid(guid, vertex); + discoveryContext.addResolvedIdByUniqAttribs(getAtlasObjectId(entity), vertex); +