使用php連線hive的條件
1 需要安裝thrift 安裝步驟
# ./configure --without-ruby
# make && make install
如果沒有安裝libevent libevent-devel的應該先安裝這兩個依賴庫yum -y install libevent libevent-devel
安裝好後啟動hive thrift
# ./hive --service hiveserver >/dev/null 2>/dev/null &
檢視hiveserver預設埠是否開啟10000 如果開啟表示成功
注:php版本要求是5.2或者以上
php連線hive**
[c-sharp]view plain
copy
print?
<?
// php連線hive thrift依賴包路徑
$globals['thrift_root'
] =
'/var/www/html/hivephp/thrift/'
; // load the required files for connecting to hive
require_once $globals['thrift_root'
] .
'packages/hive_service/thrifthive.php'
; require_once $globals['thrift_root'
] .
'transport/tsocket.php'
; require_once $globals['thrift_root'
] .
'protocol/tbinaryprotocol.php'
; // set up the transport/protocol/client
$transport = new
tsocket(
'localhost'
, 10000);
$protocol = new
tbinaryprotocol($transport);
$client = new
thrifthiveclient($protocol);
$transport->open();
// run queries, metadata calls etc
$client->execute('add jar /usr/local/hadoop/hive/lib/hive-contrib-0.7.0-cdh3u0.jar'
);
$client->execute('select count(1) from apilog'
);
var_dump($client->fetchall());
$transport->close();
?>
將以上**存為test.php到apache的www路徑/var/www/html/中 php連線hive的依賴包放到/var/www/html/hivephp/thrift/
開啟瀏覽器瀏覽http://localhost/test.php就可以看到查詢結果了
hql執行左連線
如果兩個表沒有關聯影射通過hql的jion會有 path expected for join異常 解決方法 string sql select from a table a left outer join b table b on a.id b.parentid session session ge...
php連線hive執行sql查詢
使用php連線hive的條件 1 需要安裝thrift 安裝步驟 configure without ruby make make install 如果沒有安裝libevent libevent devel的應該先安裝這兩個依賴庫yum y install libevent libevent dev...
HQL執行增刪改查的步驟
hql執行增刪改查的步驟 2008 07 24 03 17 對與hql首先要明白hql是什麼?hql是hibernate query lanuage hibernate 查詢語言 使用hql 用到的類 import org.hibernate.query import org.hibernate.s...