pyhive:使用pyhive设置蜂巢属性

时间:2019-02-20 10:48:38

标签: python hive hiveql pyhive

我有一个复杂的配置单元查询,其基础联接是笛卡尔积。所以我需要设置以下属性。但是当我使用pyhive执行这些属性时,它无法执行。我遇到错误,要求设置笛卡尔属性。

set1 = '''SET hive.strict.checks.cartesian.product = false'''

set2 = '''SET hive.mapred.mode = strict'''

def connectData(query,host,port,username):
    conn = hive.Connection(host=host, port=port, username=username).cursor()
    conn.execute(query)
    val=conn.fetchall()
    columnNames = [a[0] for a in  conn.description]
    df=pd.DataFrame(data=val,columns=columnNames)
    return df

def settings(query,host,port,username):
    conn = hive.Connection(host=host, port=port, username=username).cursor()
    conn.execute(query)

settings(set1, host, port, username)
settings(set2, host, port, username)

df = connectData(query, host, port, username)
print(df)

1 个答案:

答案 0 :(得分:0)

尝试如下所示的设置:

hive.connect('host', configuration={'hive.strict.checks.cartesian.product':'false'})
hive.connect('host', configuration={'hive.mapred.mode':'strict'})