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
b8af8c90
Commit
b8af8c90
authored
Aug 12, 2019
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3369: Renaming an hive_table creates a new table and updates the existing table
parent
ae4305d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
AlterTableRename.java
...a/org/apache/atlas/hive/hook/events/AlterTableRename.java
+9
-9
No files found.
addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterTableRename.java
View file @
b8af8c90
...
@@ -36,10 +36,7 @@ import org.apache.hadoop.hive.ql.metadata.Table;
...
@@ -36,10 +36,7 @@ import org.apache.hadoop.hive.ql.metadata.Table;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
public
class
AlterTableRename
extends
BaseHiveEvent
{
public
class
AlterTableRename
extends
BaseHiveEvent
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AlterTableRename
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AlterTableRename
.
class
);
...
@@ -123,9 +120,6 @@ public class AlterTableRename extends BaseHiveEvent {
...
@@ -123,9 +120,6 @@ public class AlterTableRename extends BaseHiveEvent {
return
;
return
;
}
}
// 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
)));
// update qualifiedName for all columns, partitionKeys, storageDesc
// update qualifiedName for all columns, partitionKeys, storageDesc
String
renamedTableQualifiedName
=
(
String
)
renamedTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_QUALIFIED_NAME
);
String
renamedTableQualifiedName
=
(
String
)
renamedTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_QUALIFIED_NAME
);
...
@@ -135,13 +129,19 @@ public class AlterTableRename extends BaseHiveEvent {
...
@@ -135,13 +129,19 @@ public class AlterTableRename extends BaseHiveEvent {
// set previous name as the alias
// set previous name as the alias
renamedTableEntity
.
getEntity
().
setAttribute
(
ATTRIBUTE_ALIASES
,
Collections
.
singletonList
(
oldTable
.
getTableName
()));
renamedTableEntity
.
getEntity
().
setAttribute
(
ATTRIBUTE_ALIASES
,
Collections
.
singletonList
(
oldTable
.
getTableName
()));
renamedTableEntity
.
getEntity
().
setRelationshipAttributes
(
null
);
// make a copy of renamedTableEntity to send as partial-update with no relationship attributes
AtlasEntity
renamedTableEntityForPartialUpdate
=
new
AtlasEntity
(
renamedTableEntity
.
getEntity
());
renamedTableEntityForPartialUpdate
.
setRelationshipAttributes
(
null
);
String
oldTableQualifiedName
=
(
String
)
oldTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_QUALIFIED_NAME
);
String
oldTableQualifiedName
=
(
String
)
oldTableEntity
.
getEntity
().
getAttribute
(
ATTRIBUTE_QUALIFIED_NAME
);
AtlasObjectId
oldTableId
=
new
AtlasObjectId
(
oldTableEntity
.
getEntity
().
getTypeName
(),
ATTRIBUTE_QUALIFIED_NAME
,
oldTableQualifiedName
);
AtlasObjectId
oldTableId
=
new
AtlasObjectId
(
oldTableEntity
.
getEntity
().
getTypeName
(),
ATTRIBUTE_QUALIFIED_NAME
,
oldTableQualifiedName
);
// update qualifiedName and other attributes (like params - which include lastModifiedTime, lastModifiedBy) of the table
// update qualifiedName and other attributes (like params - which include lastModifiedTime, lastModifiedBy) of the table
ret
.
add
(
new
EntityPartialUpdateRequestV2
(
getUserName
(),
oldTableId
,
renamedTableEntity
));
ret
.
add
(
new
EntityPartialUpdateRequestV2
(
getUserName
(),
oldTableId
,
new
AtlasEntityWithExtInfo
(
renamedTableEntityForPartialUpdate
)));
// to handle cases where Atlas didn't have the oldTable, send a full update
ret
.
add
(
new
EntityUpdateRequestV2
(
getUserName
(),
new
AtlasEntitiesWithExtInfo
(
renamedTableEntity
)));
// partial update relationship attribute ddl
// partial update relationship attribute ddl
if
(!
context
.
isMetastoreHook
())
{
if
(!
context
.
isMetastoreHook
())
{
...
...
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