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
4353aa91
Commit
4353aa91
authored
Jan 05, 2018
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2345: v1 schema API response includes partition keys in addition to columns
parent
3f330194
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
6 deletions
+26
-6
EntityLineageService.java
...java/org/apache/atlas/discovery/EntityLineageService.java
+26
-6
No files found.
repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java
View file @
4353aa91
...
...
@@ -25,6 +25,7 @@ import org.apache.atlas.annotation.GraphTransaction;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.model.instance.AtlasEntityHeader
;
import
org.apache.atlas.model.instance.AtlasObjectId
;
import
org.apache.atlas.model.lineage.AtlasLineageInfo
;
import
org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection
;
import
org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation
;
...
...
@@ -46,6 +47,7 @@ import org.apache.commons.lang.StringUtils;
import
org.springframework.stereotype.Service
;
import
javax.inject.Inject
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
...
...
@@ -58,6 +60,7 @@ import java.util.stream.Collectors;
public
class
EntityLineageService
implements
AtlasLineageService
{
private
static
final
String
INPUT_PROCESS_EDGE
=
"__Process.inputs"
;
private
static
final
String
OUTPUT_PROCESS_EDGE
=
"__Process.outputs"
;
private
static
final
String
COLUMNS
=
"columns"
;
private
final
AtlasGraph
graph
;
private
final
AtlasGremlinQueryProvider
gremlinQueryProvider
;
...
...
@@ -127,22 +130,39 @@ public class EntityLineageService implements AtlasLineageService {
ret
.
setDataType
(
AtlasTypeUtil
.
toClassTypeDefinition
(
hive_column
));
AtlasEntity
.
AtlasEntityWithExtInfo
entityWithExtInfo
=
entityRetriever
.
toAtlasEntityWithExtInfo
(
guid
);
AtlasEntity
entity
=
entityWithExtInfo
.
getEntity
();
Map
<
String
,
AtlasEntity
>
referredEntities
=
entityWithExtInfo
.
getReferredEntities
();
List
<
String
>
columnIds
=
getColumnIds
(
entity
);
if
(
MapUtils
.
isNotEmpty
(
referredEntities
))
{
List
<
Map
<
String
,
Object
>>
rows
=
referredEntities
.
entrySet
()
.
stream
()
.
filter
(
EntityLineageService:
:
isHiveColumn
)
.
map
(
e
->
AtlasTypeUtil
.
toMap
(
e
.
getValue
()))
.
collect
(
Collectors
.
toList
());
.
stream
()
.
filter
(
e
->
isColumn
(
columnIds
,
e
)
)
.
map
(
e
->
AtlasTypeUtil
.
toMap
(
e
.
getValue
()))
.
collect
(
Collectors
.
toList
());
ret
.
setRows
(
rows
);
}
return
ret
;
}
private
static
boolean
isHiveColumn
(
Map
.
Entry
<
String
,
AtlasEntity
>
e
)
{
return
StringUtils
.
equals
(
"hive_column"
,
e
.
getValue
().
getTypeName
());
private
List
<
String
>
getColumnIds
(
AtlasEntity
entity
)
{
List
<
String
>
ret
=
new
ArrayList
<>();
Object
columnObjs
=
entity
.
getAttribute
(
COLUMNS
);
if
(
columnObjs
!=
null
&&
columnObjs
instanceof
List
)
{
for
(
Object
pkObj
:
(
List
)
columnObjs
)
{
if
(
pkObj
instanceof
AtlasObjectId
)
{
ret
.
add
(((
AtlasObjectId
)
pkObj
).
getGuid
());
}
}
}
return
ret
;
}
private
boolean
isColumn
(
List
<
String
>
columnIds
,
Map
.
Entry
<
String
,
AtlasEntity
>
e
)
{
return
columnIds
.
contains
(
e
.
getValue
().
getGuid
());
}
private
AtlasLineageInfo
getLineageInfo
(
String
guid
,
LineageDirection
direction
,
int
depth
)
throws
AtlasBaseException
{
...
...
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