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

问题描述 投票:1回答:1

我试图通过编写选择查询来通过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:'编译语句时出错:失败:HiveAccessControlException权限被拒绝。主体[name = hue,type = USER]对对象[type = TABLE_OR_VIEW,name = default.orders]没有以下特权:[SELECT]'

建议使用以下几种可用答案:

 grant SELECT on table orders to user hue

这再次给我一个错误:

yhs2.error.Pyhs2Exception:'处理语句时出错:FAILED:执行错误,从org.apache.hadoop.hive.ql.exec.DDLTask返回代码1。没有权限。主体[name = hue,type = USER]对对象[type = TABLE_OR_VIEW,name = default.orders]不具有以下特权:[SELECT with Grant]'

python-2.7 hadoop hive hortonworks-data-platform
1个回答
0
投票
show current roles;

可能用户仅具有

public角色,这是不够的。您可以通过以下命令设置管理员角色:

set role admin;

请参阅Apache Hive Wiki:
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.

© www.soinside.com 2019 - 2024. All rights reserved.