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
7 years ago
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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
EntityLineageService.java
...java/org/apache/atlas/discovery/EntityLineageService.java
+23
-3
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;
...
@@ -25,6 +25,7 @@ import org.apache.atlas.annotation.GraphTransaction;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.model.instance.AtlasEntityHeader
;
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
;
import
org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection
;
import
org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection
;
import
org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation
;
import
org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation
;
...
@@ -46,6 +47,7 @@ import org.apache.commons.lang.StringUtils;
...
@@ -46,6 +47,7 @@ import org.apache.commons.lang.StringUtils;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Iterator
;
...
@@ -58,6 +60,7 @@ import java.util.stream.Collectors;
...
@@ -58,6 +60,7 @@ import java.util.stream.Collectors;
public
class
EntityLineageService
implements
AtlasLineageService
{
public
class
EntityLineageService
implements
AtlasLineageService
{
private
static
final
String
INPUT_PROCESS_EDGE
=
"__Process.inputs"
;
private
static
final
String
INPUT_PROCESS_EDGE
=
"__Process.inputs"
;
private
static
final
String
OUTPUT_PROCESS_EDGE
=
"__Process.outputs"
;
private
static
final
String
OUTPUT_PROCESS_EDGE
=
"__Process.outputs"
;
private
static
final
String
COLUMNS
=
"columns"
;
private
final
AtlasGraph
graph
;
private
final
AtlasGraph
graph
;
private
final
AtlasGremlinQueryProvider
gremlinQueryProvider
;
private
final
AtlasGremlinQueryProvider
gremlinQueryProvider
;
...
@@ -127,12 +130,14 @@ public class EntityLineageService implements AtlasLineageService {
...
@@ -127,12 +130,14 @@ public class EntityLineageService implements AtlasLineageService {
ret
.
setDataType
(
AtlasTypeUtil
.
toClassTypeDefinition
(
hive_column
));
ret
.
setDataType
(
AtlasTypeUtil
.
toClassTypeDefinition
(
hive_column
));
AtlasEntity
.
AtlasEntityWithExtInfo
entityWithExtInfo
=
entityRetriever
.
toAtlasEntityWithExtInfo
(
guid
);
AtlasEntity
.
AtlasEntityWithExtInfo
entityWithExtInfo
=
entityRetriever
.
toAtlasEntityWithExtInfo
(
guid
);
AtlasEntity
entity
=
entityWithExtInfo
.
getEntity
();
Map
<
String
,
AtlasEntity
>
referredEntities
=
entityWithExtInfo
.
getReferredEntities
();
Map
<
String
,
AtlasEntity
>
referredEntities
=
entityWithExtInfo
.
getReferredEntities
();
List
<
String
>
columnIds
=
getColumnIds
(
entity
);
if
(
MapUtils
.
isNotEmpty
(
referredEntities
))
{
if
(
MapUtils
.
isNotEmpty
(
referredEntities
))
{
List
<
Map
<
String
,
Object
>>
rows
=
referredEntities
.
entrySet
()
List
<
Map
<
String
,
Object
>>
rows
=
referredEntities
.
entrySet
()
.
stream
()
.
stream
()
.
filter
(
EntityLineageService:
:
isHiveColumn
)
.
filter
(
e
->
isColumn
(
columnIds
,
e
)
)
.
map
(
e
->
AtlasTypeUtil
.
toMap
(
e
.
getValue
()))
.
map
(
e
->
AtlasTypeUtil
.
toMap
(
e
.
getValue
()))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
ret
.
setRows
(
rows
);
ret
.
setRows
(
rows
);
...
@@ -141,8 +146,23 @@ public class EntityLineageService implements AtlasLineageService {
...
@@ -141,8 +146,23 @@ public class EntityLineageService implements AtlasLineageService {
return
ret
;
return
ret
;
}
}
private
static
boolean
isHiveColumn
(
Map
.
Entry
<
String
,
AtlasEntity
>
e
)
{
private
List
<
String
>
getColumnIds
(
AtlasEntity
entity
)
{
return
StringUtils
.
equals
(
"hive_column"
,
e
.
getValue
().
getTypeName
());
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
{
private
AtlasLineageInfo
getLineageInfo
(
String
guid
,
LineageDirection
direction
,
int
depth
)
throws
AtlasBaseException
{
...
...
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