Skip to content

Copying multiple source tables using table.copy #2278

@friend0

Description

@friend0

In the BigQuery Docs' REST reference, for a copy job, one may specify a single sourceTable object, or a list of tables as sourceTables. It looks like it's currently not possible to specify sourceTables using the NodeAPI's copy method. Instead, we have to post a much more verbose REST request like:

const copyJob = await new Promise((resolve, reject) => {
	bigQuery.request({
		method: 'POST',
		uri: '/jobs',
		json: {
			configuration: {
				copy: {
					sourceTables,
					destinationTable: {
						datasetId: table.dataset.id,
						projectId: table.bigQuery.projectId,
						tableId: table.id,
					},
					writeDisposition: overwrite ? 'WRITE_TRUNCATE' : 'WRITE_APPEND',
				},
			},
		},
	}, (err, resp) => {
		if (err) {
			return reject(err);
		}

		const job = bigQuery.job(resp.jobReference.jobId);
		job.metadata = resp;

		resolve(job);
	});
});

I'd like to request a feature on the Node API's copy function that allows us to specify multiple source tables ala sourceTables. Cheers!

Environment details

  • OS: MacOs Sierra v. 10.12.4
  • Node.js version: 7.7.3
  • npm version: 4.1.2
  • google-cloud/storage: 1.1.0

Metadata

Metadata

Labels

api: bigqueryIssues related to the BigQuery API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions