Exemplo n.º 1
0
        public void PopulateTable(
            string query, string datasetId, string newTableId, BigQueryClient client)
        {
            var         destination = client.GetTableReference(datasetId, newTableId);
            BigQueryJob job         = client.CreateQueryJob(query,
                                                            new QueryOptions {
                DestinationTable = destination
            });

            // Wait for the job to complete.
            job.GetQueryResults();
        }
Exemplo n.º 2
0
        // [START copy_table]
        public void CopyTable(
            string datasetId, string tableIdToBeCopied, string newTableId, BigQueryClient client)
        {
            var         table       = client.GetTable(datasetId, tableIdToBeCopied);
            string      query       = $"SELECT * FROM {table}";
            var         destination = client.GetTableReference(datasetId, newTableId);
            BigQueryJob job         = client.CreateQueryJob(query,
                                                            new QueryOptions {
                DestinationTable = destination
            });

            // Wait for the job to complete.
            job.GetQueryResults();
        }
Exemplo n.º 3
0
        public async Task GetQueryResults_NonQuery()
        {
            var resource = new Job
            {
                JobReference = new JobReference {
                    ProjectId = "project", JobId = "job"
                },
                Configuration = new JobConfiguration
                {
                    Copy = new JobConfigurationTableCopy {
                    }
                }
            };
            var job = new BigQueryJob(new SimpleClient(), resource);

            Assert.Throws <InvalidOperationException>(() => job.GetQueryResults());
            await Assert.ThrowsAsync <InvalidOperationException>(() => job.GetQueryResultsAsync());
        }
Exemplo n.º 4
0
        public async Task GetQueryResults_NoJobReference()
        {
            var resource = new Job
            {
                Configuration = new JobConfiguration
                {
                    DryRun = true,
                    Query  = new JobConfigurationQuery {
                        DestinationTable = new TableReference {
                            ProjectId = "project", DatasetId = "dataset", TableId = "table"
                        }
                    }
                }
            };
            var job = new BigQueryJob(new SimpleClient(), resource);

            Assert.Throws <InvalidOperationException>(() => job.GetQueryResults());
            await Assert.ThrowsAsync <InvalidOperationException>(() => job.GetQueryResultsAsync());
        }