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
5c002517
Commit
5c002517
authored
6 years ago
by
Mandar Ambawane
Committed by
nixonrodrigues
6 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3211 :- Update Hive hook with Relationship Attributes.
Signed-off-by:
nixonrodrigues
<
nixon@apache.org
>
parent
d1262e99
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
30 deletions
+18
-30
AlterTableRename.java
...a/org/apache/atlas/hive/hook/events/AlterTableRename.java
+5
-27
BaseHiveEvent.java
...java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
+0
-0
CreateHiveProcess.java
.../org/apache/atlas/hive/hook/events/CreateHiveProcess.java
+3
-3
AtlasRelatedObjectId.java
...org/apache/atlas/model/instance/AtlasRelatedObjectId.java
+6
-0
AtlasTypeUtil.java
intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
+4
-0
No files found.
addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterTableRename.java
View file @
5c002517
...
...
@@ -129,17 +129,13 @@ public class AlterTableRename extends BaseHiveEvent {
// update qualifiedName for all columns, partitionKeys, storageDesc
String
renamedTableQualifiedName
=
(
String
)
renamedTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_QUALIFIED_NAME
);
renameColumns
((
List
<
AtlasObjectId
>)
oldTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_COLUMNS
),
oldTableEntity
,
renamedTableQualifiedName
,
ret
);
renameColumns
((
List
<
AtlasObjectId
>)
oldTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_PARTITION_KEYS
),
oldTableEntity
,
renamedTableQualifiedName
,
ret
);
renameColumns
((
List
<
AtlasObjectId
>)
oldTableEntity
.
getEntity
().
get
Relationship
Attribute
(
ATTRIBUTE_COLUMNS
),
oldTableEntity
,
renamedTableQualifiedName
,
ret
);
renameColumns
((
List
<
AtlasObjectId
>)
oldTableEntity
.
getEntity
().
get
Relationship
Attribute
(
ATTRIBUTE_PARTITION_KEYS
),
oldTableEntity
,
renamedTableQualifiedName
,
ret
);
renameStorageDesc
(
oldTableEntity
,
renamedTableEntity
,
ret
);
// remove columns, partitionKeys and storageDesc - as they have already been updated above
removeAttribute
(
renamedTableEntity
,
ATTRIBUTE_COLUMNS
);
removeAttribute
(
renamedTableEntity
,
ATTRIBUTE_PARTITION_KEYS
);
removeAttribute
(
renamedTableEntity
,
ATTRIBUTE_STORAGEDESC
);
// set previous name as the alias
renamedTableEntity
.
getEntity
().
setAttribute
(
ATTRIBUTE_ALIASES
,
Collections
.
singletonList
(
oldTable
.
getTableName
()));
renamedTableEntity
.
getEntity
().
setRelationshipAttributes
(
null
);
String
oldTableQualifiedName
=
(
String
)
oldTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_QUALIFIED_NAME
);
AtlasObjectId
oldTableId
=
new
AtlasObjectId
(
oldTableEntity
.
getEntity
().
getTypeName
(),
ATTRIBUTE_QUALIFIED_NAME
,
oldTableQualifiedName
);
...
...
@@ -179,35 +175,17 @@ public class AlterTableRename extends BaseHiveEvent {
AtlasObjectId
oldSdId
=
new
AtlasObjectId
(
oldSd
.
getTypeName
(),
ATTRIBUTE_QUALIFIED_NAME
,
oldSd
.
getAttribute
(
ATTRIBUTE_QUALIFIED_NAME
));
newSd
.
removeAttribute
(
ATTRIBUTE_TABLE
);
newSd
.
setRelationshipAttributes
(
null
);
notifications
.
add
(
new
EntityPartialUpdateRequestV2
(
getUserName
(),
oldSdId
,
new
AtlasEntityWithExtInfo
(
newSd
)));
}
}
private
void
removeAttribute
(
AtlasEntityWithExtInfo
entity
,
String
attributeName
)
{
Object
attributeValue
=
entity
.
getEntity
().
getAttribute
(
attributeName
);
entity
.
getEntity
().
getAttributes
().
remove
(
attributeName
);
if
(
attributeValue
instanceof
AtlasObjectId
)
{
AtlasObjectId
objectId
=
(
AtlasObjectId
)
attributeValue
;
entity
.
removeReferredEntity
(
objectId
.
getGuid
());
}
else
if
(
attributeValue
instanceof
Collection
)
{
for
(
Object
item
:
(
Collection
)
attributeValue
)
if
(
item
instanceof
AtlasObjectId
)
{
AtlasObjectId
objectId
=
(
AtlasObjectId
)
item
;
entity
.
removeReferredEntity
(
objectId
.
getGuid
());
}
}
}
private
AtlasEntity
getStorageDescEntity
(
AtlasEntityWithExtInfo
tableEntity
)
{
AtlasEntity
ret
=
null
;
if
(
tableEntity
!=
null
&&
tableEntity
.
getEntity
()
!=
null
)
{
Object
attrSdId
=
tableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_STORAGEDESC
);
Object
attrSdId
=
tableEntity
.
getEntity
().
get
Relationship
Attribute
(
ATTRIBUTE_STORAGEDESC
);
if
(
attrSdId
instanceof
AtlasObjectId
)
{
ret
=
tableEntity
.
getReferredEntity
(((
AtlasObjectId
)
attrSdId
).
getGuid
());
...
...
This diff is collapsed.
Click to expand it.
addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
View file @
5c002517
This diff is collapsed.
Click to expand it.
addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java
View file @
5c002517
...
...
@@ -207,9 +207,9 @@ public class CreateHiveProcess extends BaseHiveEvent {
columnLineageProcess
.
setAttribute
(
ATTRIBUTE_NAME
,
hiveProcess
.
getAttribute
(
ATTRIBUTE_QUALIFIED_NAME
)
+
":"
+
outputColumn
.
getAttribute
(
ATTRIBUTE_NAME
));
columnLineageProcess
.
setAttribute
(
ATTRIBUTE_QUALIFIED_NAME
,
hiveProcess
.
getAttribute
(
ATTRIBUTE_QUALIFIED_NAME
)
+
":"
+
outputColumn
.
getAttribute
(
ATTRIBUTE_NAME
));
columnLineageProcess
.
set
Attribute
(
ATTRIBUTE_INPUTS
,
getObjectIds
(
inputColumns
));
columnLineageProcess
.
set
Attribute
(
ATTRIBUTE_OUTPUTS
,
Collections
.
singletonList
(
getObjectId
(
outputColumn
)));
columnLineageProcess
.
set
Attribute
(
ATTRIBUTE_QUERY
,
getObjectId
(
hiveProcess
));
columnLineageProcess
.
set
RelationshipAttribute
(
ATTRIBUTE_INPUTS
,
getObjectIdsWithRelationshipType
(
inputColumns
,
BaseHiveEvent
.
RELATIONSHIP_DATASET_PROCESS_INPUTS
));
columnLineageProcess
.
set
RelationshipAttribute
(
ATTRIBUTE_OUTPUTS
,
Collections
.
singletonList
(
getObjectIdWithRelationshipType
(
outputColumn
,
BaseHiveEvent
.
RELATIONSHIP_PROCESS_DATASET_OUTPUTS
)));
columnLineageProcess
.
set
RelationshipAttribute
(
ATTRIBUTE_QUERY
,
getObjectIdWithRelationshipType
(
hiveProcess
,
BaseHiveEvent
.
RELATIONSHIP_HIVE_PROCESS_COLUMN_LINEAGE
));
columnLineageProcess
.
setAttribute
(
ATTRIBUTE_DEPENDENCY_TYPE
,
entry
.
getValue
().
getType
());
columnLineageProcess
.
setAttribute
(
ATTRIBUTE_EXPRESSION
,
entry
.
getValue
().
getExpr
());
...
...
This diff is collapsed.
Click to expand it.
intg/src/main/java/org/apache/atlas/model/instance/AtlasRelatedObjectId.java
View file @
5c002517
...
...
@@ -83,6 +83,12 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable
super
(
other
);
}
public
AtlasRelatedObjectId
(
AtlasObjectId
objId
,
String
relationshipType
)
{
this
(
objId
);
setRelationshipType
(
relationshipType
);
}
public
AtlasRelatedObjectId
(
Map
objIdMap
)
{
super
(
objIdMap
);
...
...
This diff is collapsed.
Click to expand it.
intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
View file @
5c002517
...
...
@@ -414,6 +414,10 @@ public class AtlasTypeUtil {
return
new
AtlasRelatedObjectId
(
getAtlasObjectId
(
entity
));
}
public
static
AtlasRelatedObjectId
toAtlasRelatedObjectId
(
AtlasEntity
entity
,
String
relationshipType
){
return
new
AtlasRelatedObjectId
(
getAtlasObjectId
(
entity
),
relationshipType
);
}
public
static
AtlasRelatedObjectId
toAtlasRelatedObjectId
(
AtlasEntity
entity
,
AtlasTypeRegistry
typeRegistry
)
{
return
new
AtlasRelatedObjectId
(
getAtlasObjectId
(
entity
,
typeRegistry
));
}
...
...
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