Pyhive 远程连接hive出现问题:
from pyhive import hiveimport pandas as pd#Create Hive connection conn = hive.Connection(host="172.18.33.32", port=10000, username="hadoop", auth="NOSASL", database="log")# Read Hive table and Create pandas dataframedf = pd.read_sql("SELECT count(*) FROM record", conn)print(df.head())
错误:
Traceback (most recent call last): File "HiveConnect.py", line 4, inconn = hive.Connection(host="172.18.33.32", port=10000, username="hadoop", auth="NOSASL") File "C:\Users\v-lijess\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyhive\hive.py", line 168, in __init__ response = self._client.OpenSession(open_session_req) File "C:\Users\v-lijess\AppData\Local\Programs\Python\Python36-32\lib\site-packages\TCLIService\TCLIService.py", line 187, in OpenSession return self.recv_OpenSession() File "C:\Users\v-lijess\AppData\Local\Programs\Python\Python36-32\lib\site-packages\TCLIService\TCLIService.py", line 199, in recv_OpenSession (fname, mtype, rseqid) = iprot.readMessageBegin() File "C:\Users\v-lijess\AppData\Local\Programs\Python\Python36-32\lib\site-packages\thrift\protocol\TBinaryProtocol.py", line 148, in readMessageBegin name = self.trans.readAll(sz) File "C:\Users\v-lijess\AppData\Local\Programs\Python\Python36-32\lib\site-packages\thrift\transport\TTransport.py", line 60, in readAll chunk = self.read(sz - have) File "C:\Users\v-lijess\AppData\Local\Programs\Python\Python36-32\lib\site-packages\thrift\transport\TTransport.py", line 162, in read self.__rbuf = BufferIO(self.__trans.read(max(sz, self.__rbuf_size))) File "C:\Users\v-lijess\AppData\Local\Programs\Python\Python36-32\lib\site-packages\thrift\transport\TSocket.py", line 132, in read message='TSocket read 0 bytes')thrift.transport.TTransport.TTransportException: TSocket read 0 bytes
解决方案:hive-site.xml 增加下面属性,然后重启hive