pyhive 执行报错:thrift.Thrift.TApplicationException: Invalid method name: 'GetLog'
时间: 2024-03-01 17:51:18 浏览: 30
这个错误可能是由于客户端和服务器之间的 Thrift 协议不兼容引起的。请确保使用的 pyhive 版本与 Hive 服务器使用的 Thrift 版本兼容。你可以查看 Hive 版本的文档,以确定它使用的 Thrift 版本。
如果你使用的是较新版本的 pyhive,它可能使用的是较新版本的 Thrift 协议。在这种情况下,你可以尝试将 pyhive 的 Thrift 协议版本设置为与 Hive 服务器兼容的版本,例如:
```python
from pyhive import hive
from thrift.protocol import TBinaryProtocol
# 建立连接
host = 'your-hive-host'
port = 10000
conn = hive.Connection(host=host, port=port, username='your-username', password='your-password',
thrift_transport=None, thrift_protocol=TBinaryProtocol)
# 执行查询
cursor = conn.cursor()
cursor.execute('SELECT * FROM your_table')
# 获取结果
results = cursor.fetchall()
# 关闭连接
cursor.close()
conn.close()
```
在上面的示例中,我们将 pyhive 的 Thrift 协议版本设置为 TBinaryProtocol,这是 Hive 服务器支持的协议版本之一。如果你的 Hive 服务器使用的是不同的协议版本,请相应地更改 pyhive 的 Thrift 协议版本。