@@ -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-
291243function 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
616568function 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
655607const 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