A simple library to execute Hive queries against the Hive thrift server. Also supports PLAIN SASL connection to HiveServer2 thrift server.
HiveServer:
require 'rubygems' require 'rbhive' RBHive.connect('hive.server.address') do |connection| connection.fetch 'SELECT city, country FROM cities' end ➔ [{:city => "London", :country => "UK"}, {:city => "Mumbai", :country => "India"}, {:city => "New York", :country => "USA"}]
HiveServer2:
RBHive.tcli_connect('hive.server2.address', 'hive.server2.port', 'hive.server2.connection_options_hash') do |connection| connection.fetch 'SELECT city, country FROM cities' end ➔ [{:city => "London", :country => "UK"}, {:city => "Mumbai", :country => "India"}, {:city => "New York", :country => "USA"}]
where connection_options_hash = { username: ‘user’, password: ‘pass’} or an empty(nil) is accepted.
There are plans to implement LDAP/KERBEROS authentication as well. Only NONE supported currently.
require 'rubygems' require 'rbhive' RBHive.connect('hive.server.address') do |connection| connection.execute 'DROP TABLE cities' end ➔ nil
require 'rubygems' require 'rbhive' table = TableSchema.new('person', 'List of people that owe me money') do column 'name', :string, 'Full name of debtor' column 'address', :string, 'Address of debtor' column 'amount', :float, 'The amount of money borrowed' partition 'dated', :string, 'The date money was given' partition 'country', :string, 'The country the person resides in' end RBHive.connect('hive.server.address') do |connection| connection.create_table(table) connection.drop_table(table) end
require 'rubygems' require 'rbhive' table = TableSchema.new('person', 'List of people that owe me money') do column 'name', :string, 'Full name of debtor' column 'address', :string, 'Address of debtor' column 'amount', :float, 'The amount of money borrowed' column 'new_amount', :float, 'The new amount this person somehow convinced me to give them' partition 'dated', :string, 'The date money was given' partition 'country', :string, 'The country the person resides in' end RBHive.connect('hive.server.address') do |connection| connection.replace_columns(table) end