You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sa...@apache.org on 2019/10/17 20:56:54 UTC
[atlas] branch branch-2.0 updated: ATLAS-3467 - Regression:
Tagfilters (begins_with, ends_with,
contains) and space fetches incorrect results ATLAS-3476 - Regression: Case
insensitivity in tag filters in search
This is an automated email from the ASF dual-hosted git repository.
sarath pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 0cd458b ATLAS-3467 - Regression: Tagfilters (begins_with, ends_with, contains) and space fetches incorrect results ATLAS-3476 - Regression: Case insensitivity in tag filters in search
0cd458b is described below
commit 0cd458b1a8e4c2fd1e88ad1a986c753294084027
Author: Le Ma <lm...@cloudera.com>
AuthorDate: Tue Oct 15 14:09:04 2019 -0700
ATLAS-3467 - Regression: Tagfilters (begins_with, ends_with, contains) and space fetches incorrect results
ATLAS-3476 - Regression: Case insensitivity in tag filters in search
Signed-off-by: Sarath Subramanian <sa...@apache.org>
(cherry picked from commit b064d8c3aad588c4975ddd0ad5bc24e12806e171)
---
.../discovery/ClassificationSearchProcessor.java | 17 +++++++++-
.../atlas/web/adapters/TestEntitiesREST.java | 38 +++++++++++++++++++---
2 files changed, 49 insertions(+), 6 deletions(-)
diff --git a/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java b/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java
index 0aa229c..db92f72 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java
@@ -30,8 +30,11 @@ import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.util.AtlasGremlinQueryProvider;
+import org.apache.atlas.util.SearchPredicateUtil;
import org.apache.atlas.utils.AtlasPerfTracer;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.Predicate;
+import org.apache.commons.collections.PredicateUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.tinkerpop.gremlin.process.traversal.Order;
import org.slf4j.Logger;
@@ -153,7 +156,7 @@ public class ClassificationSearchProcessor extends SearchProcessor {
StringBuilder queryString = new StringBuilder();
graphIndexQueryBuilder.addActiveStateQueryFilter(queryString);
- graphIndexQueryBuilder.addTypeAndSubTypesQueryFilter(queryString, typeAndSubTypesQryStr);
+ graphIndexQueryBuilder.addTypeAndSubTypesQueryFilter(queryString, context.getSearchParameters().getClassification());
constructFilterQuery(queryString, classificationType, filterCriteria, indexAttributes);
@@ -161,6 +164,15 @@ public class ClassificationSearchProcessor extends SearchProcessor {
indexQueryString = STRAY_OR_PATTERN.matcher(indexQueryString).replaceAll(")");
indexQueryString = STRAY_ELIPSIS_PATTERN.matcher(indexQueryString).replaceAll("");
+ Predicate typeNamePredicate = SearchPredicateUtil.getINPredicateGenerator().generatePredicate(Constants.TYPE_NAME_PROPERTY_KEY, typeAndSubTypes, String.class);
+ Predicate attributePredicate = constructInMemoryPredicate(classificationType, filterCriteria, indexAttributes);
+
+ if (attributePredicate != null) {
+ inMemoryPredicate = PredicateUtils.andPredicate(typeNamePredicate, attributePredicate);
+ } else {
+ inMemoryPredicate = typeNamePredicate;
+ }
+
this.classificationIndexQuery = graph.indexQuery(Constants.VERTEX_INDEX, indexQueryString);
} else {
classificationIndexQuery = null;
@@ -263,6 +275,9 @@ public class ClassificationSearchProcessor extends SearchProcessor {
getVerticesFromIndexQueryResult(queryResult, classificationVertices);
+ // Do in-memory filtering before the graph query
+ CollectionUtils.filter(classificationVertices, inMemoryPredicate);
+
} else if (context.getSearchParameters().getTagFilters() != null) {
Iterator<AtlasVertex> queryResult = tagGraphQueryWithAttributes.vertices(qryOffset, limit).iterator();
diff --git a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
index 1e1c1ff..1f3181b 100644
--- a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
+++ b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
@@ -105,6 +105,8 @@ public class TestEntitiesREST {
tableEntity.setAttribute("columns", getObjIdList(columns));
tableEntity2.setAttribute("columns", getObjIdList(columns2));
+
+ createEntities();
}
@AfterMethod
@@ -112,8 +114,7 @@ public class TestEntitiesREST {
RequestContext.clear();
}
- @Test
- public void testCreateOrUpdateEntities() throws Exception {
+ private void createEntities() throws Exception {
AtlasEntitiesWithExtInfo entities = new AtlasEntitiesWithExtInfo();
entities.addEntity(dbEntity);
@@ -142,7 +143,7 @@ public class TestEntitiesREST {
}
}
- @Test(dependsOnMethods = "testCreateOrUpdateEntities")
+ @Test
public void testTagToMultipleEntities() throws Exception{
AtlasClassification tag = new AtlasClassification(TestUtilsV2.CLASSIFICATION, new HashMap<String, Object>() {{ put("tag", "tagName"); }});
@@ -153,7 +154,7 @@ public class TestEntitiesREST {
for (int i = 0; i < createdGuids.get(TABLE_TYPE).size() - 1; i++) {
final AtlasClassification result_tag = entityREST.getClassification(createdGuids.get(TABLE_TYPE).get(i), TestUtilsV2.CLASSIFICATION);
Assert.assertNotNull(result_tag);
- Assert.assertEquals(result_tag, tag);
+ Assert.assertEquals(result_tag.getTypeName(), tag.getTypeName());
}
}
@@ -280,6 +281,10 @@ public class TestEntitiesREST {
Assert.assertNotNull(res.getEntities());
Assert.assertEquals(res.getEntities().size(), 2);
+
+ filterCriteria.setAttributeValue("STRING");
+ res = discoveryREST.searchWithParameters(searchParameters);
+ Assert.assertNull(res.getEntities());
}
@Test(dependsOnMethods = "testWildCardBasicSearch")
@@ -305,6 +310,29 @@ public class TestEntitiesREST {
Assert.assertEquals(res.getEntities().size(), 3);
}
+ @Test(dependsOnMethods = "testTagToMultipleEntities")
+ public void testBasicSearchWithFilter() throws Exception {
+ searchParameters = new SearchParameters();
+ searchParameters.setIncludeSubClassifications(true);
+ searchParameters.setClassification(TestUtilsV2.CLASSIFICATION);
+ SearchParameters.FilterCriteria fc = new SearchParameters.FilterCriteria();
+ fc.setOperator(SearchParameters.Operator.CONTAINS);
+ fc.setAttributeValue("new comments");
+ fc.setAttributeName("tag");
+ searchParameters.setTagFilters(fc);
+
+ AtlasSearchResult res = discoveryREST.searchWithParameters(searchParameters);
+ Assert.assertNull(res.getEntities());
+
+ fc.setOperator(SearchParameters.Operator.ENDS_WITH);
+ res = discoveryREST.searchWithParameters(searchParameters);
+ Assert.assertNull(res.getEntities());
+
+ fc.setOperator(SearchParameters.Operator.STARTS_WITH);
+ res = discoveryREST.searchWithParameters(searchParameters);
+ Assert.assertNull(res.getEntities());
+ }
+
@Test(dependsOnMethods = "testBasicSearchWithSubTypes")
public void testUpdateWithSerializedEntities() throws Exception {
@@ -334,7 +362,7 @@ public class TestEntitiesREST {
Assert.assertEquals(newGuids.size(), 3);
}
- @Test(dependsOnMethods = "testCreateOrUpdateEntities")
+ @Test
public void testGetEntities() throws Exception {
final AtlasEntitiesWithExtInfo response = entityREST.getByGuids(createdGuids.get(DATABASE_TYPE), false, false);