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
a22495b9
Commit
a22495b9
authored
Oct 23, 2020
by
Jayendra Parab
Committed by
nixonrodrigues
Oct 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-4005 : DSL search gives error if select clause contains attributes with null values.
Signed-off-by:
nixonrodrigues
<
nixon@apache.org
>
parent
8f5ba447
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
24 deletions
+10
-24
GremlinClause.java
...y/src/main/java/org/apache/atlas/query/GremlinClause.java
+1
-1
GremlinQueryComposer.java
...ain/java/org/apache/atlas/query/GremlinQueryComposer.java
+5
-22
SelectClauseComposer.java
...ain/java/org/apache/atlas/query/SelectClauseComposer.java
+1
-1
DSLQueriesTest.java
.../src/test/java/org/apache/atlas/query/DSLQueriesTest.java
+3
-0
GremlinQueryComposerTest.java
...java/org/apache/atlas/query/GremlinQueryComposerTest.java
+0
-0
No files found.
repository/src/main/java/org/apache/atlas/query/GremlinClause.java
View file @
a22495b9
...
...
@@ -62,7 +62,7 @@ enum GremlinClause {
INLINE_SUM
(
"r.sum({it.value('%s')})"
),
INLINE_MAX
(
"r.max({it.value('%s')}).value('%s')"
),
INLINE_MIN
(
"r.min({it.value('%s')}).value('%s')"
),
INLINE_GET_PROPERTY
(
"it.
value('%s')
"
),
INLINE_GET_PROPERTY
(
"it.
property('%s').isPresent() ? it.value('%s') : \"\"
"
),
INLINE_TRANSFORM_CALL
(
"f(%s)"
),
INLINE_DEFAULT_SORT
(
".sort()"
),
INLINE_SORT_DESC
(
".sort{a,b -> b <=> a}"
),
...
...
repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java
View file @
a22495b9
...
...
@@ -253,10 +253,6 @@ public class GremlinQueryComposer {
public
void
addSelect
(
SelectClauseComposer
selectClauseComposer
)
{
process
(
selectClauseComposer
);
if
(
CollectionUtils
.
isEmpty
(
context
.
getErrorList
()))
{
addSelectAttrExistsCheck
(
selectClauseComposer
);
}
// If the query contains orderBy and groupBy then the transformation determination is deferred to the method processing orderBy
if
(!(
queryMetadata
.
hasOrderBy
()
&&
queryMetadata
.
hasGroupBy
()))
{
addSelectTransformation
(
selectClauseComposer
,
null
,
false
);
...
...
@@ -382,24 +378,6 @@ public class GremlinQueryComposer {
return
ia
.
getRaw
();
}
private
void
addSelectAttrExistsCheck
(
final
SelectClauseComposer
selectClauseComposer
)
{
// For each of the select attributes we need to add a presence check as well, if there's no explicit where for the same
// NOTE: One side-effect is that the result table will be empty if any of the attributes is null or empty for the type
String
[]
qualifiedAttributes
=
selectClauseComposer
.
getAttributes
();
if
(
qualifiedAttributes
!=
null
&&
qualifiedAttributes
.
length
>
0
)
{
for
(
int
i
=
0
;
i
<
qualifiedAttributes
.
length
;
i
++)
{
String
qualifiedAttribute
=
qualifiedAttributes
[
i
];
IdentifierHelper
.
Info
idMetadata
=
createInfo
(
qualifiedAttribute
);
// Only primitive attributes need to be checked
if
(
idMetadata
.
isPrimitive
()
&&
!
selectClauseComposer
.
isAggregatorIdx
(
i
)
&&
!
attributesProcessed
.
contains
(
qualifiedAttribute
))
{
add
(
GremlinClause
.
HAS_PROPERTY
,
getPropertyForClause
(
idMetadata
));
}
}
// All these checks should be done before the grouping happens (if any)
moveToLast
(
GremlinClause
.
GROUP_BY
);
}
}
private
void
process
(
SelectClauseComposer
scc
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"addSelect(items.length={})"
,
scc
.
getItems
()
!=
null
?
scc
.
getItems
().
length
:
0
);
...
...
@@ -412,6 +390,11 @@ public class GremlinQueryComposer {
for
(
int
i
=
0
;
i
<
scc
.
getItems
().
length
;
i
++)
{
IdentifierHelper
.
Info
ia
=
createInfo
(
scc
.
getItem
(
i
));
if
(
StringUtils
.
isEmpty
(
ia
.
getQualifiedName
()))
{
context
.
getErrorList
().
add
(
"Unable to find qualified name for "
+
ia
.
getAttributeName
());
continue
;
}
if
(
scc
.
isAggregatorWithArgument
(
i
)
&&
!
ia
.
isPrimitive
())
{
context
.
check
(
false
,
AtlasErrorCode
.
INVALID_DSL_SELECT_INVALID_AGG
,
ia
.
getQualifiedName
());
return
;
...
...
repository/src/main/java/org/apache/atlas/query/SelectClauseComposer.java
View file @
a22495b9
...
...
@@ -87,7 +87,7 @@ class SelectClauseComposer {
}
public
boolean
assign
(
int
i
,
String
qualifiedName
,
GremlinClause
clause
)
{
items
[
i
]
=
clause
.
get
(
qualifiedName
);
items
[
i
]
=
clause
.
get
(
qualifiedName
,
qualifiedName
);
return
true
;
}
...
...
repository/src/test/java/org/apache/atlas/query/DSLQueriesTest.java
View file @
a22495b9
...
...
@@ -216,8 +216,11 @@ public class DSLQueriesTest extends BasicTestSetup {
{
"hive_column where hive_column isa PII"
,
4
},
{
"hive_column where hive_column isa PII select hive_column.qualifiedName"
,
4
},
{
"hive_column select hive_column.qualifiedName"
,
17
},
{
"hive_column select hive_column.qualifiedName, hive_column.description"
,
17
},
{
"hive_column select qualifiedName"
,
17
},
{
"hive_column select qualifiedName, description"
,
17
},
{
"hive_column where hive_column.name=\"customer_id\""
,
2
},
{
"hive_column where hive_column.name=\"customer_id\" select qualifiedName, description"
,
2
},
{
"from hive_table select hive_table.qualifiedName"
,
10
},
{
"hive_db where (name = \"Reporting\")"
,
1
},
{
"hive_db where (name = \"Reporting\") select name as _col_0, owner as _col_1"
,
1
},
...
...
repository/src/test/java/org/apache/atlas/query/GremlinQueryComposerTest.java
View file @
a22495b9
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