Commit 4e1eeb4c by Yu-Hsin Shih Committed by Sarath Subramanian

ATLAS-3198: Stop pushing message to ATLAS_HOOK for Truncate Table/Delete data/Update data

Both ATLAS_HOOK and ATLAS_ENTITIES should stop receiving message from Truncate Table/Delete data/Update data Signed-off-by: 's avatarSarath Subramanian <sarath@apache.org>
parent 3f67eb3c
......@@ -206,7 +206,6 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
case EXPORT:
case IMPORT:
case QUERY:
case TRUNCATETABLE:
event = new CreateHiveProcess(context);
break;
......
......@@ -271,7 +271,12 @@ public class CreateHiveProcess extends BaseHiveEvent {
ret = true;
}
}
// DELETE and UPDATE initially have one input and one output.
// Since they do not support sub-query, they won't create a lineage that have one input and one output. (One input only)
// It's safe to filter them out here.
if (output.getWriteType() == WriteEntity.WriteType.DELETE || output.getWriteType() == WriteEntity.WriteType.UPDATE) {
ret = true;
}
}
}
}
......
......@@ -1674,30 +1674,17 @@ public class HiveHookIT extends HiveITBase {
}
@Test
public void testTruncateTable() throws Exception {
public void testIgnoreTruncateTable() throws Exception {
String tableName = createTable(false);
String query = String.format("truncate table %s", tableName);
String query = String.format("truncate table %s", tableName);
runCommand(query);
Set<WriteEntity> outputs = getOutputs(tableName, Entity.Type.TABLE);
String tableId = assertTableIsRegistered(DEFAULT_DB, tableName);
HiveEventContext event = constructEvent(query, HiveOperation.TRUNCATETABLE, null, outputs);
AtlasEntity processEntity = validateProcess(event);
AtlasEntity processExecutionEntity1 = validateProcessExecution(processEntity, event);
AtlasObjectId process = toAtlasObjectId(processExecutionEntity1.getRelationshipAttribute(
BaseHiveEvent.ATTRIBUTE_PROCESS));
Assert.assertEquals(process.getGuid(), processEntity.getGuid());
//Check lineage
String datasetName = HiveMetaStoreBridge.getTableQualifiedName(CLUSTER_NAME, DEFAULT_DB, tableName);
AtlasLineageInfo atlasLineageInfoInput = atlasClientV2.getLineageInfo(tableId, AtlasLineageInfo.LineageDirection.INPUT,0);
Map<String, AtlasEntityHeader> entityMap = atlasLineageInfoInput.getGuidEntityMap();
Assert.assertEquals(numberOfProcessExecutions(processEntity), 1);
//Below should be assertTrue - Fix https://issues.apache.org/jira/browse/ATLAS-653
Assert.assertFalse(entityMap.containsKey(tableId));
assertTableIsRegistered(DEFAULT_DB, tableName);
assertProcessIsNotRegistered(event);
}
@Test
......
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