Skip to content

Commit a02b9f7

Browse files
alixhamijmdobry
authored andcommitted
Updates region tags to standard and deletes unused region tags (#94)
1 parent a555860 commit a02b9f7

3 files changed

Lines changed: 6 additions & 92 deletions

File tree

handwritten/bigquery/samples/queries.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ function queryStackOverflow(projectId) {
7878
// [END bigquery_simple_app_all]
7979

8080
function syncQuery(sqlQuery, projectId) {
81-
// [START bigquery_sync_query]
8281
// Imports the Google Cloud client library
8382
const BigQuery = require('@google-cloud/bigquery');
8483

@@ -111,12 +110,10 @@ function syncQuery(sqlQuery, projectId) {
111110
.catch(err => {
112111
console.error('ERROR:', err);
113112
});
114-
// [END bigquery_sync_query]
115113
}
116114

117115
function asyncQuery(sqlQuery, projectId) {
118-
// [START bigquery_async_query]
119-
// [START bigquery_build_client]
116+
// [START bigquery_query]
120117
// Imports the Google Cloud client library
121118
const BigQuery = require('@google-cloud/bigquery');
122119

@@ -130,7 +127,6 @@ function asyncQuery(sqlQuery, projectId) {
130127
const bigquery = new BigQuery({
131128
projectId: projectId,
132129
});
133-
// [END bigquery_build_client]
134130

135131
// Query options list: https://cloud.google.com/bigquery/docs/reference/v2/jobs/query
136132
const options = {
@@ -171,7 +167,7 @@ function asyncQuery(sqlQuery, projectId) {
171167
.catch(err => {
172168
console.error('ERROR:', err);
173169
});
174-
// [END bigquery_async_query]
170+
// [END bigquery_query]
175171
}
176172

177173
require(`yargs`)

handwritten/bigquery/samples/system-test/tables.test.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -151,26 +151,6 @@ test.serial(`should extract a table to GCS`, async t => {
151151
.start();
152152
});
153153

154-
test(`should load a GCS file`, async t => {
155-
t.plan(1);
156-
const tableId = generateUuid();
157-
158-
const output = await tools.runAsync(
159-
`${cmd} load-gcs ${projectId} ${datasetId} ${tableId} ${bucketName} ${importFileName}`,
160-
cwd
161-
);
162-
t.regex(output, /completed\./);
163-
await tools
164-
.tryTest(async assert => {
165-
const [rows] = await bigquery
166-
.dataset(datasetId)
167-
.table(tableId)
168-
.getRows();
169-
assert(rows.length > 0);
170-
})
171-
.start();
172-
});
173-
174154
test(`should load a GCS CSV file with explicit schema`, async t => {
175155
t.plan(1);
176156
const tableId = generateUuid();

handwritten/bigquery/samples/tables.js

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -240,54 +240,6 @@ function loadLocalFile(datasetId, tableId, filename, projectId) {
240240
// [END bigquery_load_from_file]
241241
}
242242

243-
function loadFileFromGCS(datasetId, tableId, bucketName, filename, projectId) {
244-
// [START bigquery_load_from_gcs]
245-
// Imports the Google Cloud client libraries
246-
const BigQuery = require('@google-cloud/bigquery');
247-
const Storage = require('@google-cloud/storage');
248-
249-
/**
250-
* TODO(developer): Uncomment the following lines before running the sample.
251-
*/
252-
// const projectId = "your-project-id";
253-
// const datasetId = "my_dataset";
254-
// const tableId = "my_table";
255-
// const bucketName = "my-bucket";
256-
// const filename = "file.csv";
257-
258-
// Instantiates clients
259-
const bigquery = new BigQuery({
260-
projectId: projectId,
261-
});
262-
263-
const storage = new Storage({
264-
projectId: projectId,
265-
});
266-
267-
// Loads data from a Google Cloud Storage file into the table
268-
bigquery
269-
.dataset(datasetId)
270-
.table(tableId)
271-
.load(storage.bucket(bucketName).file(filename))
272-
.then(results => {
273-
const job = results[0];
274-
275-
// load() waits for the job to finish
276-
assert.equal(job.status.state, 'DONE');
277-
console.log(`Job ${job.id} completed.`);
278-
279-
// Check the job's status for errors
280-
const errors = job.status.errors;
281-
if (errors && errors.length > 0) {
282-
throw errors;
283-
}
284-
})
285-
.catch(err => {
286-
console.error('ERROR:', err);
287-
});
288-
// [END bigquery_load_from_gcs]
289-
}
290-
291243
function loadCSVFromGCS(datasetId, tableId, projectId) {
292244
// [START bigquery_load_table_gcs_csv]
293245
// Imports the Google Cloud client libraries
@@ -566,7 +518,7 @@ function extractTableToGCS(
566518
filename,
567519
projectId
568520
) {
569-
// [START bigquery_extract_gcs]
521+
// [START bigquery_extract_table]
570522
// Imports the Google Cloud client libraries
571523
const BigQuery = require('@google-cloud/bigquery');
572524
const Storage = require('@google-cloud/storage');
@@ -610,11 +562,11 @@ function extractTableToGCS(
610562
.catch(err => {
611563
console.error('ERROR:', err);
612564
});
613-
// [END bigquery_extract_gcs]
565+
// [END bigquery_extract_table]
614566
}
615567

616568
function insertRowsAsStream(datasetId, tableId, rows, projectId) {
617-
// [START bigquery_insert_stream]
569+
// [START bigquery_table_insert_rows]
618570
// Imports the Google Cloud client library
619571
const BigQuery = require('@google-cloud/bigquery');
620572

@@ -649,7 +601,7 @@ function insertRowsAsStream(datasetId, tableId, rows, projectId) {
649601
console.error('ERROR:', err);
650602
}
651603
});
652-
// [END bigquery_insert_stream]
604+
// [END bigquery_table_insert_rows]
653605
}
654606

655607
const fs = require(`fs`);
@@ -715,20 +667,6 @@ require(`yargs`)
715667
);
716668
}
717669
)
718-
.command(
719-
`load-gcs <projectId> <datasetId> <tableId> <bucketName> <fileName>`,
720-
`Loads data from a Google Cloud Storage file into a table.`,
721-
{},
722-
opts => {
723-
loadFileFromGCS(
724-
opts.datasetId,
725-
opts.tableId,
726-
opts.bucketName,
727-
opts.fileName,
728-
opts.projectId
729-
);
730-
}
731-
)
732670
.command(
733671
`load-gcs-csv <projectId> <datasetId> <tableId>`,
734672
`Loads sample CSV data from a Google Cloud Storage file into a table.`,

0 commit comments

Comments
 (0)