Python配置单元:节俭运输运输.t传输异常:非

2024-04-26 18:36:55 发布

您现在位置:Python中文网/ 问答频道 /正文

假设Hive安装在“g”集群中。我无法访问黄金集群。我在“s”集群中做python开发工作。我可以从“s”集群访问配置单元并运行查询。在

我有下面的代码从运行在“s”集群中的Python脚本连接到Hive。在

some_table是配置单元中已存在的表。我想执行一个简单的select * from some_table命令来获得一些结果。在

import sys
sys.path.append("/usr/lib/hive/lib/py")

from hive_service import ThriftHive
from hive_service.ttypes import HiveServerException
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol


transport = TSocket.TSocket('what-ever-server', what-ever-port)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)

client = ThriftHive.Client(protocol)
transport.open()
print "connect success"
client.execute("SELECT * FROM some_table")
print client.fetchAll()
print "executed"

但是在打印“connect success”之后,我得到了下面的错误。我假设连接是成功的。在

^{pr2}$

我在这个代码里做错了什么?在使用服务器名和端口连接到配置单元时,我没有遇到任何错误,所以我假设那里一切正常,与配置单元的连接不是问题所在。在


Tags: fromimportclienttable集群someprotocolthrift
1条回答
网友
1楼 · 发布于 2024-04-26 18:36:55

经过进一步的研究后,我发现实际上是HiveServer2使用的端口号是10000。之后,我必须安装pyhs2才能正常工作。在

相关问题 更多 >