0

I want to save the result of my hive queries in a file. But the output from hive has a lot of logs as well. Is there any way to disable them. I just want to capture the result of the query.

hive> show databases;
2019-03-12 08:49:38 INFO  HiveConf:3944 - Using the default value passed in for log id: a02ee11b-32fe-4ed6-8c7a-e93a8fffb9c5
2019-03-12 08:49:38 INFO  Driver:429 - Compiling command(queryId=root_20190312084938_951426c7-96cc-4b9a-9be6-ed22c9e5c769): show databases
2019-03-12 08:49:39 INFO  metastore:407 - Trying to connect to metastore with URI thrift://hiveservice.staging.svc:9083 2019-03-12 08:49:39 INFO  metastore:481 - Opened a connection to metastore, current connections: 1
2019-03-12 08:49:39 INFO  metastore:534 - Connected to metastore.
2019-03-12 08:49:39 INFO  Driver:518 - Semantic Analysis Completed
2019-03-12 08:49:39 INFO  Driver:290 - Returning Hive schema:
.
.
.
.
2019-03-12 08:49:39 INFO  DDLTask:2506 - results : 1
2019-03-12 08:49:39 INFO  Driver:2050 - Completed executing command(queryId=root_20190312084938_951426c7-96cc-4b9a-9be6-ed22c9e5c769); Time taken: 0.102 seconds
OK
2019-03-12 08:49:39 INFO  Driver:1111 - OK
2019-03-12 08:49:39 INFO  DbLockManager:251 - releaseLocks: []
2019-03-12 08:49:39 INFO  deprecation:1285 - mapred.input.dir is deprecated. Instead, use mapreduce.input.fileinputformat.inputdir
2019-03-12 08:49:39 INFO  FileInputFormat:256 - Total input files to process : 1
2019-03-12 08:49:39 INFO  ListSinkOperator:690 - Closing operator LIST_SINK[0]
my_database
Time taken: 1.131 seconds, Fetched: 1 row(s)
2019-03-12 08:49:39 INFO  CliDriver:1111 - Time taken: 1.131 seconds, Fetched: 1 row(s)
2019-03-12 08:49:39 INFO  HiveConf:3944 - Using the default value passed in for log id: a02ee11b-32fe-4ed6-8c7a-e93a8fffb9c5
2019-03-12 08:49:39 INFO  SessionState:432 - Resetting thread name to  main
hive>
wittyameta
  • 375
  • 1
  • 3
  • 16
  • Something like that? https://stackoverflow.com/questions/14289846/hive-query-output-to-file – pheeleeppoo Mar 12 '19 at 09:06
  • @pheeleeppoo This only works for select queries. It wasn't working for 'show databases' – wittyameta Mar 12 '19 at 09:06
  • logs you can control from log4j conf file , check hive conf folder? If you can tell me which hadoop distribution you are using So can give you steps to update log conf. – hayat Mar 12 '19 at 09:07
  • @hayat I'm using Hive 2.3.4. I don't see any log4j.properties file in conf folder. There are a bunch of log4j.template.properties files, but no .properties – wittyameta Mar 12 '19 at 09:37
  • you can copy log4j.template.properties to log4j.properties and updated log setting and then restart hive – hayat Mar 12 '19 at 17:07

0 Answers0