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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 05:09:19  来源:igfitidea点击:

how to run hive in debug mode

javahadoophive

提问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

回答by Jatin Kumar

Setting hive --hiveconf hive.root.logger=DEBUG,consolemay not always workbecause of company specific setup.

由于公司特定的设置,设置hive --hiveconf hive.root.logger=DEBUG,console可能并不总是有效

I ended up creating a hive-log4j.propertiesfile 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 hivewhich adds your home directory having hive-log4j.propertiesin front of the classpath and so is picked up.

并启动 hive shell 使用CLASSPATH=$HOME hivehive-log4j.properties在类路径前面添加您的主目录,因此被拾取。