Commit 8b58a326 by Ashutosh Mestry

ATLAS-3182: Import transforms handling qualifiedName for hive_table entity.

parent 0323ce38
...@@ -43,18 +43,21 @@ public class HiveTableEntityHandler extends BaseEntityHandler { ...@@ -43,18 +43,21 @@ public class HiveTableEntityHandler extends BaseEntityHandler {
} }
private static class HiveTableEntity extends AtlasTransformableEntity { private static class HiveTableEntity extends AtlasTransformableEntity {
private final String qualifiedName;
private String databaseName; private String databaseName;
private String tableName; private String tableName;
private String clusterName; private String clusterName;
private boolean isCustomAttributeUpdated = false; private boolean isCustomAttributeUpdated = false;
private final boolean tableNameFromQualifiedNameDifferent;
private final String tableNameFromQualifiedName;
public HiveTableEntity(AtlasEntity entity) { public HiveTableEntity(AtlasEntity entity) {
super(entity); super(entity);
this.tableName = (String) entity.getAttribute(NAME_ATTRIBUTE); this.tableName = (String) entity.getAttribute(NAME_ATTRIBUTE);
String qualifiedName = (String) entity.getAttribute(QUALIFIED_NAME_ATTRIBUTE); this.qualifiedName = (String) entity.getAttribute(QUALIFIED_NAME_ATTRIBUTE);
if (qualifiedName != null) { if (qualifiedName != null) {
int databaseSeparatorIdx = qualifiedName.indexOf(DATABASE_DELIMITER); int databaseSeparatorIdx = qualifiedName.indexOf(DATABASE_DELIMITER);
...@@ -62,9 +65,13 @@ public class HiveTableEntityHandler extends BaseEntityHandler { ...@@ -62,9 +65,13 @@ public class HiveTableEntityHandler extends BaseEntityHandler {
this.databaseName = databaseSeparatorIdx != -1 ? qualifiedName.substring(0, databaseSeparatorIdx) : ""; this.databaseName = databaseSeparatorIdx != -1 ? qualifiedName.substring(0, databaseSeparatorIdx) : "";
this.clusterName = clusterSeparatorIdx != -1 ? qualifiedName.substring(clusterSeparatorIdx + 1) : ""; this.clusterName = clusterSeparatorIdx != -1 ? qualifiedName.substring(clusterSeparatorIdx + 1) : "";
this.tableNameFromQualifiedName = clusterSeparatorIdx != -1 ? this.qualifiedName.substring(databaseSeparatorIdx + 1, clusterSeparatorIdx) : "";
this.tableNameFromQualifiedNameDifferent = !this.tableNameFromQualifiedName.equals(this.tableName);
} else { } else {
this.databaseName = ""; this.databaseName = "";
this.clusterName = ""; this.clusterName = "";
this.tableNameFromQualifiedName = "";
this.tableNameFromQualifiedNameDifferent = false;
} }
} }
...@@ -121,6 +128,8 @@ public class HiveTableEntityHandler extends BaseEntityHandler { ...@@ -121,6 +128,8 @@ public class HiveTableEntityHandler extends BaseEntityHandler {
private String toQualifiedName() { private String toQualifiedName() {
String tableName = tableNameFromQualifiedNameDifferent ? this.tableNameFromQualifiedName : this.tableName;
return String.format("%s.%s@%s", databaseName, tableName, clusterName); return String.format("%s.%s@%s", databaseName, tableName, clusterName);
} }
} }
......
{
"entity": {
"attributes": {
"aliases": null,
"columns": [],
"comment": null,
"createTime": 1556559566000,
"db": {
"guid": "9ef83dcb-6cca-4e10-a19c-752d64227a94",
"typeName": "hive_db"
},
"description": null,
"lastAccessTime": 1556559566000,
"name": "temptable",
"owner": "hrt_qa",
"parameters": {
"bucketing_version": "2",
"numFiles": "1",
"numRows": "0",
"rawDataSize": "0",
"totalSize": "378890"
},
"partitionKeys": [],
"qualifiedName": "test_partition_bootstrap.temptable_temp-5e93084a-f2d1-46f7-8f8f-30ffb859d2be@mycluster0",
"replicatedFrom": null,
"replicatedTo": [
{
"guid": "2306c3e3-8b92-418e-b788-ade3d82d68db",
"typeName": "AtlasServer"
}
],
"retention": 0,
"tableType": "MANAGED_TABLE",
"temporary": true,
"viewExpandedText": null,
"viewOriginalText": null
},
"createTime": 1556559566442,
"createdBy": "hrt_qa",
"guid": "e2d30fc3-026e-4597-b6a4-c706066bd480",
"status": "ACTIVE",
"typeName": "hive_table",
"updateTime": 1556559585192,
"updatedBy": "hrt_qa",
"version": 0
},
"referredEntities": {}
}
[{"conditions":{"hive_db.clusterName":"EQUALS: mycluster0"},"action":{"hive_db.clusterName":"SET: mycluster1"}},{"conditions":{"hive_db.name":"EQUALS: test_partition_bootstrap"},"action":{"hive_db.name":"SET: test_partition_bootstrap_target"}},{"conditions":{"hive_db.location":"STARTS_WITH_IGNORE_CASE: hdfs://ctr-e139-1542663976389-101273-01-000011.hwx.site:8020"},"action":{"hive_db.location":"REPLACE_PREFIX: = :hdfs://ctr-e139-1542663976389-101273-01-000011.hwx.site:8020=hdfs://ctr-e139-1542663976389-101273-01-000006.hwx.site:8020"}},{"conditions":{"hive_storagedesc.location":"STARTS_WITH_IGNORE_CASE: hdfs://ctr-e139-1542663976389-101273-01-000011.hwx.site:8020"},"action":{"hive_storagedesc.location":"REPLACE_PREFIX: = :hdfs://ctr-e139-1542663976389-101273-01-000011.hwx.site:8020=hdfs://ctr-e139-1542663976389-101273-01-000006.hwx.site:8020"}}]
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment