Commit aaf0ba23 by Madhan Neethiraj

ATLAS-3187: columns attribute is empty for deleted hive_table entity

parent ed288a75
...@@ -72,7 +72,6 @@ import java.util.HashMap; ...@@ -72,7 +72,6 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.ListIterator;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
...@@ -85,7 +84,7 @@ import static org.apache.atlas.glossary.GlossaryUtils.TERM_ASSIGNMENT_ATTR_EXPRE ...@@ -85,7 +84,7 @@ import static org.apache.atlas.glossary.GlossaryUtils.TERM_ASSIGNMENT_ATTR_EXPRE
import static org.apache.atlas.glossary.GlossaryUtils.TERM_ASSIGNMENT_ATTR_SOURCE; import static org.apache.atlas.glossary.GlossaryUtils.TERM_ASSIGNMENT_ATTR_SOURCE;
import static org.apache.atlas.glossary.GlossaryUtils.TERM_ASSIGNMENT_ATTR_STATUS; import static org.apache.atlas.glossary.GlossaryUtils.TERM_ASSIGNMENT_ATTR_STATUS;
import static org.apache.atlas.glossary.GlossaryUtils.TERM_ASSIGNMENT_ATTR_STEWARD; import static org.apache.atlas.glossary.GlossaryUtils.TERM_ASSIGNMENT_ATTR_STEWARD;
import static org.apache.atlas.model.instance.AtlasRelationship.Status.ACTIVE; import static org.apache.atlas.model.instance.AtlasRelationship.Status.DELETED;
import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_BIGDECIMAL; import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_BIGDECIMAL;
import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_BIGINTEGER; import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_BIGINTEGER;
import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_BOOLEAN; import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_BOOLEAN;
...@@ -101,12 +100,9 @@ import static org.apache.atlas.repository.Constants.CLASSIFICATION_ENTITY_GUID; ...@@ -101,12 +100,9 @@ import static org.apache.atlas.repository.Constants.CLASSIFICATION_ENTITY_GUID;
import static org.apache.atlas.repository.Constants.CLASSIFICATION_LABEL; import static org.apache.atlas.repository.Constants.CLASSIFICATION_LABEL;
import static org.apache.atlas.repository.Constants.CLASSIFICATION_VALIDITY_PERIODS_KEY; import static org.apache.atlas.repository.Constants.CLASSIFICATION_VALIDITY_PERIODS_KEY;
import static org.apache.atlas.repository.Constants.TERM_ASSIGNMENT_LABEL; import static org.apache.atlas.repository.Constants.TERM_ASSIGNMENT_LABEL;
import static org.apache.atlas.repository.graph.GraphHelper.EDGE_LABEL_PREFIX;
import static org.apache.atlas.repository.graph.GraphHelper.addToPropagatedTraitNames;
import static org.apache.atlas.repository.graph.GraphHelper.getAdjacentEdgesByLabel; import static org.apache.atlas.repository.graph.GraphHelper.getAdjacentEdgesByLabel;
import static org.apache.atlas.repository.graph.GraphHelper.getAllClassificationEdges; import static org.apache.atlas.repository.graph.GraphHelper.getAllClassificationEdges;
import static org.apache.atlas.repository.graph.GraphHelper.getAllTraitNames; import static org.apache.atlas.repository.graph.GraphHelper.getAllTraitNames;
import static org.apache.atlas.repository.graph.GraphHelper.getAssociatedEntityVertex;
import static org.apache.atlas.repository.graph.GraphHelper.getBlockedClassificationIds; import static org.apache.atlas.repository.graph.GraphHelper.getBlockedClassificationIds;
import static org.apache.atlas.repository.graph.GraphHelper.getArrayElementsProperty; import static org.apache.atlas.repository.graph.GraphHelper.getArrayElementsProperty;
import static org.apache.atlas.repository.graph.GraphHelper.getClassificationEntityStatus; import static org.apache.atlas.repository.graph.GraphHelper.getClassificationEntityStatus;
...@@ -1108,42 +1104,64 @@ public class EntityGraphRetriever { ...@@ -1108,42 +1104,64 @@ public class EntityGraphRetriever {
entity.setRelationshipAttribute(attributeName, ret); entity.setRelationshipAttribute(attributeName, ret);
if (attributeEndDef.getIsLegacyAttribute() && !entity.hasAttribute(attributeName)) { if (attributeEndDef.getIsLegacyAttribute() && !entity.hasAttribute(attributeName)) {
entity.setAttribute(attributeName, toAtlasObjectId(ret)); entity.setAttribute(attributeName, toLegacyAttribute(ret));
} }
} }
return ret; return ret;
} }
private Object toAtlasObjectId(Object obj) { private Object toLegacyAttribute(Object obj) {
final Object ret; final Object ret;
if (obj instanceof AtlasRelatedObjectId) { if (obj instanceof AtlasRelatedObjectId) {
AtlasRelatedObjectId relatedObjId = (AtlasRelatedObjectId) obj; ret = toLegacyAttribute((AtlasRelatedObjectId) obj);
ret = relatedObjId.getRelationshipStatus() == ACTIVE ? new AtlasObjectId((AtlasObjectId) obj) : null;
} else if (obj instanceof Collection) { } else if (obj instanceof Collection) {
List list = new ArrayList(); ret = toLegacyAttribute((Collection) obj);
} else if (obj instanceof Map) {
ret = toLegacyAttribute((Map) obj);
} else {
ret = obj;
}
for (Object elem : (Collection) obj) { return ret;
Object objId = toAtlasObjectId(elem); }
if (objId != null) { private AtlasObjectId toLegacyAttribute(AtlasRelatedObjectId relatedObjId) {
list.add(objId); final AtlasObjectId ret;
}
}
ret = list; if (relatedObjId.getRelationshipStatus() == DELETED && relatedObjId.getEntityStatus() == AtlasEntity.Status.ACTIVE) {
} else if (obj instanceof Map) { ret = null;
Map map = new HashMap(); } else {
ret = new AtlasObjectId(relatedObjId);
}
return ret;
}
private Collection toLegacyAttribute(Collection collection) {
final List ret = new ArrayList();
for (Object elem : collection) {
Object objId = toLegacyAttribute(elem);
for (Object key : ((Map) obj).keySet()) { if (objId != null) {
map.put(key, toAtlasObjectId(((Map) obj).get(key))); ret.add(objId);
} }
}
ret = map; return ret;
} else { }
ret = obj;
private Map toLegacyAttribute(Map map) {
final Map ret = new HashMap();
for (Object key : map.keySet()) {
Object elem = toLegacyAttribute(map.get(key));
if (elem != null) {
ret.put(key, elem);
}
} }
return ret; return ret;
......
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