Commit c6ee2779 by Ashutosh Mestry

ATLAS-3489: Import API: Deleted entity handling improvement.

parent 8f807351
...@@ -1047,7 +1047,7 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore { ...@@ -1047,7 +1047,7 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore {
private AtlasObjectId getAtlasObjectId(AtlasEntity entity) { private AtlasObjectId getAtlasObjectId(AtlasEntity entity) {
AtlasObjectId ret = entityRetriever.toAtlasObjectId(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. // if uniqueAttributes is not empty, reset guid to null.
ret.setGuid(null); ret.setGuid(null);
} }
......
...@@ -29,6 +29,7 @@ import org.apache.atlas.model.impexp.AtlasImportRequest; ...@@ -29,6 +29,7 @@ import org.apache.atlas.model.impexp.AtlasImportRequest;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntityHeader; import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.model.instance.AtlasObjectId; 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.AtlasRelatedObjectId;
import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
...@@ -130,6 +131,11 @@ public class ImportServiceTest extends ExportImportTestBase { ...@@ -130,6 +131,11 @@ public class ImportServiceTest extends ExportImportTestBase {
return getZipSource("sales-v1-full.zip"); 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") @Test(dataProvider = "sales")
public void importDB1(InputStream inputStream) throws AtlasBaseException, IOException { public void importDB1(InputStream inputStream) throws AtlasBaseException, IOException {
loadBaseModel(); loadBaseModel();
...@@ -495,6 +501,35 @@ public class ImportServiceTest extends ExportImportTestBase { ...@@ -495,6 +501,35 @@ public class ImportServiceTest extends ExportImportTestBase {
assertFalse(importService.checkHiveTableIncrementalSkipLineage(importRequest, exportRequest)); 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){ private AtlasImportRequest getImportRequest(String replicatedFrom){
AtlasImportRequest importRequest = getDefaultImportRequest(); AtlasImportRequest importRequest = getDefaultImportRequest();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment