楼主: pkx1208
1440 1

pyhive连接hive时出错 [推广有奖]

  • 3关注
  • 0粉丝

已卖:161份资源

硕士生

55%

还不是VIP/贵宾

-

威望
0
论坛币
511 个
通用积分
3.0609
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
8153 点
帖子
66
精华
0
在线时间
134 小时
注册时间
2015-1-23
最后登录
2025-12-15

楼主
pkx1208 发表于 2024-6-3 11:32:40 |AI写论文
100论坛币
使用pyhive连接hive时,python报错信息:
raceback (most recent call last):
  File "/home/coco/.local/lib/python3.10/site-packages/thrift/transport/TSocket.py", line 150, in read
    buff = self.handle.recv(sz)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/coco/PycharmProjects/pythonProject/bdatat_processing/test.py", line 7, in <module>
    conn=hive.Connection(host=host,port=port,username=user,database='mum_baby')
  File "/home/coco/.local/lib/python3.10/site-packages/pyhive/hive.py", line 269, in __init__
    self._transport.open()
  File "/home/coco/.local/lib/python3.10/site-packages/thrift_sasl/__init__.py", line 93, in open
    status, payload = self._recv_sasl_message()
  File "/home/coco/.local/lib/python3.10/site-packages/thrift_sasl/__init__.py", line 112, in _recv_sasl_message
    header = self._trans_read_all(5)
  File "/home/coco/.local/lib/python3.10/site-packages/thrift_sasl/__init__.py", line 210, in _trans_read_all
    return read_all(sz)
  File "/home/coco/.local/lib/python3.10/site-packages/thrift/transport/TTransport.py", line 62, in readAll
    chunk = self.read(sz - have)
  File "/home/coco/.local/lib/python3.10/site-packages/thrift/transport/TSocket.py", line 164, in read
    raise TTransportException(message="unexpected exception", inner=e)
thrift.transport.TTransport.TTransportException: unexpected exception


在hive.log当中,报错信息为:
2024-06-03T10:47:33,894 ERROR [HiveServer2-Handler-Pool: Thread-42] server.TThreadPoolServer: Thrift error occurred during processing of message.
org.apache.thrift.protocol.TProtocolException: Missing version in readMessageBegin, old client?
        at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:228) ~[hive-exec-3.1.3.jar:3.1.3]
        at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:27) ~[hive-exec-3.1.3.jar:3.1.3]
        at org.apache.hive.service.auth.TSetIpAddressProcessor.process(TSetIpAddressProcessor.java:56) ~[hive-service-3.1.3.jar:3.1.3]
        at org.apache.thrift.server.TThreadPoolServer&#119882;&#119900;&#119903;&#119896;&#119890;&#119903;&#119875;&#119903;&#119900;&#119888;&#119890;&#119904;&#119904;.&#119903;&#119906;&#119899;(&#119879;&#119879;ℎ&#119903;&#119890;&#119886;&#119889;&#119875;&#119900;&#119900;&#119897;&#119878;&#119890;&#119903;&#119907;&#119890;&#119903;.&#119895;&#119886;&#119907;&#119886;:286) [ℎ&#119894;&#119907;&#119890;−&#119890;&#119909;&#119890;&#119888;−3.1.3.&#119895;&#119886;&#119903;:3.1.3]&#119886;&#119905;&#119895;&#119886;&#119907;&#119886;.&#119906;&#119905;&#119894;&#119897;.&#119888;&#119900;&#119899;&#119888;&#119906;&#119903;&#119903;&#119890;&#119899;&#119905;.&#119879;ℎ&#119903;&#119890;&#119886;&#119889;&#119875;&#119900;&#119900;&#119897;&#119864;&#119909;&#119890;&#119888;&#119906;&#119905;&#119900;&#119903;.&#119903;&#119906;&#119899;&#119882;&#119900;&#119903;&#119896;&#119890;&#119903;(&#119879;ℎ&#119903;&#119890;&#119886;&#119889;&#119875;&#119900;&#119900;&#119897;&#119864;&#119909;&#119890;&#119888;&#119906;&#119905;&#119900;&#119903;.&#119895;&#119886;&#119907;&#119886;:1149) [?:1.8.0351]&#119886;&#119905;&#119895;&#119886;&#119907;&#119886;.&#119906;&#119905;&#119894;&#119897;.&#119888;&#119900;&#119899;&#119888;&#119906;&#119903;&#119903;&#119890;&#119899;&#119905;.&#119879;ℎ&#119903;&#119890;&#119886;&#119889;&#119875;&#119900;&#119900;&#119897;&#119864;&#119909;&#119890;&#119888;&#119906;&#119905;&#119900;&#119903;Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_351]
        at java.lang.Thread.run(Thread.java:750) [?:1.8.0_351]

不知道要怎么解决


关键词:Hive HIV connection Unexpected Processing

沙发
shy836732411 发表于 2024-9-11 15:40:31
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from impala.dbapi import connect
# 连接到Impala
conn = connect(host='*****', port=***, user='****',password='****',auth_mechanism='LDAP', timeout=6000)
# 创建一个游标对象
cursor = conn.cursor()
# 执行SQL查询
cursor.execute('select data_day,count(distinct user_id) uct from database.tablename where app_id="**" and data_day="******" )
#列名查询
columns = [description[0] for description in cursor.description]
# 获取查询结果
results = cursor.fetchall()
# 遍历并打印结果
for result in results:
    print(result)
#list转换成dataframe   
df = pd.DataFrame(results, columns=['data_day', 'uct'])

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-30 21:22