- 修改HIVE-SITE.XML,每个sql在执行之前都会去执行这个类,这个类实现
ExecuteWithHookContext接口
<property>
<name>hive.exec.pre.hooks</name>
<value>com.wending.hive.HivePreHook</value>
<description>
Comma-separated list of pre-execution hooks to be invoked for each statement.
A pre-execution hook is specified as the name of a Java class which implements the
org.apache.hadoop.hive.ql.hooks.ExecuteWithHookContext interface.
</description>
</property>
2.示例代码,然后打包放在hive lib/路径下,不管从哪个路径访问的,命令行,JDBC等等都能把sql采集到。
public class HivePreHook implements ExecuteWithHookContext {
public vo