How to use app script to run a google big query and save the results in a new table in the same project folder on google big query
It will look like this:
function saveQueryToTable() {
var projectId = 'your project';
var datasetId = 'your dataset';
var tableId = 'your table';
var job = {
configuration: {
query: {
query: 'SELECT TOP(word, 300) AS word, COUNT(*) AS word_count' +
'FROM publicdata:samples.shakespeare' +
'WHERE LENGTH(word) > 10;',
destinationTable: {
projectId: projectId,
datasetId: datasetId,
tableId: tableId
}
}
}
};
var queryResults = BigQuery.Jobs.insert(job, projectId);
Logger.log(queryResults.status);
}
More examples here.