You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sa...@apache.org on 2019/08/13 06:28:38 UTC
[atlas] branch branch-2.0 updated: ATLAS-3369: Renaming an
hive_table creates a new table and updates the existing table
This is an automated email from the ASF dual-hosted git repository.
sarath pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 249d1fc ATLAS-3369: Renaming an hive_table creates a new table and updates the existing table
249d1fc is described below
commit 249d1fc939dee1df459ee89e990e9bde049f0dcf
Author: Sarath Subramanian <sa...@apache.org>
AuthorDate: Mon Aug 12 23:21:15 2019 -0700
ATLAS-3369: Renaming an hive_table creates a new table and updates the existing table
(cherry picked from commit b8af8c90abe96e5921f0c54ac383a0cb448b1426)
---
.../atlas/hive/hook/events/AlterTableRename.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterTableRename.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterTableRename.java
index c59ff7f..f496b78 100644
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterTableRename.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterTableRename.java
@@ -36,10 +36,7 @@ import org.apache.hadoop.hive.ql.metadata.Table;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
public class AlterTableRename extends BaseHiveEvent {
private static final Logger LOG = LoggerFactory.getLogger(AlterTableRename.class);
@@ -123,9 +120,6 @@ public class AlterTableRename extends BaseHiveEvent {
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
String renamedTableQualifiedName = (String) renamedTableEntity.getEntity().getAttribute(ATTRIBUTE_QUALIFIED_NAME);
@@ -135,13 +129,19 @@ public class AlterTableRename extends BaseHiveEvent {
// set previous name as the alias
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);
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
- 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
if (!context.isMetastoreHook()) {