FAILED: ParseException line 1:21 cannot recognize input near '' '' '' in table name

后端 未结 2 2089
情书的邮戳
情书的邮戳 2021-01-22 07:18

Command:

hive -e \"use xxx;DROP TABLE IF EXISTS `xxx.flashsaleeventproducts_hist`;CREATE EXTERNAL TABLE `xxx.flashsaleeventproducts_hist`(`event_id` string,`grou         


        
2条回答
  •  清酒与你
    2021-01-22 07:45

    Please find below script to connect to hive:

    import subprocess
    import sys
    query=""" hive -e "set hive.cli.print.header=true;use db;select * from somehivetable;" """
    
    outresutfile=open("query_result.csv", 'w')
    p=subprocess.Popen(query,shell=True,stdout=outresutfile,stderr=subprocess.PIPE)
    stdout,stderr = p.communicate()
    if p.returncode != 0:
        print stderr
        sys.exit(1)
    

提交回复
热议问题