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/28 16:16:21 UTC
[atlas] branch master updated: ATLAS-3489: Import API: Deleted
entity handling improvement.
This is an automated email from the ASF dual-hosted git repository.
amestry pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push:
new c6ee277 ATLAS-3489: Import API: Deleted entity handling improvement.
c6ee277 is described below
commit c6ee27790db7905f8d9b5b02f2961d59cc76b5cb
Author: Ashutosh Mestry <am...@hortonworks.com>
AuthorDate: Sun Oct 27 21:53:49 2019 -0700
ATLAS-3489: Import API: Deleted entity handling improvement.
---
.../store/graph/v2/AtlasEntityStoreV2.java | 2 +-
.../atlas/repository/impexp/ImportServiceTest.java | 35 +++++++++++++++++++++
repository/src/test/resources/dup_col_deleted.zip | Bin 0 -> 19279 bytes
3 files changed, 36 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 95f6ec3..c14850f 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
@@ -29,6 +29,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.AtlasObjectId;
+import org.apache.atlas.model.instance.AtlasRelationship;
import org.apache.atlas.model.instance.AtlasRelatedObjectId;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.repository.Constants;
@@ -130,6 +131,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();
@@ -495,6 +501,35 @@ public class ImportServiceTest extends ExportImportTestBase {
assertFalse(importService.checkHiveTableIncrementalSkipLineage(importRequest, exportRequest));
}
+ @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);
+ }
+ }
+ }
+
private AtlasImportRequest getImportRequest(String replicatedFrom){
AtlasImportRequest importRequest = getDefaultImportRequest();
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