hive 12及以后,可以使用非同步查询
rbhive1.0对此的支持函数如下
# encoding: UTF-8 $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'pp' require 'rbhive' def abc_function() RBHive.tcli_connect('1.2.3.4', 10000,{hive_version: 12, transport: :sasl, :sasl_params => {}}) do |connection| handles =connection.async_execute('select * from abc limit 2') state= connection.async_state(handles) while true do sleep 10 state= connection.async_state(handles) if(state == :finished) result = connection.async_fetch(handles,1000) pp result connection.async_close_session(handles) break end end end end begin abc_function() rescue Exception => e puts "#{e}" puts "#{e.backtrace}" end