Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Hive on tez cannot execute custom hook program!!!

avatar
Explorer

I developed a custom hook on CDH (6.2. X), implement the HiveDriverRunHook interface and ExecuteWithHookContext interface. It runs smoothly, but when I migrate the hook to CDP (7.1. X), I report an error and cannot execute it. I suspect it was caused by the Tez engine, but I cannot solve it and need help,thanks very much

1 ACCEPTED SOLUTION

avatar
Super Collaborator

In CDP, when the HiveProtoLoggingHook is configured, query information is automatically captured and stored in the 'query_data' folder, which is typically located where 'hive.hook.proto.base-directory' is set. These details are saved as protobuf files, and in Hive, you can utilize the ProtobufMessageSerDe to access them.

To read this captured data, you can create a table as shown below.

CREATE EXTERNAL TABLE `query_data`(
`eventtype` string COMMENT 'from deserializer', 
`hivequeryid` string COMMENT 'from deserializer', 
`timestamp` bigint COMMENT 'from deserializer', 
`executionmode` string COMMENT 'from deserializer', 
`requestuser` string COMMENT 'from deserializer', 
`queue` string COMMENT 'from deserializer', 
`user` string COMMENT 'from deserializer', 
`operationid` string COMMENT 'from deserializer', 
  `tableswritten` array<string> COMMENT 'from deserializer', 
  `tablesread` array<string> COMMENT 'from deserializer', 
  `otherinfo` map<string,string> COMMENT 'from deserializer')
PARTITIONED BY ( 
  `date` string)
ROW FORMAT SERDE 
  'org.apache.hadoop.hive.ql.io.protobuf.ProtobufMessageSerDe' 
WITH SERDEPROPERTIES ( 
  'proto.class'='org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents$HiveHookEventProto', 
  'proto.maptypes'='org.apache.hadoop.hive.ql.hooks.proto.MapFieldEntry') 
STORED AS INPUTFORMAT 
  'org.apache.hadoop.hive.ql.io.protobuf.ProtobufMessageInputFormat' 
OUTPUTFORMAT 
  'org.apache.hadoop.hive.ql.io.HiveNullValueSequenceFileOutputFormat'
LOCATION
  '<query_datalocation>'
TBLPROPERTIES (
  'bucketing_version'='2', 
  'proto.class'='org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents$HiveHookEventProto')


After creating the table, execute 'msck repair query_data sync partitions' to synchronize the partitions, and then you can retrieve and analyze the data using Beeline.




View solution in original post

7 REPLIES 7

avatar
Community Manager

@yucai, Welcome to our community! To help you get the best possible answer, I have tagged in our Hive experts @asish @tjangid who may be able to assist you further.

Please feel free to provide any additional information or details about your query, and we hope that you will find a satisfactory solution to your question.



Regards,

Vidya Sargur,
Community Manager


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:

avatar
Guru

Custom hook is not supported by Cloudera.

avatar
Explorer

But I have implemented custom hooks on CDH, which means that custom hooks are no longer supported in CDP, right? Is there any other way for me to obtain information about hive without changing the source code? For example, SQL information or execution result information?

avatar
Cloudera Employee

Hi @yucai , I have noticed your question, I think the Chinese PS team can help you. By the way, which company do you belong to? China UnionPay Data Services? Can you leave your contact information, we can have a quick call.

avatar
Explorer

I sent you a private message with my phone number. Thank you

avatar
Super Collaborator

In CDP, when the HiveProtoLoggingHook is configured, query information is automatically captured and stored in the 'query_data' folder, which is typically located where 'hive.hook.proto.base-directory' is set. These details are saved as protobuf files, and in Hive, you can utilize the ProtobufMessageSerDe to access them.

To read this captured data, you can create a table as shown below.

CREATE EXTERNAL TABLE `query_data`(
`eventtype` string COMMENT 'from deserializer', 
`hivequeryid` string COMMENT 'from deserializer', 
`timestamp` bigint COMMENT 'from deserializer', 
`executionmode` string COMMENT 'from deserializer', 
`requestuser` string COMMENT 'from deserializer', 
`queue` string COMMENT 'from deserializer', 
`user` string COMMENT 'from deserializer', 
`operationid` string COMMENT 'from deserializer', 
  `tableswritten` array<string> COMMENT 'from deserializer', 
  `tablesread` array<string> COMMENT 'from deserializer', 
  `otherinfo` map<string,string> COMMENT 'from deserializer')
PARTITIONED BY ( 
  `date` string)
ROW FORMAT SERDE 
  'org.apache.hadoop.hive.ql.io.protobuf.ProtobufMessageSerDe' 
WITH SERDEPROPERTIES ( 
  'proto.class'='org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents$HiveHookEventProto', 
  'proto.maptypes'='org.apache.hadoop.hive.ql.hooks.proto.MapFieldEntry') 
STORED AS INPUTFORMAT 
  'org.apache.hadoop.hive.ql.io.protobuf.ProtobufMessageInputFormat' 
OUTPUTFORMAT 
  'org.apache.hadoop.hive.ql.io.HiveNullValueSequenceFileOutputFormat'
LOCATION
  '<query_datalocation>'
TBLPROPERTIES (
  'bucketing_version'='2', 
  'proto.class'='org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents$HiveHookEventProto')


After creating the table, execute 'msck repair query_data sync partitions' to synchronize the partitions, and then you can retrieve and analyze the data using Beeline.




avatar
Community Manager

@yucai Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future.  Thanks.@


Regards,

Diana Torres,
Community Moderator


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community: