簡體   English   中英

將Hive作業提交到Dataproc集群時,如何執行gcp存儲桶中的Hive查詢列表(在我的情況下為gs:/hive/hive.sql”)

[英]How to execute list of hive queries which is in gcp storage bucket (in my case gs:/hive/hive.sql") while submitting hive job to dataproc cluster

在這里,我在hiveJob下的queryList中編寫查詢。

將Hive作業提交到Dataproc集群

def submit_hive_job(dataproc, project, region,
                       cluster_name):
    job_details = {
        'projectId': project,
        'job': {
            'placement': {
                'clusterName': cluster_name
            },
            "hiveJob": {
                "queryList": {
                    ###
                    how can i execute .sql file here which is in bucket
                    ####
                    "queries": [
                        "CREATE TABLE IF NOT EXISTS sai ( eid int, name String, salary String, destination String)",
                        "Insert into table sai values (26,'Shiv','1500','ac')"
                    ]
                }
            }
        }
    }
    result = dataproc.projects().regions().jobs().submit(
        projectId=project,
        region=region,
        body=job_details).execute()
    job_id = result['reference']['jobId']
    print('Submitted job Id {}'.format(job_id))
    return job_id

存儲桶中的hive.sql文件

create table employee ( employeeid: int, employeename: string, salary: float) rows format delimited fields terminated by ‘,’ ;
describe employee;
select * from employee;

我發現我們可以將.sql文件保存在存儲桶中,然后按如下所示指定queryFileUri

"hiveJob": {
 "queryFileUri":"gs://queryfile/test.sql"             
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM