LineageHook implements org.apache.hadoop.hive.ql.hooks.ExecuteWithHookContext { @Override public void run(HookContext hookContext) { LOGGER.info("Running LineageHook..."); String wholeQuery = null; String processId = null; String instanceExecId = null; try { if (hookContext == null) { LOGGER.warn("HookContext is null. Assuming default values"); wholeQuery = LineageConstants.query; processId = "" + LineageConstants.processId; instanceExecId = "" + LineageConstants.instanceId; } else { wholeQuery = hookContext.getQueryPlan().getQueryString(); Properties properties = hookContext.getConf().getAllProperties(); for (Map.Entry entry : properties.entrySet()) { String key = (String)(entry.getKey()); if (LineageConstants.processIdString.equalsIgnoreCase(key)) { processId = (String) (entry.getValue()); LOGGER.info("ProcessId found in Hive = " + processId); } else if (LineageConstants.instanceExecIdString.equalsIgnoreCase(key)) { instanceExecId = (String) (entry.getValue()); LOGGER.info("InstanceExecId found in Hive = " + instanceExecId); } } if (processId == null || instanceExecId == null) { LOGGER.info("Warning: ProcessId or InstanceExecId is null. Lineage not done. End of Lineage Hook."); return; } } LOGGER.info("BDRE Printed query = " + wholeQuery); LineageProcessor lineageProcessor = new LineageProcessor(); lineageProcessor.execute(wholeQuery, processId, instanceExecId); successFlag = true; } catch (Exception e) { LOGGER.error("Error in executing LineageHook", e); successFlag = false; } }  boolean isSuccess(); @Override void run(HookContext hookContext);  }
@Ignore @Test public void testRun() { LineageHook lineageHook=new LineageHook(); lineageHook.run(null); assert lineageHook.isSuccess(); }