从客户端脚本从Big Query加载数据

时间:2019-01-09 20:22:55

标签: javascript google-apps-script google-bigquery google-app-maker

我在App Maker应用中创建了一个计算源,该源从Big Query读取数据,效果很好。现在,我想在用户事件上加载数据,因此我编写了一个函数:

function ButtonClick() {
 var Objekt = google.script.run.runQuery('Select ... Limit 100;');
  return Objekt;
}

function runQuery(Query) {
  var projectId = 'en-int-biggi';
  var request;
  request = {
    query: Query,useLegacySql: false};
  var queryResults = BigQuery.Jobs.query(request, projectId);
  var jobId = queryResults.jobReference.jobId;
  var names = queryResults.schema.fields.map(function(field){ return field.name; }); 
  return queryResults.rows.map(function(row) {
   //App Maker doesn't allow to return arbitrary objects through its datasources. All results should be strongly typed:
  var record = app.models.Firma.newRecord();
  for (var i = 0, len = names.length; i < len; ++i) {
     // Calculated model should contain correspondent fields
    // all non-defined fields will be ignored
    record[names[i]] =  (row.f[i].v);
  }
    console.log(record);
    return record;
});
}

通过Button Click调用该函数会出现错误:

  

返回的日志由于其长度而被删节。       周期性对象无法处理。

0 个答案:

没有答案