Skip to content

rekotan/rbhive

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RBHive – Ruby thrift lib for executing Hive queries

A simple library to execute Hive queries against the Hive thrift server.

Example to fetch some results

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"}]

Example to execute a query

require 'rubygems'
require 'rbhive'

RBHive.connect('hive.server.address') do |connection|
  connection.execute 'DROP TABLE cities'
end
 nil

Example on how to create and/or drop tables

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

Example on how to modify table schema

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

About

Ruby gem for querying hive databases.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%