【问题标题】:400 Bad Request error attempting to load bigquery table from cloud store400 Bad Request 错误尝试从云存储加载 bigquery 表
【发布时间】:2013-03-24 12:57:00
【问题描述】:

我收到 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}
}

我使用此处的说明设置我的请求:Load data from Google Cloud Storage to BigQuery using Java 。实际代码如下:

  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 查询表,它使用服务帐户方法。

任何帮助将不胜感激。

【问题讨论】:

  • 回答了我自己的问题。请求的架构部分中指定的字段类型必须小写:字符串而不是字符串。

标签: google-bigquery


【解决方案1】:

请求的架构部分中指定的字段类型必须是小写:字符串而不是字符串

【讨论】:

    【解决方案2】:

    异常代码 400 表示 billingTierLimitExceeded

    当您尝试执行超出项目最大计费层级的高计算查询时返回此错误。

    疑难解答:减少每个输入字节完成的计算次数或启用高计算查询以允许每个字节进行更多计算。

    你可以参考这里Troubleshooting Errors

    【讨论】:

      猜你喜欢
      • 2013-01-29
      • 2019-06-19
      • 2017-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-18
      相关资源
      最近更新 更多