atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From suma...@apache.org
Subject incubator-atlas git commit: ATLAS-1049: non-existing supertype in query filter should not fail the query
Date Wed, 27 Jul 2016 00:31:07 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/master d0a9b9999 -> 2dba5feab


ATLAS-1049: non-existing supertype in query filter should not fail the query


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/2dba5fea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/2dba5fea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/2dba5fea

Branch: refs/heads/master
Commit: 2dba5feabd6ab1821546888c607bb3e8d032de61
Parents: d0a9b99
Author: Madhan Neethiraj <madhan@apache.org>
Authored: Tue Jul 26 16:47:19 2016 -0700
Committer: Suma Shivaprasad <sumasai.shivaprasad@gmail.com>
Committed: Tue Jul 26 17:30:58 2016 -0700

----------------------------------------------------------------------
 release-log.txt                                 |  1 +
 .../types/cache/DefaultTypeCache.java           |  7 +++++-
 .../types/cache/DefaultTypeCacheTest.java       | 24 +++++++-------------
 3 files changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2dba5fea/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index c3ab28b..5380a6f 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
 
 
 ALL CHANGES:
+ATLAS-1049 Fix validation while filtering by supertypes(mneethiraj via sumasai)
 ATLAS-1053 Fix issues flagged by Coverity scan - potential NPE (mneethiraj via sumasai)
 ATLAS-1052 Fix NPE in HiveHook due to null Session State (sumasai)
 ATLAS-1051 Sqoop Hook does not package HDFS model jars which is required (sumasai)

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2dba5fea/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java
b/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java
index 150418e..6c6d5a0 100644
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java
+++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java
@@ -27,6 +27,8 @@ import org.apache.atlas.typesystem.types.IDataType;
 import org.apache.atlas.typesystem.types.StructType;
 import org.apache.atlas.typesystem.types.TraitType;
 import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -42,6 +44,7 @@ import java.util.concurrent.ConcurrentHashMap;
 @Singleton
 @SuppressWarnings("rawtypes")
 public class DefaultTypeCache implements TypeCache {
+    private static final Logger LOG = LoggerFactory.getLogger(DefaultTypeCache.class);
 
     private Map<String, IDataType> types_ = new ConcurrentHashMap<>();
     private static final List<TypeCategory> validTypeFilterCategories =
@@ -183,7 +186,9 @@ public class DefaultTypeCache implements TypeCache {
             case SUPERTYPE:
             case NOT_SUPERTYPE:
                 if (!has(filterEntry.getValue())) {
-                    throw new IllegalArgumentException("Invalid supertype " + filterEntry.getValue());
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("{}: supertype does not exist", filterEntry.getValue());
+                    }
                 }
                 break;
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2dba5fea/typesystem/src/test/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCacheTest.java
----------------------------------------------------------------------
diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCacheTest.java
b/typesystem/src/test/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCacheTest.java
index 335023f..f885a6b 100644
--- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCacheTest.java
+++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCacheTest.java
@@ -436,23 +436,15 @@ public class DefaultTypeCacheTest {
         }
 
         //invalid supertype
-        try {
-            ts.getTypeNames(new HashMap<TypeCache.TYPE_FILTER, String>() {{
-                put(TypeCache.TYPE_FILTER.SUPERTYPE, "X");
-            }});
-            fail("Expected IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            //expected
-        }
+        results = ts.getTypeNames(new HashMap<TypeCache.TYPE_FILTER, String>() {{
+            put(TypeCache.TYPE_FILTER.SUPERTYPE, "X");
+        }});
+        assertTrue(results.isEmpty(), "Expected empty result for non-existent type 'X'. Found:
" + results);
 
         //invalid supertype
-        try {
-            ts.getTypeNames(new HashMap<TypeCache.TYPE_FILTER, String>() {{
-                put(TypeCache.TYPE_FILTER.NOT_SUPERTYPE, "X");
-            }});
-            fail("Expected IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            //expected
-        }
+        results = ts.getTypeNames(new HashMap<TypeCache.TYPE_FILTER, String>() {{
+            put(TypeCache.TYPE_FILTER.NOT_SUPERTYPE, "X");
+        }});
+        assertTrue(results.containsAll(Arrays.asList("A", "A1", "B", "C")), "Results: " +
results);
     }
 }


Mime
View raw message