javascript - 如何限制 BigQuery 获取的行数?
问题描述
我正在尝试使用 firebase 云功能从 BigQuery 表中获取一些数据到我的 React 前端。
我的表有 14000 多行,所以我不想同时把它们都带进来,我宁愿发送一个请求,一次得到 100 左右。
我在这里查看了文档:https ://cloud.google.com/bigquery/docs/managing-table-data#browse-table
但他们的解决方案似乎对返回的内容没有任何影响。
exports.getTableDataFromFrontEnd = functions.runWith(runtimeOpts).https.onCall((data, context) => {
console.log('V23');
let promise = new Promise(function(resolve, reject) {
async function browseRows() {
// Create a client
const bigqueryClient = new BigQuery();
const datasetId = 'CSV_Upload';
const tableId = 'Test_Table';
//Limit the query to 100 rows (This is not working).
const options = {
limit: 100
};
// List rows in the table
const [rows] = await bigqueryClient
.dataset(datasetId)
.table(tableId)
.getRows(options)
resolve(rows) //This still has 14000+ rows.
}
browseRows();
});
return promise;
});
解决方案
我不确定您使用的是什么库,但如果是这个库,那么选项的名称是maxResults
,而不是limit
。
推荐阅读
- scala - 过滤数据框中的日期范围
- r - 制作 ggplot 0,0 XY 坐标以与背景图像的特定点重合
- sql - 删除不起作用的地方
- c# - 如何使用 C# 在 Excel .xlsx 文件中基于行列组合在单元格中输入值?
- javascript - 我如何上传多个图像文件并在通过javascript上传后相应地查看它们,就像我在代码中所做的那样?
- node.js - 使用“$merge”时出现 Ajv 模式验证错误
- r - stringdist_semi_join 仅显示来自 dataframe1 的列
- android - 无法为 [type:Factory,primary_type:'yodgorbek.komilov.musobaqayangiliklari.viewmodel.MainViewModel' 创建实例?
- java - 没有文件 IO 的 AWS 凭证
- java - 如何在 JPA 中持久化与其他实体具有多对多关联的实体?