A simple library to execute Hive queries against the Hive thrift server.
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"}]
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