You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sh...@apache.org on 2016/07/07 06:14:46 UTC
[4/4] incubator-atlas git commit: ATLAS-993 If condition in DSL order
by clause is not defined then dsl query fails (guptaneeru via shwethags)
ATLAS-993 If condition in DSL order by clause is not defined then dsl query fails (guptaneeru via shwethags)
Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/b9ce7a11
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/b9ce7a11
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/b9ce7a11
Branch: refs/heads/master
Commit: b9ce7a11162466654ae9d8d5b84c2b592b6bfef8
Parents: ed07049
Author: Shwetha GS <ss...@hortonworks.com>
Authored: Thu Jul 7 10:39:07 2016 +0530
Committer: Shwetha GS <ss...@hortonworks.com>
Committed: Thu Jul 7 10:39:07 2016 +0530
----------------------------------------------------------------------
release-log.txt | 1 +
.../org/apache/atlas/query/GremlinQuery.scala | 4 +--
.../GraphBackedDiscoveryServiceTest.java | 31 ++++++++++----------
3 files changed, 19 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b9ce7a11/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index f97b544..d700596 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
ALL CHANGES:
+ATLAS-993 If condition in DSL order by clause is not defined then dsl query fails (guptaneeru via shwethags)
ATLAS-968 Set group information from UGI for Ldap authentication (nixonrodrigues via shwethags)
ATLAS-584 Integrate CSRF prevention filter (kevalbhatt18 via shwethags)
ATLAS-963 UI: Entity details is not display String array attribute values correctly (kevalbhatt18 via shwethags)
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b9ce7a11/repository/src/main/scala/org/apache/atlas/query/GremlinQuery.scala
----------------------------------------------------------------------
diff --git a/repository/src/main/scala/org/apache/atlas/query/GremlinQuery.scala b/repository/src/main/scala/org/apache/atlas/query/GremlinQuery.scala
index 73981c0..14c42b0 100755
--- a/repository/src/main/scala/org/apache/atlas/query/GremlinQuery.scala
+++ b/repository/src/main/scala/org/apache/atlas/query/GremlinQuery.scala
@@ -331,8 +331,8 @@ class GremlinTranslator(expr: Expression,
asc match {
//builds a closure comparison function based on provided order by clause in DSL. This will be used to sort the results by gremlin order pipe.
//Ordering is case insensitive.
- case false=> orderby = s"order{it.b.getProperty('$odr').toLowerCase() <=> it.a.getProperty('$odr').toLowerCase()}"//descending
- case _ => orderby = s"order{it.a.getProperty('$odr').toLowerCase() <=> it.b.getProperty('$odr').toLowerCase()}"
+ case false=> orderby = s"order{(it.b.getProperty('$odr') !=null ? it.b.getProperty('$odr').toLowerCase(): it.b.getProperty('$odr')) <=> (it.a.getProperty('$odr') != null ? it.a.getProperty('$odr').toLowerCase(): it.a.getProperty('$odr'))}"//descending
+ case _ => orderby = s"order{(it.a.getProperty('$odr') != null ? it.a.getProperty('$odr').toLowerCase(): it.a.getProperty('$odr')) <=> (it.b.getProperty('$odr') !=null ? it.b.getProperty('$odr').toLowerCase(): it.b.getProperty('$odr'))}"
}
s"""${genQuery(child, inSelect)}.$orderby"""
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b9ce7a11/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java b/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java
index 64c8bc7..a911c49 100755
--- a/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java
+++ b/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java
@@ -515,6 +515,9 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest {
{"hive_table where (name = \"sales_fact\" and createTime >= \"2014-12-11T02:35:58.440Z\" ) select name as _col_0, createTime as _col_1 orderby '_col_0' limit 10", 1, "_col_0", isAscending},
{"hive_table where (name = \"sales_fact\" and createTime >= \"2014-12-11T02:35:58.440Z\" ) select name as _col_0, createTime as _col_1 orderby '_col_0' limit 0 offset 1", 0, "_col_0", isAscending},
+
+ //Test if proeprty is not defined. it should not fail the query
+ {"hive_table orderby 'hive_table.owner_notdefined'", 8, null, isAscending},
};
}
@@ -553,24 +556,22 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest {
}
Iterator<String> iter = returnedList.iterator();
String _current = null, _prev = null;
- //Following code compares the results in rows and makes sure data is sorted as expected.
- while(iter.hasNext())
- {
- _prev = _current;
- _current = iter.next().toLowerCase();
- if (_prev != null && _prev.compareTo(_current) != 0)
- {
- if(ascending)
- {
- Assert.assertTrue(_prev.compareTo(_current) < 0);
- }
- else
- {
- Assert.assertTrue(_prev.compareTo(_current) > 0);
+ if (orderBy != null) {
+ // Following code compares the results in rows and makes sure data
+ // is sorted as expected
+ while (iter.hasNext()) {
+ _prev = _current;
+ _current = iter.next().toLowerCase();
+ if (_prev != null && _prev.compareTo(_current) != 0) {
+ if (ascending) {
+ Assert.assertTrue(_prev.compareTo(_current) < 0);
+ } else {
+ Assert.assertTrue(_prev.compareTo(_current) > 0);
+ }
}
}
}
-
+
System.out.println("query [" + dslQuery + "] returned [" + rows.length() + "] rows");
}