Java 如何在调试模式下运行 hive
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27854359/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to run hive in debug mode
提问by saching
i took example from cloudera website to write a custom SerDe for parsing a file
我以 cloudera 网站为例编写了一个自定义 SerDe 来解析文件
http://blog.cloudera.com/blog/2012/12/how-to-use-a-serde-in-apache-hive/
http://blog.cloudera.com/blog/2012/12/how-to-use-a-serde-in-apache-hive/
it seems a good example but when i create table with custom serde
这似乎是一个很好的例子,但是当我使用自定义 serde 创建表时
ADD JAR <path-to-hive-serdes-jar>;
CREATE EXTERNAL TABLE tweets (
id BIGINT,
created_at STRING,
source STRING,
favorited BOOLEAN,
retweeted_status STRUCT<
text:STRING,
user:STRUCT<screen_name:STRING,name:STRING>,
retweet_count:INT>,
entities STRUCT<
urls:ARRAY<STRUCT<expanded_url:STRING>>,
user_mentions:ARRAY<STRUCT<screen_name:STRING,name:STRING>>,
hashtags:ARRAY<STRUCT<text:STRING>>>,
text STRING,
user STRUCT<
screen_name:STRING,
name:STRING,
friends_count:INT,
followers_count:INT,
statuses_count:INT,
verified:BOOLEAN,
utc_offset:INT,
time_zone:STRING>,
in_reply_to_screen_name STRING
)
PARTITIONED BY (datehour INT)
ROW FORMAT SERDE 'com.cloudera.hive.serde.JSONSerDe'
LOCATION '/user/flume/tweets';
it executed perfectly fine but when i do
它执行得非常好,但是当我这样做时
select * from tweets;
i am getting nothing so thats why i wanted to know if i can run hive in debug mode to see where it is getting failed
我什么也没得到所以这就是为什么我想知道我是否可以在调试模式下运行 hive 以查看它在哪里失败
采纳答案by SachinJ
You better start hive shell by switching logger mode to DEBUG as follows, I hope you could find something useful from there.
您最好按如下方式将记录器模式切换为 DEBUG 来启动 hive shell,我希望您能从那里找到有用的东西。
hive --hiveconf hive.root.logger=DEBUG,console
回答by Raju Shikha
Hive code can be debugged.This link may help you : https://cwiki.apache.org/confluence/display/Hive/DeveloperGuide#DeveloperGuide-DebuggingHiveCode
可以调试 Hive 代码。此链接可能对您有所帮助:https: //cwiki.apache.org/confluence/display/Hive/DeveloperGuide#DeveloperGuide-DebuggingHiveCode
回答by Jatin Kumar
Setting hive --hiveconf hive.root.logger=DEBUG,console
may not always workbecause of company specific setup.
由于公司特定的设置,设置hive --hiveconf hive.root.logger=DEBUG,console
可能并不总是有效。
I ended up creating a hive-log4j.properties
file in my home directory with following settings:
我最终hive-log4j.properties
在我的主目录中创建了一个具有以下设置的文件:
log4j.rootCategory=DEBUG,console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
and started hive shell using CLASSPATH=$HOME hive
which adds your home directory having hive-log4j.properties
in front of the classpath and so is picked up.
并启动 hive shell 使用CLASSPATH=$HOME hive
它hive-log4j.properties
在类路径前面添加您的主目录,因此被拾取。