将数据从Google云端存储加载到GoogleBigQuery

时间:2018-02-21 10:03:45

标签: c# google-bigquery google-cloud-storage

我将数据从存储在Google Cloud中的json文件上传到BigQUery Table但我收到的错误

未找到:URI gs://encoreteststorage/Myfolder/TestDataJson.json

云中的文件位置 - >桶/ encoreteststorage / MyFolder文件

存储桶URI不正确(存储桶名称,文件夹和文件名是否正确)还是存在其他问题?

我拥有bigquery数据集的权限,因为我可以使用BigQueryTable UploadJson方法直接从本地系统将数据上传到BigQuery。

CodeSnippet

public IEnumerable<ErrorInfo> ImportDataFromCloudStorage(string uri, WriteDisposition disposition = WriteDisposition.WriteAppend)
{
    TableReference reference = new TableReference
    {
        DatasetId = "TestDataset",
        TableId = "UploadDatafromCloud",
        ProjectId = _projectId
    };

    BigQueryClient client = BigQueryClient.Create(_projectId, _googleCredential);

    BigQueryJob job = client.CreateLoadJob(uri, reference, null, new CreateLoadJobOptions()
    {

        WriteDisposition = disposition,
        SourceFormat = FileFormat.NewlineDelimitedJson,
        CreateDisposition = CreateDisposition.CreateIfNeeded
    });

    job.PollUntilCompleted();

    return CheckJobStatus(client, job.Reference);
}

0 个答案:

没有答案