Giter Club home page Giter Club logo

rbhive's Introduction

RBHive – Ruby thrift lib for executing Hive queries

A simple library to execute Hive queries against the Hive thrift server. Also supports PLAIN SASL connection to thrift server (HiveServer2)

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

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 It is in progress to implement LDAP/KERBEROS authentication as well. Only NONE supported currently.

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

rbhive's People

Contributors

abhinay avatar andykent avatar antoniogarrote avatar horaci avatar jae avatar jkitching avatar kolobock avatar pingles avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.