简体   繁体   English

pyhive:使用 pyhive 设置配置单元属性

[英]pyhive: Set hive properties using pyhive

i have a complex hive query which underlying joins are cartesian product.我有一个复杂的 hive 查询,其中底层连接是笛卡尔积。 so i need to set the below properties.所以我需要设置以下属性。 but when i execute these properties using pyhive it is not able to execute.但是当我使用 pyhive 执行这些属性时,它无法执行。 i am getting an error asking to set properties for cartesian.我收到一个错误,要求为笛卡尔设置属性。

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

set2 = '''SET hive.mapred.mode=strict''' 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)

Try settings as shown below:尝试如下设置:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM