-
-
Notifications
You must be signed in to change notification settings - Fork 168
Getting a marshalling error when trying to truncate or delete from a table #186
Copy link
Copy link
Open
Description
I am trying to delete data from a table and getting an error:
"json: cannot unmarshal number into Go struct field JobConfiguration.JobTimeoutMs of type string".
The error is thrown on 'bigqueryClient.createQueryJob(options)' step
Not sure what is the case as the schema specifies only a string field, and the data that is inserted doesn't contain any number to be marshalled to INT64. I am able to select the data, the inserted row is returned, the issue happens only when trying to delete.
Here is the code:
import { BigQuery } from '@google-cloud/bigquery';
async function testBigqueryEmulator() {
const datasetId = 'my-dataset';
const tableId = 'my-table';
const schema = 'name:string';
const data = [
{name: 'Tom'},
{name: 'Jane'},
];
const bigqueryClient = new BigQuery({
projectId: 'component-test',
apiEndpoint: 'http://0.0.0.0:9050'
});
// Create the dataset
const [dataset] = await bigqueryClient.createDataset(datasetId);
const table = dataset.table(tableId);
await table.create({schema});
await table.insert(data);
// truncate table
const query = `DELETE FROM \`${datasetId}.${tableId}\` WHERE 1=1`;
// const query = `select * FROM \`${datasetId}.${tableId}\``; / this works
const options = {
query,
useLegacySql: false,
jobTimeoutMs: 60000,
};
const [job] = await bigqueryClient.createQueryJob(options);
const [rows] = await job.getQueryResults();
return rows;
}
(async () => {
await testBigqueryEmulator();
})();
Emulator version: 0.3.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels