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
c88ea511
Commit
c88ea511
authored
5 years ago
by
Le Ma
Committed by
Sarath Subramanian
5 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3425 gremlin Script Execution Failed Due To Unsupported Functions
Signed-off-by:
Sarath Subramanian
<
sarath@apache.org
>
parent
85a5eeba
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
12 deletions
+50
-12
ClassificationSearchProcessor.java
...apache/atlas/discovery/ClassificationSearchProcessor.java
+3
-3
AtlasGremlin2QueryProvider.java
...ava/org/apache/atlas/util/AtlasGremlin2QueryProvider.java
+9
-9
TestEntitiesREST.java
.../java/org/apache/atlas/web/adapters/TestEntitiesREST.java
+38
-0
No files found.
repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java
View file @
c88ea511
...
...
@@ -188,15 +188,15 @@ public class ClassificationSearchProcessor extends SearchProcessor {
gremlinQueryBindings
=
new
HashMap
<>();
StringBuilder
gremlinQuery
=
new
StringBuilder
();
gremlinQuery
.
append
(
"g.V().has('__guid',
T.in, guids
)"
);
gremlinQuery
.
append
(
"g.V().has('__guid',
within(guids)
)"
);
gremlinQuery
.
append
(
queryProvider
.
getQuery
(
AtlasGremlinQueryProvider
.
AtlasGremlinQuery
.
BASIC_SEARCH_CLASSIFICATION_FILTER
));
gremlinQuery
.
append
(
".as('e').out()"
);
gremlinQuery
.
append
(
".as('e').
filter(
out()"
);
gremlinQuery
.
append
(
queryProvider
.
getQuery
(
AtlasGremlinQueryProvider
.
AtlasGremlinQuery
.
BASIC_SEARCH_TYPE_FILTER
));
constructGremlinFilterQuery
(
gremlinQuery
,
gremlinQueryBindings
,
context
.
getClassificationType
(),
context
.
getSearchParameters
().
getTagFilters
());
// After filtering on tags go back to e and output the list of entity vertices
gremlinQuery
.
append
(
"
.back('e'
).toList()"
);
gremlinQuery
.
append
(
").toList()"
);
gremlinQueryBindings
.
put
(
"traitNames"
,
typeAndSubTypes
);
gremlinQueryBindings
.
put
(
"typeNames"
,
typeAndSubTypes
);
// classification typeName
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/util/AtlasGremlin2QueryProvider.java
View file @
c88ea511
...
...
@@ -57,9 +57,9 @@ public class AtlasGremlin2QueryProvider extends AtlasGremlinQueryProvider {
"path().toList()"
;
case
BASIC_SEARCH_TYPE_FILTER:
return
".has('__typeName',
T.in, typeNames
)"
;
return
".has('__typeName',
within(typeNames)
)"
;
case
BASIC_SEARCH_CLASSIFICATION_FILTER:
return
".or(has('__traitNames',
T.in, traitNames), has('__propagatedTraitNames', T.in, traitNames
))"
;
return
".or(has('__traitNames',
within(traitNames)), has('__propagatedTraitNames', within(traitNames)
))"
;
case
BASIC_SEARCH_STATE_FILTER:
return
".has('__state', state)"
;
case
TO_RANGE_LIST:
...
...
@@ -67,17 +67,17 @@ public class AtlasGremlin2QueryProvider extends AtlasGremlinQueryProvider {
case
GUID_PREFIX_FILTER:
return
".filter{it.'__guid'.matches(guid)}"
;
case
COMPARE_LT:
return
".has('%s',
T.lt, %s
)"
;
return
".has('%s',
lt(%s)
)"
;
case
COMPARE_LTE:
return
".has('%s',
T.lte, %s
)"
;
return
".has('%s',
lte(%s)
)"
;
case
COMPARE_GT:
return
".has('%s',
T.gt, %s
)"
;
return
".has('%s',
gt(%s)
)"
;
case
COMPARE_GTE:
return
".has('%s',
T.gte, %s
)"
;
return
".has('%s',
gte(%s)
)"
;
case
COMPARE_EQ:
return
".has('%s',
T.eq, %s
)"
;
return
".has('%s',
eq(%s)
)"
;
case
COMPARE_NEQ:
return
".has('%s',
T.neq, %s
)"
;
return
".has('%s',
neq(%s)
)"
;
case
COMPARE_MATCHES:
return
".filter({it.getProperty('%s').matches(%s)})"
;
case
COMPARE_STARTS_WITH:
...
...
@@ -91,7 +91,7 @@ public class AtlasGremlin2QueryProvider extends AtlasGremlinQueryProvider {
case
COMPARE_NOT_NULL:
return
".has('%s')"
;
case
RELATIONSHIP_SEARCH:
return
"g.V('__guid', guid).both(relation).has('__state',
T.in, states
)"
;
return
"g.V('__guid', guid).both(relation).has('__state',
within(states)
)"
;
case
RELATIONSHIP_SEARCH_ASCENDING_SORT:
return
".order{it.a.getProperty(sortAttributeName) <=> it.b.getProperty(sortAttributeName)}"
;
case
RELATIONSHIP_SEARCH_DESCENDING_SORT:
...
...
This diff is collapsed.
Click to expand it.
webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
View file @
c88ea511
...
...
@@ -19,6 +19,7 @@ package org.apache.atlas.web.adapters;
import
static
org
.
apache
.
atlas
.
TestUtilsV2
.
COLUMN_TYPE
;
import
static
org
.
apache
.
atlas
.
TestUtilsV2
.
DATABASE_TYPE
;
import
static
org
.
apache
.
atlas
.
TestUtilsV2
.
PHI
;
import
static
org
.
apache
.
atlas
.
TestUtilsV2
.
TABLE_TYPE
;
import
org.apache.atlas.AtlasClient
;
...
...
@@ -56,6 +57,7 @@ import javax.inject.Inject;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -230,6 +232,42 @@ public class TestEntitiesREST {
Assert
.
assertEquals
(
res
.
getEntities
().
size
(),
1
);
}
@Test
(
dependsOnMethods
=
"testBasicSearchAddCls"
)
public
void
testGraphQueryFilter
()
throws
Exception
{
searchParameters
=
new
SearchParameters
();
searchParameters
.
setQuery
(
"sample_string"
);
searchParameters
.
setClassification
(
PHI
);
SearchParameters
.
FilterCriteria
fc
=
new
SearchParameters
.
FilterCriteria
();
fc
.
setOperator
(
SearchParameters
.
Operator
.
EQ
);
fc
.
setAttributeName
(
"booleanAttr"
);
fc
.
setAttributeValue
(
"true"
);
searchParameters
.
setTagFilters
(
fc
);
AtlasSearchResult
res
=
discoveryREST
.
searchWithParameters
(
searchParameters
);
Assert
.
assertNotNull
(
res
.
getEntities
());
Assert
.
assertEquals
(
res
.
getEntities
().
size
(),
1
);
Assert
.
assertEquals
(
res
.
getEntities
().
get
(
0
).
getTypeName
(),
DATABASE_TYPE
);
AtlasClassification
cls
=
new
AtlasClassification
(
TestUtilsV2
.
PHI
,
new
HashMap
<
String
,
Object
>()
{{
put
(
"stringAttr"
,
"sample_string"
);
put
(
"booleanAttr"
,
false
);
put
(
"integerAttr"
,
100
);
}});
ClassificationAssociateRequest
clsAssRequest
=
new
ClassificationAssociateRequest
(
Collections
.
singletonList
(
createdGuids
.
get
(
TABLE_TYPE
).
get
(
0
)),
cls
);
entityREST
.
addClassification
(
clsAssRequest
);
final
AtlasClassification
result_tag
=
entityREST
.
getClassification
(
createdGuids
.
get
(
TABLE_TYPE
).
get
(
0
),
TestUtilsV2
.
PHI
);
Assert
.
assertNotNull
(
result_tag
);
res
=
discoveryREST
.
searchWithParameters
(
searchParameters
);
Assert
.
assertNotNull
(
res
.
getEntities
());
Assert
.
assertEquals
(
res
.
getEntities
().
size
(),
1
);
Assert
.
assertEquals
(
res
.
getEntities
().
get
(
0
).
getTypeName
(),
DATABASE_TYPE
);
}
private
void
addPHICls
()
throws
Exception
{
AtlasClassification
clsPHI
=
new
AtlasClassification
(
TestUtilsV2
.
PHI
,
new
HashMap
<
String
,
Object
>()
{{
put
(
"stringAttr"
,
"string"
);
...
...
This diff is collapsed.
Click to expand it.
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