这是Apache Atlas的已知问题。为了解决这个问题,我们可以使用以下代码进行绕过操作:
@AtlasFunctions
public class DeleteEntityFunction {
public static boolean deleteEntity(String guid) {
AtlasEntityStore atlasEntityStore = AtlasServiceLoader.get().getService(AtlasEntityStore.class);
try {
atlasEntityStore.deleteByIds(Collections.singleton(new AtlasObjectId(guid)));
} catch (AtlasBaseException e) {
e.printStackTrace();
return false;
}
return true;
}
}
String entityGuid = "replace_with_entity_guid"; // 要删除的实体GUID
// 调用自定义函数删除实体和实体属性
AtlasFunctionsRegistry functionsRegistry = new AtlasFunctionsRegistry();
functionsRegistry.getFunction("deleteEntity").execute(entityGuid);
请注意,此解决方法仅适用于删除整个实体及其关联实体属性。如果您只想删除实体属性而不是整个实体,请使用AtlasEntityStore并手动删除实体属性。