繁体   English   中英

将数据流式传输到BigQuery时出现Java代码错误

[英]Java Code error while Streaming Data into BigQuery

我是Java的初学者。 您能告诉我为什么以下代码检测到错误,尽管我采用了以下Google网址中作为示例给出的完全相同的代码: https : //developers.google.com/bigquery/streaming-data-into-bigquery# streaminginsert示例

单词bigquery的底部为红色,错误为:bigquery无法解析。

我记得我想通过使用tabledata()。insertAll()方法一次将数据流式传输到BigQuery一条记录中。

这是我的代码:

import java.io.IOException;
import java.util.*;
import com.google.api.services.bigquery.*;
import com.google.api.services.bigquery.model.*;


public class sdz1 {

    public static void main(String[] args) {

        TableRow row = new TableRow();
        row.set("Average", 7.7);
        TableDataInsertAllRequest.Rows rows = new TableDataInsertAllRequest.Rows();
        rows.setInsertId(""+System.currentTimeMillis());
        rows.setJson(row);
        List  rowList = new ArrayList();
        rowList.add(rows);
        TableDataInsertAllRequest content = new TableDataInsertAllRequest().setRows(rowList);
        try
        {
            TableDataInsertAllResponse response = bigquery
                            .tabledata()
                            .insertAll("Vigicolis", "wi_vigicolis", "TestTable", content)
                            .execute();
            // TableDataInsertAllResponse response = new TableDataInsertAllResponse();
            // response.bigquery.tabledata().insertAll("Vigicolis", "wi_vigicolis", "TestTable", content).execute();
            System.out.println("Response: " + response);
        }
        catch (IOException e)
        {
            // handle
        }
    }

}

您缺少BigQuery的jar文件,该文件提供了运行此程序所需的必需软件包和类。 找到罐子,然后通过命令或在IDE中将其添加到类路径中。

罐子和罐子的Maven依赖关系链接也可以从此链接下载。

您需要创建bigquery对象。

例如:Bigquery bigquery = new Bigquery(new NetHttpTransport(),new JacksonFactory(),New AppIdentityCredential(SQLSERVICE_ADMIN));

暂无
暂无

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

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