ATLAS-1443: attributes with null value are not included in Atlas API response
Signed-off-by: Madhan Neethiraj <madhan@apache.org>
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java b/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
index 93fd69f..92817d2 100644
--- a/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
@@ -195,7 +195,7 @@
AttributeInfo attributeInfo, Operation operation) throws AtlasException {
final Map<String, Object> valuesMap = typedInstance.getValuesMap();
- if ( valuesMap.containsKey(attributeInfo.name) || operation == Operation.CREATE ) {
+ if ( typedInstance.isValueSet(attributeInfo.name) || operation == Operation.CREATE ) {
Object attrValue = typedInstance.get(attributeInfo.name);
LOG.debug("Mapping attribute {} = {}", attributeInfo.name, attrValue);
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/ITypedInstance.java b/typesystem/src/main/java/org/apache/atlas/typesystem/ITypedInstance.java
index d7f4cb7..c24eb8e 100755
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/ITypedInstance.java
+++ b/typesystem/src/main/java/org/apache/atlas/typesystem/ITypedInstance.java
@@ -83,4 +83,6 @@
void setString(String attrName, String val) throws AtlasException;
String getSignatureHash(MessageDigest digester) throws AtlasException;
-}
+
+ boolean isValueSet(String attrName) throws AtlasException;
+}
\ No newline at end of file
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java
index 42280d0..389b4a5 100755
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java
+++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java
@@ -289,6 +289,10 @@
throw new AtlasException("Get/Set not supported on an Id object");
}
+ public boolean isValueSet(String attrName) throws AtlasException {
+ throw new AtlasException("Attributes not set on an Id object");
+ }
+
@Override
public String getSignatureHash(MessageDigest digester) throws AtlasException {
digester.update(id.getBytes(Charset.forName("UTF-8")));
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java
index 4e21410..328f0d7 100755
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java
+++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java
@@ -48,11 +48,11 @@
public ReferenceableInstance(Id id, String dataTypeName, FieldMapping fieldMapping, boolean[] nullFlags,
- boolean[] explicitNullFlags, boolean[] bools, byte[] bytes, short[] shorts, int[] ints, long[] longs, float[] floats, double[] doubles,
+ boolean[] explicitSets, boolean[] bools, byte[] bytes, short[] shorts, int[] ints, long[] longs, float[] floats, double[] doubles,
BigDecimal[] bigDecimals, BigInteger[] bigIntegers, Date[] dates, String[] strings,
ImmutableList<Object>[] arrays, ImmutableMap<Object, Object>[] maps, StructInstance[] structs,
ReferenceableInstance[] referenceableInstances, Id[] ids, ImmutableMap<String, ITypedStruct> traits) {
- super(dataTypeName, fieldMapping, nullFlags, explicitNullFlags, bools, bytes, shorts, ints, longs, floats, doubles, bigDecimals,
+ super(dataTypeName, fieldMapping, nullFlags, explicitSets, bools, bytes, shorts, ints, longs, floats, doubles, bigDecimals,
bigIntegers, dates, strings, arrays, maps, structs, referenceableInstances, ids);
this.id = id;
this.traits = traits;
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java
index cdfaad0..9ac591a 100755
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java
+++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java
@@ -279,10 +279,10 @@
public Map<String, Object> getValuesMap() throws AtlasException {
Map<String, Object> m = new HashMap<>();
for (String attr : fieldMapping.fields.keySet()) {
- int pos = fieldMapping.fieldNullPos.get(attr);
- if ( explicitSets[pos] ) {
+// int pos = fieldMapping.fieldNullPos.get(attr);
+// if ( explicitSets[pos] ) {
m.put(attr, get(attr));
- }
+// }
}
return m;
}
@@ -774,6 +774,12 @@
}
@Override
+ public boolean isValueSet(final String attrName) throws AtlasException {
+ int nullPos = fieldMapping.fieldNullPos.get(attrName);
+ return explicitSets[nullPos];
+ }
+
+ @Override
public String toShortString() {
return String.format("struct[type=%s]", dataTypeName);
}