I'm trying to use @google-cloud/bigquery-storage
and it seems I can't get adapt
. This is what I'm trying to do.
const { v1, adapt } = require('@google-cloud/bigquery-storage');
const { BigQueryWriteClient } = v1;
const { BigQuery } = require('@google-cloud/bigquery');
async function BQStorageWrite() {
const bigquery = new BigQuery({ projectId: bqProjectId });
const dataset = bigquery.dataset(bqDataSetId);
const table = await dataset.table(bqTableId);
const [metadata] = await table.getMetadata();
console.log('adapt ' + adapt); // adapt undefined
console.log('v1 ' + v1); // v1 [object Object]
const storageSchema = adapt.convertBigQuerySchemaToStorageTableSchema(
metadata.schema
);
//Writing data to a BQ Table
}
adapt is undefined as per the console log, hence I get an error saying 'TypeError: Cannot read properties of undefined (reading 'convertBigQuerySchemaToStorageTableSchema')'
Am I missing something obvious here? What is the correct way to get this imported? Thank you.
@DbxD, As you have mentioned in the comment.
adapt
is not released into the library yet till the latest version@google-cloud/bigquery-storage v 3.3.0
. Hence we can't import it. It will be available in the next library release.For more information link1 and link2 can be referred.
Posting the answer as community wiki for the benefit of the community that might encounter this use case in the future.
Feel free to edit this answer for additional information.