Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
a2ccdf12
Commit
a2ccdf12
authored
Feb 14, 2018
by
Ashutosh Mestry
Committed by
Madhan Neethiraj
Feb 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2447: DSL improvement in handling of select clause
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
3ec37cae
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
6 deletions
+30
-6
GremlinClause.java
...y/src/main/java/org/apache/atlas/query/GremlinClause.java
+2
-2
GremlinQueryComposer.java
...ain/java/org/apache/atlas/query/GremlinQueryComposer.java
+10
-3
DSLQueriesTest.java
.../src/test/java/org/apache/atlas/query/DSLQueriesTest.java
+13
-1
GremlinQueryComposerTest.java
...java/org/apache/atlas/query/GremlinQueryComposerTest.java
+0
-0
AtlasBaseExceptionMapper.java
...org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java
+5
-0
No files found.
repository/src/main/java/org/apache/atlas/query/GremlinClause.java
View file @
a2ccdf12
...
...
@@ -36,11 +36,11 @@ enum GremlinClause {
AND
(
"and(%s)"
),
NESTED_START
(
"__"
),
NESTED_HAS_OPERATOR
(
"has('%s', %s(%s))"
),
LIMIT
(
"limit(
local, %s).limit(
%s)"
),
LIMIT
(
"limit(%s)"
),
ORDER_BY
(
"order().by('%s')"
),
ORDER_BY_DESC
(
"order().by('%s', decr)"
),
OUT
(
"out('%s')"
),
RANGE
(
"range(
local, %s, %s + %s).range(
%s, %s + %s)"
),
RANGE
(
"range(%s, %s + %s)"
),
SELECT
(
"select('%s')"
),
TO_LIST
(
"toList()"
),
TEXT_CONTAINS
(
"has('%s', org.janusgraph.core.attribute.Text.textRegex(%s))"
),
...
...
repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java
View file @
a2ccdf12
...
...
@@ -167,9 +167,7 @@ public class GremlinQueryComposer {
if
(
lhsI
.
isDate
())
{
rhs
=
parseDate
(
rhs
);
}
if
(
lhsI
.
isNumeric
())
{
}
else
if
(
lhsI
.
isNumeric
())
{
rhs
=
parseNumber
(
rhs
);
}
...
...
@@ -492,6 +490,15 @@ public class GremlinQueryComposer {
if
(
isNestedQuery
)
return
;
// Need de-duping at the end so that correct results are fetched
if
(
queryClauses
.
size
()
>
2
)
{
// QueryClauses should've something more that just g.V() (hence 2)
add
(
GremlinClause
.
DEDUP
);
// Range and limit must be present after the de-duping construct
moveToLast
(
GremlinClause
.
RANGE
);
moveToLast
(
GremlinClause
.
LIMIT
);
}
if
(!
queryMetadata
.
hasLimitOffset
())
{
addDefaultLimit
();
}
...
...
repository/src/test/java/org/apache/atlas/query/DSLQueriesTest.java
View file @
a2ccdf12
...
...
@@ -44,6 +44,7 @@ import static org.testng.Assert.assertEquals;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
assertNull
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
import
static
org
.
testng
.
Assert
.
fail
;
@Guice
(
modules
=
TestModules
.
TestOnlyModule
.
class
)
public
class
DSLQueriesTest
extends
BasicTestSetup
{
...
...
@@ -176,7 +177,8 @@ public class DSLQueriesTest extends BasicTestSetup {
{
"Person where (age < 50)"
,
3
},
{
"Person where (age <= 35)"
,
2
},
{
"Person where (age = 35)"
,
0
},
{
"Person where (age != 35)"
,
4
}
{
"Person where (age != 35)"
,
4
},
{
"Person where (approximationOfPi > -3.4028235e+38)"
,
4
},
};
}
...
...
@@ -606,9 +608,19 @@ public class DSLQueriesTest extends BasicTestSetup {
{
"hive_table select owner, columns"
},
// Can't select a mix of immediate attribute and referred entity
{
"hive_table select owner, db.name"
},
// Same as above
{
"hive_order"
},
// From src should be an Entity or Classification
{
"Person where (age > -3.4028235e+38)"
}
// comparing float with BigDecimal
};
}
@Test
public
void
testQuery
()
{
try
{
discoveryService
.
searchUsingDslQuery
(
"hive_table select db"
,
DEFAULT_LIMIT
,
0
);
}
catch
(
AtlasBaseException
e
)
{
fail
(
"Should've been a success"
);
}
}
@Test
(
dataProvider
=
"errorQueriesProvider"
,
expectedExceptions
=
{
AtlasBaseException
.
class
})
public
void
errorQueries
(
String
query
)
throws
AtlasBaseException
{
LOG
.
debug
(
query
);
...
...
repository/src/test/java/org/apache/atlas/query/GremlinQueryComposerTest.java
View file @
a2ccdf12
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java
View file @
a2ccdf12
...
...
@@ -53,6 +53,11 @@ public class AtlasBaseExceptionMapper implements ExceptionMapper<AtlasBaseExcept
AtlasErrorCode
errorCode
=
baseException
.
getAtlasErrorCode
();
errorJsonMap
.
put
(
"errorCode"
,
errorCode
.
getErrorCode
());
errorJsonMap
.
put
(
"errorMessage"
,
baseException
.
getMessage
());
if
(
baseException
.
getCause
()
!=
null
)
{
errorJsonMap
.
put
(
"errorCause"
,
baseException
.
getCause
().
getMessage
());
}
Response
.
ResponseBuilder
responseBuilder
=
Response
.
status
(
errorCode
.
getHttpCode
());
// No body for 204 (and maybe 304)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment