Commit b9ce7a11 by Shwetha GS

ATLAS-993 If condition in DSL order by clause is not defined then dsl query…

ATLAS-993 If condition in DSL order by clause is not defined then dsl query fails (guptaneeru via shwethags)
parent ed07049a
...@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES: ...@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
ALL 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-968 Set group information from UGI for Ldap authentication (nixonrodrigues via shwethags)
ATLAS-584 Integrate CSRF prevention filter (kevalbhatt18 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) ATLAS-963 UI: Entity details is not display String array attribute values correctly (kevalbhatt18 via shwethags)
......
...@@ -331,8 +331,8 @@ class GremlinTranslator(expr: Expression, ...@@ -331,8 +331,8 @@ class GremlinTranslator(expr: Expression,
asc match { 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. //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. //Ordering is case insensitive.
case false=> orderby = s"order{it.b.getProperty('$odr').toLowerCase() <=> it.a.getProperty('$odr').toLowerCase()}"//descending 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').toLowerCase() <=> it.b.getProperty('$odr').toLowerCase()}" 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""" s"""${genQuery(child, inSelect)}.$orderby"""
......
...@@ -515,6 +515,9 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest { ...@@ -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 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}, {"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 { ...@@ -553,24 +556,22 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest {
} }
Iterator<String> iter = returnedList.iterator(); Iterator<String> iter = returnedList.iterator();
String _current = null, _prev = null; String _current = null, _prev = null;
//Following code compares the results in rows and makes sure data is sorted as expected. if (orderBy != null) {
while(iter.hasNext()) // Following code compares the results in rows and makes sure data
{ // is sorted as expected
_prev = _current; while (iter.hasNext()) {
_current = iter.next().toLowerCase(); _prev = _current;
if (_prev != null && _prev.compareTo(_current) != 0) _current = iter.next().toLowerCase();
{ if (_prev != null && _prev.compareTo(_current) != 0) {
if(ascending) if (ascending) {
{ Assert.assertTrue(_prev.compareTo(_current) < 0);
Assert.assertTrue(_prev.compareTo(_current) < 0); } else {
} Assert.assertTrue(_prev.compareTo(_current) > 0);
else }
{
Assert.assertTrue(_prev.compareTo(_current) > 0);
} }
} }
} }
System.out.println("query [" + dslQuery + "] returned [" + rows.length() + "] rows"); System.out.println("query [" + dslQuery + "] returned [" + rows.length() + "] rows");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment