這個錯誤困擾了好久,因為集群有多台,暫放到其他幾台機器上執行了SQL操作,一直在找解決方法,無意間得到真傳,喜出望外啊
報錯信息:
Traceback (most recent call last):
File "b.py", line 3, in <module>
cur=conn.cursor()
File "/usr/local/python2.7/lib/python2.7/site-packages/impyla-v0.14.0-py2.7.egg/impala/hiveserver2.py", line 125, in cursor
session = self.service.open_session(user, configuration)
File "/usr/local/python2.7/lib/python2.7/site-packages/impyla-v0.14.0-py2.7.egg/impala/hiveserver2.py", line 995, in open_session
resp = self._rpc('OpenSession', req)
File "/usr/local/python2.7/lib/python2.7/site-packages/impyla-v0.14.0-py2.7.egg/impala/hiveserver2.py", line 923, in _rpc
response = self._execute(func_name, request)
File "/usr/local/python2.7/lib/python2.7/site-packages/impyla-v0.14.0-py2.7.egg/impala/hiveserver2.py", line 940, in _execute
return func(request)
File "/usr/local/python2.7/lib/python2.7/site-packages/impyla-v0.14.0-py2.7.egg/impala/_thrift_gen/TCLIService/TCLIService.py", line 174, in OpenSession
self.send_OpenSession(req)
File "/usr/local/python2.7/lib/python2.7/site-packages/impyla-v0.14.0-py2.7.egg/impala/_thrift_gen/TCLIService/TCLIService.py", line 181, in send_OpenSession
args.write(self._oprot)
File "/usr/local/python2.7/lib/python2.7/site-packages/impyla-v0.14.0-py2.7.egg/impala/_thrift_gen/TCLIService/TCLIService.py", line 1069, in write
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
TypeError: expecting list of size 2 for struct args
解決方法:
[root@cdh3 tmp]# pip install thrift==0.9.3
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Collecting thrift==0.9.3
Downloading http://mirrors.tencentyun.com/pypi/packages/ae/58/35e3f0cd290039ff862c2c9d8ae8a76896665d70343d833bdc2f748b8e55/thrift-0.9.3.tar.gz
Installing collected packages: thrift
Found existing installation: thrift 0.13.0
Uninstalling thrift-0.13.0:
Successfully uninstalled thrift-0.13.0
Running setup.py install for thrift ... done
Successfully installed thrift-0.9.3
原因:應該是thrift模塊版本的問題
Thrift是Facebook於2007年開發的跨語言的rpc服框架,提供多語言的編譯功能,並提供多種服務器工作模式;用戶通過Thrift的IDL(接口定義語言)來描述接口函數及數據類型,然后通過Thrift的編譯環境生成各種語言類型的接口文件,用戶可以根據自己的需要采用不同的語言開發客戶端代碼和服務器端代碼。