我正在尝试从python连接impala并使用Impyla模块实现此目的。以下是用于连接的代码段。
connect(host='<impala_host>', port=21050)
当我尝试执行任何查询时,这与Authorization异常失败。确切的例外是,
impala.error.HiveServer2Error: AuthorizationException: User '<user>' does not have privileges to execute 'SELECT' on: <table>
如何为connect方法提供用户和密码?
看看代码,似乎user
和password
参数默认设置为None
。您应该能够使用以下内容自行设置它们:
connect(host='my.impala.host', port=21050, user='myuser', password='mypassword')
你可以在这里看到https://github.com/cloudera/impyla/blob/master/impala/dbapi.py的文档。
我遇到过同样的问题。通过添加use_ssl解决了这个问题:
connect(host='my.impala.host', port=21050, user='myuser', password='mypassword', use_ssl=True)
用户名可以在游标参数中定义,例如
conn = connect(host='myhost');
cursor = conn.cursor(user='myuser')
cursor.execute('select user();')