You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by am...@apache.org on 2019/10/30 17:02:45 UTC

[atlas] branch branch-2.0 updated: ATLAS-3489: Import API: Deleted entity handling improvement.gs

This is an automated email from the ASF dual-hosted git repository.

amestry pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new b157d53  ATLAS-3489: Import API: Deleted entity handling improvement.gs
b157d53 is described below

commit b157d53e9cb94b4e5893bc7af2ab0710b361ea04
Author: Ashutosh Mestry <am...@hortonworks.com>
AuthorDate: Sun Oct 27 21:53:49 2019 -0700

    ATLAS-3489: Import API: Deleted entity handling improvement.gs
---
 .../store/graph/v2/AtlasEntityStoreV2.java         |   2 +-
 .../atlas/repository/impexp/ImportServiceTest.java |  36 +++++++++++++++++++++
 repository/src/test/resources/dup_col_deleted.zip  | Bin 0 -> 19279 bytes
 3 files changed, 37 insertions(+), 1 deletion(-)

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 5b3c27d..17b4a5b 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
@@ -1047,7 +1047,7 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore {
     private AtlasObjectId getAtlasObjectId(AtlasEntity entity) {
         AtlasObjectId ret = entityRetriever.toAtlasObjectId(entity);
 
-        if (ret != null && MapUtils.isNotEmpty(ret.getUniqueAttributes())) {
+        if (ret != null && !RequestContext.get().isImportInProgress() && MapUtils.isNotEmpty(ret.getUniqueAttributes())) {
             // if uniqueAttributes is not empty, reset guid to null.
             ret.setGuid(null);
         }
diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
index 1bfe62b..71dd44f 100644
--- a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
@@ -28,6 +28,7 @@ import org.apache.atlas.model.impexp.AtlasImportRequest;
 import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.model.instance.AtlasEntityHeader;
 import org.apache.atlas.model.instance.AtlasRelatedObjectId;
+import org.apache.atlas.model.instance.AtlasRelationship;
 import org.apache.atlas.model.instance.EntityMutationResponse;
 import org.apache.atlas.repository.Constants;
 import org.apache.atlas.repository.graph.AtlasGraphProvider;
@@ -124,6 +125,11 @@ public class ImportServiceTest extends ExportImportTestBase {
         return getZipSource("sales-v1-full.zip");
     }
 
+    @DataProvider(name = "dup_col_data")
+    public static Object[][] getDataForDuplicateColumn(ITestContext context) throws IOException, AtlasBaseException {
+        return getZipSource("dup_col_deleted.zip");
+    }
+
     @Test(dataProvider = "sales")
     public void importDB1(InputStream inputStream) throws AtlasBaseException, IOException {
         loadBaseModel();
@@ -466,4 +472,34 @@ public class ImportServiceTest extends ExportImportTestBase {
     public void importEmptyZip() throws IOException, AtlasBaseException {
         new ZipSource((InputStream) getZipSource("empty.zip")[0][0]);
     }
+
+    @Test(dataProvider = "dup_col_data")
+    public void testImportDuplicateColumnsWithDifferentStatus(InputStream inputStream) throws IOException, AtlasBaseException {
+        loadBaseModel();
+        loadFsModel();
+        loadHiveModel();
+
+        runImportWithNoParameters(importService, inputStream);
+
+        AtlasEntity.AtlasEntityWithExtInfo atlasEntityWithExtInfo = entityStore.getById("e18e15de-1810-4724-881a-5cb6b2160077");
+        assertNotNull(atlasEntityWithExtInfo);
+
+        AtlasEntity atlasEntity = atlasEntityWithExtInfo.getEntity();
+        assertNotNull(atlasEntity);
+
+        List<AtlasRelatedObjectId> columns = (List<AtlasRelatedObjectId>) atlasEntity.getRelationshipAttribute("columns");
+        assertEquals( columns.size(), 4);
+
+        for(AtlasRelatedObjectId id : columns){
+            if(id.getGuid().equals("a3de3e3b-4bcd-4e57-a988-1101a2360200")){
+                assertEquals(id.getEntityStatus(), AtlasEntity.Status.DELETED);
+                assertEquals(id.getRelationshipStatus(), AtlasRelationship.Status.DELETED);
+            }
+            if(id.getGuid().equals("f7fa3768-f3de-48a8-92a5-38ec4070152c")) {
+                assertEquals(id.getEntityStatus(), AtlasEntity.Status.ACTIVE);
+                assertEquals(id.getRelationshipStatus(), AtlasRelationship.Status.ACTIVE);
+            }
+        }
+    }
+
 }
diff --git a/repository/src/test/resources/dup_col_deleted.zip b/repository/src/test/resources/dup_col_deleted.zip
new file mode 100644
index 0000000..b0b5d0d
Binary files /dev/null and b/repository/src/test/resources/dup_col_deleted.zip differ