gpt4 book ai didi

python-2.7 - HiveAccessControlException 权限被拒绝。 [关于 pyhs2]

转载 作者:行者123 更新时间:2023-12-02 19:31:39 24 4
gpt4 key购买 nike

我正在尝试通过编写选择查询来通过 pyhs2 访问数据。

import pyhs2

with pyhs2.connect(host='localhost',
port=10000,
authMechanism="PLAIN",
user='hue',
password='',
database='default') as conn:

with conn.cursor() as cur:
print cur.getDatabases()

cur.execute("select * from orders")
print cur.getSchema()

for i in cur.fetch():
print i

这给了我一个错误:

pyhs2.error.Pyhs2Exception: 'Error while compiling statement: FAILED: HiveAccessControlException Permission denied. Principal [name=hue, type=USER] does not have following privileges on Object [type=TABLE_OR_VIEW, name=default.orders] : [SELECT]'



建议使用的可用答案很少:
 grant SELECT on table orders to user hue

这又给了我一个错误:

yhs2.error.Pyhs2Exception: 'Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Permission denied. Principal [name=hue, type=USER] does not have following privileges on Object [type=TABLE_OR_VIEW, name=default.orders] : [SELECT with grant]'

最佳答案

在授予权限之前,请确保您具有管理员角色:

show current roles;

可能用户只有 公众 这还不够。您可以通过命令设置管理员角色:
set role admin; 

请参阅 Apache Hive 维基:

https://cwiki.apache.org/confluence/display/Hive/SQL+Standard+Based+Hive+Authorization
For Hive 0.14 and Newer
Set the following in hive-site.xml:
hive.users.in.admin.role to the list of comma-separated users who need to be added to admin role. Note that a user who belongs to the admin role needs to run the "set role" command before getting the privileges of the admin role, as this role is not in current roles by default.

关于python-2.7 - HiveAccessControlException 权限被拒绝。 [关于 pyhs2],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30567691/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com