Ejemplo n.º 1
0
        public void UploadCsv_JobLabels()
        {
            var client = BigQueryClient.Create(_fixture.ProjectId);

            var tableReference = client.GetTableReference(_fixture.DatasetId, _fixture.CreateTableId());

            string[] csvRows =
            {
                "Name,GameStarted",
                "Ben,2014-08-19T12:41:35.220Z",
                "Lucy,2014-08-20T12:41:35.220Z",
                "Rohit,2014-08-21T12:41:35.220Z"
            };

            var         bytes  = Encoding.UTF8.GetBytes(string.Join("\n", csvRows));
            TableSchema schema = null;

            var job = client.UploadCsv(tableReference, schema, new MemoryStream(bytes),
                                       new UploadCsvOptions {
                Autodetect = true, Labels = JobsTest.JobLabels
            });

            JobsTest.VerifyJobLabels(job?.Resource?.Configuration?.Labels);

            job = job.PollUntilCompleted().ThrowOnAnyError();
            JobsTest.VerifyJobLabels(job?.Resource?.Configuration?.Labels);
        }
Ejemplo n.º 2
0
        public void SynchronousTemporaryQuery_JobLabels()
        {
            var projectId = _fixture.ProjectId;
            var client    = BigQueryClient.Create(projectId);
            var table     = client.GetTable(PublicDatasetsProject, PublicDatasetsDataset, ShakespeareTable);

            var sql     = $"SELECT corpus as title, COUNT(word) as unique_words FROM {table} GROUP BY title ORDER BY unique_words DESC LIMIT 10";
            var options = new QueryOptions {
                Labels = JobsTest.JobLabels
            };

            var queryJob = client.CreateQueryJob(sql, null, options);

            JobsTest.VerifyJobLabels(queryJob?.Resource?.Configuration?.Labels);

            queryJob.PollUntilCompleted().ThrowOnAnyError();
            JobsTest.VerifyJobLabels(queryJob?.Resource?.Configuration?.Labels);
        }