I have been trying to query from a temporary table (table definitions) that consists of google sheets data but I keep getting error in code.gs. Below is my code:
function test(){
var projectId = 'projectId';
var datasetId = 'datasetId';
var tableId = 'tableId';
var sheet_url = 'the_url_of_google_sheet';
var tableName = 'sheet_tab';
var tableProps = {
externalDataConfiguration:{
sourceUris: [sheet_url],
googleSheetOptions:{
skipLeadingRows: 1
},
sourceFormat: 'GOOGLE_SHEETS',
autoDetect: true
}
}
var tableDef = {};
tableDef[tableName] = tableProps;
var sql = 'SELECT * FROM ' +tableName+';';
var jobConfig = BigQuery.newJobConfigurationQuery();
jobConfig.destinationTable = {projectId : projectId, datasetId : datasetId,
tableId: tableId};
jobConfig.query = sql;
jobConfig.writeDisposition = 'WRITE_APPEND';
jobConfig.tableDefinitions = tableDef;
var queryR = BigQuery.Jobs.query(jobConfig, projectId)
}
The error message is 'TableName' could not be resolved, dataset name is missing.