3

400の不正な要求エラーが発生します:

スレッド「メイン」の例外com.google.api.client.googleapis.json.GoogleJsonResponseException:400不正なリクエスト

{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Bad Request",
    "reason" : "badRequest"
  } ],
  "message" : "Bad Request"
}

完全なリクエストを確認する方法はわかりませんが、JobのtoPrettyString()メソッドを使用すると次のようになります。

{configuration=
  {load=
    {
      createDisposition=CREATE_IF_NEEDED, 
      destinationTable={
        datasetId=vcf1, 
        projectId=x8-alien-rainfall-3, 
        tableId=NewTable
      }, 
      encoding=UTF-8,
      maxBadRecords=10, 
      schema={
        fields=[
          {name=sample_id, type=String}, 
          {name=chromosome, type=String}, 
          {name=start_pos, type=Integer}, 
          {name=end_pos, type=Integer}, 
          {name=reference, type=String}, 
          {name=observed, type=String}, 
          {name=quality, type=Float}, 
          {name=filter, type=String}, 
          {name=zygosity, type=String}, 
          {name=refGene_function, type=String}
        ]
      }, 
      skipLeadingRows=1, 
      sourceUris=[gs://vcfs/test_exome_part1.csv]
    }
  }, 
  jobReference={projectId=x8-alien-rainfall-3}
}

次の手順を使用してリクエストを設定します:Javaを使用してGoogleCloudStorageからBigQueryにデータを読み込みます。実際のコードを以下に示します。

  public static void loadCsvAsNewTable(Bigquery bigquery,
                                Integer skipLeadingRows,
                                Integer maxBadRecords)
      throws IOException {

    String encoding = "UTF-8";
    String csvFile = "gs://vcfs/test_exome_part1.csv";
    String datasetId = "vcf1";
    String tableId = "NewTable";

    Job insertJob = new Job();
    insertJob.setJobReference(new JobReference().setProjectId(PROJECT_ID));
    JobConfiguration config = new JobConfiguration();
    JobConfigurationLoad loadConfig = new JobConfigurationLoad();
    config.setLoad(loadConfig);

    List<String> sources = new ArrayList<String>();
    sources.add(csvFile);
    loadConfig.setSourceUris(sources);

    TableReference destinationTable = new TableReference();
    destinationTable.setDatasetId(datasetId);
    destinationTable.setTableId(tableId);
    destinationTable.setProjectId(PROJECT_ID);
    loadConfig.setDestinationTable(destinationTable);
    loadConfig.setSchema(tableSchema());
    loadConfig.setCreateDisposition("CREATE_IF_NEEDED");

    if (skipLeadingRows != null) {
      loadConfig.setSkipLeadingRows(skipLeadingRows);
    }
    if (maxBadRecords != null) {
      loadConfig.setMaxBadRecords(maxBadRecords);
    }

    loadConfig.setEncoding(encoding);
    config.setLoad(loadConfig);
    insertJob.setConfiguration(config);

    System.out.println(insertJob.toPrettyString());

    Insert insert = bigquery.jobs().insert(PROJECT_ID, insertJob);
    insert.setProjectId(PROJECT_ID);

    println("Starting load job.");
    Job job = insert.execute();
    if (isJobRunning(job)) {
      Job doneJob = waitForJob(bigquery, PROJECT_ID, job.getJobReference());
      println("Done: " + doneJob.toString());
    } else {
      println("Error: " + job.toString());
    }
  }

サービスアカウントアプローチを使用する同じGoogleCredentialを使用してテーブルをクエリできます。

どんな援助でも大歓迎です。

4

2 に答える 2

2

リクエストのスキーマ部分で指定されるフィールドタイプは小文字である必要があります:文字列ではなく文字列

于 2014-10-03T17:45:12.350 に答える
1

例外コード400はbillingTierLimitExceededを示します。

このエラーは、プロジェクトの最大請求階層を超える高計算クエリを実行しようとすると返されます。

トラブルシューティング:入力バイトごとに実行される計算の数を減らすか、高計算クエリを有効にして、バイトごとにより多くの計算を許可します。

ここでエラーのトラブルシューティングを参照できます

于 2017-02-13T19:22:33.257 に答える