全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 python论坛
1371 1
2024-06-03
悬赏 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]

不知道要怎么解决


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
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'])
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群