Commit daf812aa by Suma Shivaprasad

ATLAS-594 alter table rename doesnt work across databases ( sumasai via shwethags)

parent f7146ede
......@@ -406,10 +406,9 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
for (WriteEntity writeEntity : event.getOutputs()) {
if (writeEntity.getType() == Entity.Type.TABLE) {
Table newTable = writeEntity.getTable();
if (newTable.getDbName().equals(oldTable.getDbName()) && !newTable.getTableName()
.equals(oldTable.getTableName())) {
//Create/update old table entity - create new entity and replace id
//Hive sends with both old and new table names in the outputs which is weird. So skipping that with the below check
if (!newTable.getDbName().equals(oldTable.getDbName()) || !newTable.getTableName().equals(oldTable.getTableName())) {
//Create/update old table entity - create new entity with oldQFNme and tableName
Referenceable tableEntity = createOrUpdateEntities(dgiBridge, event.getUser(), writeEntity);
String oldQualifiedName = dgiBridge.getTableQualifiedName(dgiBridge.getClusterName(),
oldTable.getDbName(), oldTable.getTableName());
......@@ -419,6 +418,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
String newQualifiedName = dgiBridge.getTableQualifiedName(dgiBridge.getClusterName(),
newTable.getDbName(), newTable.getTableName());
//Replace entity with new name
Referenceable newEntity = new Referenceable(HiveDataTypes.HIVE_TABLE.getName());
newEntity.set(HiveDataModelGenerator.NAME, newQualifiedName);
newEntity.set(HiveDataModelGenerator.TABLE_NAME, newTable.getTableName().toLowerCase());
......
......@@ -557,11 +557,15 @@ public class HiveHookIT {
@Test
public void testAlterTableRename() throws Exception {
String tableName = createTable();
String newName = tableName();
String query = "alter table " + tableName + " rename to " + newName;
final String newDBName = createDatabase();
assertTableIsRegistered(DEFAULT_DB, tableName);
assertDatabaseIsRegistered(newDBName);
String newTableName = tableName();
String query = String.format("alter table %s rename to %s", DEFAULT_DB + "." + tableName, newDBName + "." + newTableName);
runCommand(query);
assertTableIsRegistered(DEFAULT_DB, newName);
assertTableIsRegistered(newDBName, newTableName);
assertTableIsNotRegistered(DEFAULT_DB, tableName);
}
......
......@@ -15,6 +15,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset
ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags)
ALL CHANGES:
ATLAS-594 alter table rename doesnt work across databases (sumasai via shwethags)
ATLAS-586 While updating the multiple attributes, Atlas returns the response with escape characters (dkantor via shwethags)
ATLAS-582 Move Atlas UI to use backboneJS (kevalbhatt18 via shwethags)
ATLAS-540 API to retrieve entity version events (shwethags)
......
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