The geographic location of the table, bydefault this value is inherited from the dataset. This can be used toconfigure the location of all jobs created through a table instance. Itcannot be used to set the actual location of the table. This value willbe superseded by any API responses containing location data for thetable.
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('my-dataset');const table = dataset.table('my-table');table.createReadStream(options) .on('error', console.error) .on('data', row => {}) .on('end', function() { // All rows have been retrieved. });//-// If you anticipate many results, you can end a stream early to prevent// unnecessary processing and API requests.//-table.createReadStream() .on('data', function(row) { this.end(); });```
Metadata to set with the load operation.The metadata object should be in the format of theconfiguration.loadproperty of a Jobs resource. If a string is given,it will be used as the filetype.
Properties
Name
Type
Attributes
Description
jobId
string
<optional>
Custom job id.
jobPrefix
string
<optional>
Prefix to apply to the job id.
Returns:
Type
Description
WritableStream
Throws:
If source format isn't recognized.
Type
Error
Example
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('my-dataset');const table = dataset.table('my-table');//-// Load data from a CSV file.//-const request = require('request');const csvUrl = 'http://goo.gl/kSE7z6';const metadata = { allowJaggedRows: true, skipLeadingRows: 1};request.get(csvUrl) .pipe(table.createWriteStream(metadata)) .on('job', (job) => { // `job` is a Job object that can be used to check the status of the // request. }) .on('complete', (job) => { // The job has completed successfully. });//-// Load data from a JSON file.//-const fs = require('fs');fs.createReadStream('./test/testdata/testfile.json') .pipe(table.createWriteStream('json')) .on('job', (job) => { // `job` is a Job object that can be used to check the status of the // request. }) .on('complete', (job) => { // The job has completed successfully. });```
You may optionally use this to "get or create" an object by providingan object withautoCreate set totrue. Any extra configuration thatis normally required for thecreate method must be contained withinthis object as well.
If you wish to get a selection of metadata instead of the full table metadata(retrieved by both Table#get by default and by Table#getMetadata), usetheoptions parameter to set theview and/orselectedFields query parameters.
Wrap valuesof 'INT64' type inBigQueryInt objects.If aboolean, this will wrap values inBigQueryInt objects.If anobject, this will return a value returned bywrapIntegers.integerTypeCastFunction.
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('my-dataset');const table = dataset.table('my-table');table.getRows((err, rows) => { if (!err) { // rows is an array of results. }});//-// To control how many API requests are made and page through the results// manually, set `autoPaginate` to `false`.//-function manualPaginationCallback(err, rows, nextQuery, apiResponse) { if (nextQuery) { // More results exist. table.getRows(nextQuery, manualPaginationCallback); }}table.getRows({ autoPaginate: false}, manualPaginationCallback);//-// If the callback is omitted, we'll return a Promise.//-table.getRows().then((data) => { const rows = data[0]; });```