How to use rbhive gem and hive query

I have a task to query in hive db from ruby ​​code. I plan to use rbhive gem, but I cannot get documentation from it how to pass username, password, db name, etc. when connected to the hive server.

Here is my code:

res = RBHive.connect('host_address', 10_000) do |connection|
  connection.fetch 'show databases;'
end

It just shows:

Connecting to host_server on port 10000
Executing Hive Query: show databases;

and he hangs there endlessly.

+4
source share
2 answers

This may be surprising, but with Hive 1.0.0 I was able to connect using

RBHive.tcli_connect('host', 10000, {transport: :sasl, sasl_params:{}}) do |connection|
+1
source

Please, use

options = { username: 'username', password: 'password' }
RBHive.tcli_connect('host', 'port', { transport: :sasl, sasl_params: options}) do |connection|
  results = connection.execute "SHOW DATABASES"
end
0
source

Source: https://habr.com/ru/post/1589197/


All Articles