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
6c49542b
Commit
6c49542b
authored
Apr 17, 2018
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2581: V2 Hive hook notifications - incorrect location for sd after moving…
ATLAS-2581: V2 Hive hook notifications - incorrect location for sd after moving table to a different database
parent
cabc1e55
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
20 deletions
+35
-20
AlterTableRename.java
...a/org/apache/atlas/hive/hook/events/AlterTableRename.java
+34
-19
AtlasGremlin3QueryProvider.java
...ava/org/apache/atlas/util/AtlasGremlin3QueryProvider.java
+1
-1
No files found.
addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterTableRename.java
View file @
6c49542b
...
...
@@ -72,6 +72,8 @@ public class AlterTableRename extends BaseHiveEvent {
continue
;
}
newTable
=
getHive
().
getTable
(
newTable
.
getDbName
(),
newTable
.
getTableName
());
break
;
}
}
...
...
@@ -88,27 +90,27 @@ public class AlterTableRename extends BaseHiveEvent {
// first update with oldTable info, so that the table will be created if it is not present in Atlas
ret
.
add
(
new
EntityUpdateRequestV2
(
getUserName
(),
new
AtlasEntitiesWithExtInfo
(
oldTableEntity
)));
AtlasEntityWithExtInfo
renamedTableEntity
=
toTableEntity
(
newTable
);
// update qualifiedName for all columns, partitionKeys, storageDesc
String
newTableQualifiedName
=
getQualifiedName
(
newTable
);
String
renamedTableQualifiedName
=
(
String
)
renamedTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_QUALIFIED_NAME
);
renameColumns
((
List
<
AtlasObjectId
>)
oldTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_COLUMNS
),
oldTableEntity
,
new
TableQualifiedName
,
ret
);
renameColumns
((
List
<
AtlasObjectId
>)
oldTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_PARTITION_KEYS
),
oldTableEntity
,
new
TableQualifiedName
,
ret
);
renameStorageDesc
(
(
AtlasObjectId
)
oldTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_STORAGEDESC
),
oldTableEntity
,
newTableQualifiedName
,
ret
);
renameColumns
((
List
<
AtlasObjectId
>)
oldTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_COLUMNS
),
oldTableEntity
,
renamed
TableQualifiedName
,
ret
);
renameColumns
((
List
<
AtlasObjectId
>)
oldTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_PARTITION_KEYS
),
oldTableEntity
,
renamed
TableQualifiedName
,
ret
);
renameStorageDesc
(
oldTableEntity
,
renamedTableEntity
,
ret
);
// update qualifiedName and other attributes (like params - which include lastModifiedTime, lastModifiedBy) of the table
AtlasEntityWithExtInfo
newTableEntity
=
toTableEntity
(
newTable
);
// 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
newTableEntity
.
getEntity
().
setAttribute
(
ATTRIBUTE_ALIASES
,
Collections
.
singletonList
(
oldTable
.
getTableName
()));
// remove columns, partitionKeys and storageDesc - as they have already been updated above
removeAttribute
(
newTableEntity
,
ATTRIBUTE_COLUMNS
);
removeAttribute
(
newTableEntity
,
ATTRIBUTE_PARTITION_KEYS
);
removeAttribute
(
newTableEntity
,
ATTRIBUTE_STORAGEDESC
);
renamedTableEntity
.
getEntity
().
setAttribute
(
ATTRIBUTE_ALIASES
,
Collections
.
singletonList
(
oldTable
.
getTableName
()));
AtlasObjectId
oldTableId
=
new
AtlasObjectId
(
oldTableEntity
.
getEntity
().
getTypeName
(),
ATTRIBUTE_QUALIFIED_NAME
,
oldTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_QUALIFIED_NAME
));
ret
.
add
(
new
EntityPartialUpdateRequestV2
(
getUserName
(),
oldTableId
,
newTableEntity
));
// update qualifiedName and other attributes (like params - which include lastModifiedTime, lastModifiedBy) of the table
ret
.
add
(
new
EntityPartialUpdateRequestV2
(
getUserName
(),
oldTableId
,
renamedTableEntity
));
context
.
removeFromKnownTable
((
String
)
oldTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_QUALIFIED_NAME
));
...
...
@@ -127,11 +129,14 @@ public class AlterTableRename extends BaseHiveEvent {
}
}
private
void
renameStorageDesc
(
AtlasObjectId
sdId
,
AtlasEntityExtInfo
oldEntityExtInfo
,
String
newTableQualifiedName
,
List
<
HookNotification
>
notifications
)
{
if
(
sdId
!=
null
)
{
AtlasEntity
oldSd
=
oldEntityExtInfo
.
getEntity
(
sdId
.
getGuid
());
private
void
renameStorageDesc
(
AtlasEntityWithExtInfo
oldEntityExtInfo
,
AtlasEntityWithExtInfo
newEntityExtInfo
,
List
<
HookNotification
>
notifications
)
{
AtlasEntity
oldSd
=
getStorageDescEntity
(
oldEntityExtInfo
);
AtlasEntity
newSd
=
getStorageDescEntity
(
newEntityExtInfo
);
if
(
oldSd
!=
null
&&
newSd
!=
null
)
{
AtlasObjectId
oldSdId
=
new
AtlasObjectId
(
oldSd
.
getTypeName
(),
ATTRIBUTE_QUALIFIED_NAME
,
oldSd
.
getAttribute
(
ATTRIBUTE_QUALIFIED_NAME
));
AtlasEntity
newSd
=
new
AtlasEntity
(
oldSd
.
getTypeName
(),
ATTRIBUTE_QUALIFIED_NAME
,
getStorageDescQualifiedName
(
newTableQualifiedName
));
newSd
.
removeAttribute
(
ATTRIBUTE_TABLE
);
notifications
.
add
(
new
EntityPartialUpdateRequestV2
(
getUserName
(),
oldSdId
,
new
AtlasEntityWithExtInfo
(
newSd
)));
}
...
...
@@ -156,7 +161,17 @@ public class AlterTableRename extends BaseHiveEvent {
}
}
private
String
getStorageDescQualifiedName
(
String
tblQualifiedName
)
{
return
tblQualifiedName
+
"_storage"
;
private
AtlasEntity
getStorageDescEntity
(
AtlasEntityWithExtInfo
tableEntity
)
{
AtlasEntity
ret
=
null
;
if
(
tableEntity
!=
null
&&
tableEntity
.
getEntity
()
!=
null
)
{
Object
attrSdId
=
tableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_STORAGEDESC
);
if
(
attrSdId
instanceof
AtlasObjectId
)
{
ret
=
tableEntity
.
getReferredEntity
(((
AtlasObjectId
)
attrSdId
).
getGuid
());
}
}
return
ret
;
}
}
repository/src/main/java/org/apache/atlas/util/AtlasGremlin3QueryProvider.java
View file @
6c49542b
...
...
@@ -52,7 +52,7 @@ public class AtlasGremlin3QueryProvider extends AtlasGremlin2QueryProvider {
case
TO_RANGE_LIST:
return
".range(startIdx, endIdx).toList()"
;
case
RELATIONSHIP_SEARCH:
return
"g.V().has('__guid', guid).both
(relation
).has('__state', within(states))"
;
return
"g.V().has('__guid', guid).both
E(relation).has('__state', within(states)).otherV(
).has('__state', within(states))"
;
case
RELATIONSHIP_SEARCH_ASCENDING_SORT:
return
".order().by(sortAttributeName, incr)"
;
case
RELATIONSHIP_SEARCH_DESCENDING_SORT:
...
...
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