从appengine上传到bigquery时如何忽略未知值

时间:2022-03-02 15:09:40

I'm trying to upload data to bigquery in appengine.

我正在尝试将数据上传到appengine中的bigquery。

here is my code using the api from this streaming sample

这是我使用此流媒体示例中的api的代码

@Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {

    String projectId = "myprojectId";
    String datasetId = "mydatasetId";
    String tableId = "person";
    System.out.println("Enter JSON to stream to BigQuery: \n" + "Press End-of-stream (CTRL-D) to stop");

    String string = "[\n  {\"Name\": \"test\", \"Age\": 0, \"Weight\": 100.0, \"IsMagic\": false},\n  {\"Name\": \"test\", \"Age\": 1, \"Weight\": 100.0, \"IsMagic\": false},\n  {\"Name\": \"test\", \"Age\": 2, \"Weight\": 100.0, \"IsMagic\": false},\n  {\"Name\": \"test\", \"Age\": 3, \"Weight\": 100.0, \"IsMagic\": false},\n  {\"Name\": \"test\", \"Age\": 0, \"Weight\": 100.0, \"IsMagic\": false}\n]";
    JsonReader jsonReader = new JsonReader(new StringReader(string));

    Iterator<TableDataInsertAllResponse> responses = StreamingSample.run(projectId, datasetId, tableId, jsonReader);

    while (responses.hasNext()) {
        log.info(responses.next());
    }

    jsonReader.close();


}

now how can I make big query ignoreUnknownValues? is there any library I can use for that?

现在我怎样才能使大查询ignoreUnknownValues?我可以使用任何图书馆吗?

1 个解决方案

#1