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
384c3358
Commit
384c3358
authored
Jan 12, 2017
by
Madhan Neethiraj
Committed by
Vimal Sharma
Jan 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Atlas changes to support Hive hook for Hive2
parent
cc503701
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
7 deletions
+47
-7
ColumnLineageUtils.java
...java/org/apache/atlas/hive/bridge/ColumnLineageUtils.java
+47
-7
No files found.
addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/ColumnLineageUtils.java
View file @
384c3358
...
...
@@ -25,7 +25,10 @@ import org.apache.hadoop.hive.ql.hooks.LineageInfo;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -62,18 +65,55 @@ public class ColumnLineageUtils {
for
(
Map
.
Entry
<
LineageInfo
.
DependencyKey
,
LineageInfo
.
Dependency
>
e
:
lInfo
.
entrySet
())
{
List
<
HiveColumnLineageInfo
>
l
=
new
ArrayList
<>();
String
k
=
getQualifiedName
(
e
.
getKey
());
for
(
LineageInfo
.
BaseColumnInfo
iCol
:
e
.
getValue
().
getBaseCols
())
{
String
db
=
iCol
.
getTabAlias
().
getTable
().
getDbName
();
String
table
=
iCol
.
getTabAlias
().
getTable
().
getTableName
();
String
colQualifiedName
=
iCol
.
getColumn
()
==
null
?
db
+
"."
+
table
:
db
+
"."
+
table
+
"."
+
iCol
.
getColumn
().
getName
();
l
.
add
(
new
HiveColumnLineageInfo
(
e
.
getValue
(),
colQualifiedName
));
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"buildLineageMap(): key={}; value={}"
,
e
.
getKey
(),
e
.
getValue
());
}
Collection
<
LineageInfo
.
BaseColumnInfo
>
baseCols
=
getBaseCols
(
e
.
getValue
());
if
(
baseCols
!=
null
)
{
for
(
LineageInfo
.
BaseColumnInfo
iCol
:
baseCols
)
{
String
db
=
iCol
.
getTabAlias
().
getTable
().
getDbName
();
String
table
=
iCol
.
getTabAlias
().
getTable
().
getTableName
();
String
colQualifiedName
=
iCol
.
getColumn
()
==
null
?
db
+
"."
+
table
:
db
+
"."
+
table
+
"."
+
iCol
.
getColumn
().
getName
();
l
.
add
(
new
HiveColumnLineageInfo
(
e
.
getValue
(),
colQualifiedName
));
}
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Setting lineage --> Input: {} ==> Output : {}"
,
l
,
k
);
}
m
.
put
(
k
,
l
);
}
LOG
.
debug
(
"Setting lineage --> Input: {} ==> Output : {}"
,
l
,
k
);
m
.
put
(
k
,
l
);
}
return
m
;
}
static
Collection
<
LineageInfo
.
BaseColumnInfo
>
getBaseCols
(
LineageInfo
.
Dependency
lInfoDep
)
{
Collection
<
LineageInfo
.
BaseColumnInfo
>
ret
=
null
;
if
(
lInfoDep
!=
null
)
{
try
{
Method
getBaseColsMethod
=
lInfoDep
.
getClass
().
getMethod
(
"getBaseCols"
);
Object
retGetBaseCols
=
getBaseColsMethod
.
invoke
(
lInfoDep
);
if
(
retGetBaseCols
!=
null
)
{
if
(
retGetBaseCols
instanceof
Collection
)
{
ret
=
(
Collection
)
retGetBaseCols
;
}
else
{
LOG
.
warn
(
"{}: unexpected return type from LineageInfo.Dependency.getBaseCols(), expected type {}"
,
retGetBaseCols
.
getClass
().
getName
(),
"Collection"
);
}
}
}
catch
(
NoSuchMethodException
|
InvocationTargetException
|
IllegalAccessException
ex
)
{
LOG
.
warn
(
"getBaseCols()"
,
ex
);
}
}
return
ret
;
}
static
String
[]
extractComponents
(
String
qualifiedName
)
{
String
[]
comps
=
qualifiedName
.
split
(
"\\."
);
int
lastIdx
=
comps
.
length
-
1
;
...
...
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