forward3d / rbhive

Ruby gem for querying Apache Hive
http://www.forward3d.com
MIT License
98 stars 74 forks source link

fetch support for ADD JAR queries #13

Closed kaschaeffer closed 10 years ago

kaschaeffer commented 10 years ago

I'm using rbhive on HiveServer2 to execute arbitrary commands and, if there is a response, to capture that. The fetch command works generally quite well. However, it seems to not support "ADD JAR ..." type commands for loading UDFs.

I can alternatively use the execute command. However, this has the disadvantage of not loading results in a simple way and of suppressing all errors.

Is there a way to modify fetch so that it supports arbitrary queries?

Thanks, Kevin

andytinycat commented 10 years ago

When you say "seems to not support", do you mean you get an exception if you try to do connection.fetch("ADD JAR...")?

Can you try, within a block with the same connection, executing execute("ADD JAR.."), then fetch("YOUR QUERY")? In theory, that should work. Something like this:

RBHive.tcli_connect('hive.server.address', 10_000) do |connection|
  connection.execute("ADD JAR myjar.jar")
  connection.fetch("SELECT * FROM someplace")
end
andytinycat commented 10 years ago

I'm closing this, as I've not heard from you. Feel free to re-open if you're still having problems.

khanh-nguyen commented 8 years ago

@andytinycat I got this issue with cdh5

options = { :transport => :buffered, :hive_version => :cdh5, :transport => :sasl, :sasl_params => {}}
RBHive.tcli_connect("hive-server-address", 10000, options) do |connection|
    connection.execute("ADD JAR /nfs/shared/path/to/myjar.jar")
    ...
end

The error I got is

RBHive::TCLIConnectionError:
       Error while processing statement: /nfs/shared/path/to/myjar.jar does not exist

I could go to the server and verify that the file exists: ls -l /nfs/shared/path/to/myjar.jar. Do you have any idea why?