【问题标题】:Call BigQuery stored procedure(Routine) using spring boot使用 Spring Boot 调用 BigQuery 存储过程(例程)
【发布时间】:2021-12-17 05:58:24
【问题描述】:

我正在尝试使用 Spring Boot 调用 Google BigQuery 存储过程(例程)。我尝试了例程的所有方法来提取数据。但是,它没有帮助。

有没有人通过 Spring 启动创建和调用 BigQuery 存储过程(例程)?如果有,怎么做?

【问题讨论】:

  • 请提供足够的代码,以便其他人更好地理解或重现问题。

标签: spring-boot google-bigquery


【解决方案1】:
public static Boolean executeInsertQuery(String query, TableId tableId, String jobName) {
    log.info("Starting {} truncate query", jobName);
    BigQuery bigquery = GCPConfig.getBigQuery(); // bqClient

 

    // query configuration
    QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query)
            .setUseLegacySql(false)
            .setAllowLargeResults(true)
            .setDestinationTable(tableId)     .setWriteDisposition(JobInfo.WriteDisposition.WRITE_TRUNCATE).build();


    try {
        // build the query job.
        QueryJob queryJob = new QueryJob.Builder(queryConfig).bigQuery(bigquery).jobName(jobName).build();

        QueryJob.Result result = queryJob.execute();
    

    } catch (JobException e) {
        log.error("{} unsuccessful. job id: {}, job name: {}. exception: {}", jobName, e.getJobId(),
                e.getJobName(), e.toString());
        return false;
    }

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-28
    • 1970-01-01
    • 2018-06-25
    • 2021-03-15
    • 1970-01-01
    相关资源
    最近更新 更多