You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2021/01/24 01:13:02 UTC
[atlas] branch master updated: ATLAS-4110: updated handling of neq
operator for recent changes in JanusGraph
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push:
new c48e4c3 ATLAS-4110: updated handling of neq operator for recent changes in JanusGraph
c48e4c3 is described below
commit c48e4c393b747b25f1c399a2c37175e5004d1526
Author: Deep Singh <de...@gmail.com>
AuthorDate: Thu Jan 21 17:14:12 2021 -0600
ATLAS-4110: updated handling of neq operator for recent changes in JanusGraph
Signed-off-by: Madhan Neethiraj <ma...@apache.org>
---
repository/src/main/java/org/apache/atlas/query/GremlinClause.java | 1 +
.../src/main/java/org/apache/atlas/query/GremlinQueryComposer.java | 4 ++++
.../test/java/org/apache/atlas/query/GremlinQueryComposerTest.java | 6 ++++++
3 files changed, 11 insertions(+)
diff --git a/repository/src/main/java/org/apache/atlas/query/GremlinClause.java b/repository/src/main/java/org/apache/atlas/query/GremlinClause.java
index 7a98ddd..b7e5330 100644
--- a/repository/src/main/java/org/apache/atlas/query/GremlinClause.java
+++ b/repository/src/main/java/org/apache/atlas/query/GremlinClause.java
@@ -25,6 +25,7 @@ public enum GremlinClause {
GROUP_BY("group().by('%s')"),
HAS("has('%s', %s)"),
HAS_OPERATOR("has('%s', %s(%s))"),
+ HAS_NOT_OPERATOR("or(__.has('%s', neq(%s)), __.hasNot('%s'))"),
HAS_PROPERTY("has('%s')"),
WHERE("where(%s)"),
HAS_NOT_PROPERTY("hasNot('%s')"),
diff --git a/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java b/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java
index c5c53fc..c7d01cf 100644
--- a/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java
+++ b/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java
@@ -219,6 +219,10 @@ public class GremlinQueryComposer {
}
} else if (op == SearchParameters.Operator.IN) {
add(GremlinClause.HAS_OPERATOR, getPropertyForClause(lhsI), "within", rhs);
+ } else if (op == SearchParameters.Operator.NEQ) {
+ String propertyName = getPropertyForClause(lhsI);
+
+ add(GremlinClause.HAS_NOT_OPERATOR, propertyName, rhs, propertyName);
} else {
Object normalizedRhs = getNormalizedAttrVal(lhsI, IdentifierHelper.removeQuotes(rhs));
diff --git a/repository/src/test/java/org/apache/atlas/query/GremlinQueryComposerTest.java b/repository/src/test/java/org/apache/atlas/query/GremlinQueryComposerTest.java
index 96e2840..0e8af18 100644
--- a/repository/src/test/java/org/apache/atlas/query/GremlinQueryComposerTest.java
+++ b/repository/src/test/java/org/apache/atlas/query/GremlinQueryComposerTest.java
@@ -385,6 +385,12 @@ public class GremlinQueryComposerTest {
}
@Test
+ public void whereClauseWithNEQCondition() {
+ verify("Table where owner != 'random'",
+ "g.V().has('__typeName', 'Table').or(__.has('Table.owner', neq('random')), __.hasNot('Table.owner')).dedup().limit(25).toList()");
+ }
+
+ @Test
public void invalidQueries() {
verify("hdfs_path like h1", "");
}