Tag: 谷歌 的BigQuery

Big Query insertAll()只插入最后一行

我试图在Big Query中使用名为bigquery的Node包将行插入到BigQuery中 ,它充当BQ API本身的包装,并使用insertAll()API调用。 但是,加载多个项目的数组时,实际上只将数组中的最后一个项目插入到表格中。

BigQuery Node.js api创build外部表

我正尝试使用node.js API从Google云端函数创build外部表格。 该function将从GCS桶更改中触发。 我可以创build一个本地表,但不能创build一个外部表。 在这里用于导入的node.js api中,configuration.load元数据没有设置来将其指定为外部表。 这里是我的代码本地表创build到现在。 我的问题是“如何使用Node.js Api为GCS存储桶创build外部表” const projectId = "N" const bigquery = BigQuery({ projectId: projectId }); const storage = Storage({ projectId: projectId }); const dataset = bigquery.dataset("dataset"); const table = dataset.table("test_data"); const bucket = storage.bucket("my-bucket"); const file = bucket.file("2017/03/02/*"); let job; // Imports data from a GCS file into a table […]

节点BigQuery apiResponse总是未定义的

我正在使用Google Cloud Node库的BigQuery API https://googlecloudplatform.github.io/google-cloud-node/#/docs/bigquery/0.9.0/bigquery 根据官方文档,“query”方法的callback函数应该返回一个名为apiResponse的对象。 但是,我总是获得价值 undefined 我试图直接查询数据集和bigquery对象,但我有相同的响应。 我需要这些信息才能获得执行查询的成本。

没有将数据stream式传输到BigQuery的错误响应

我有一个简单的nodejs脚本,它将数据插入到bigquery表中。 当数据input正确时,它就像一个魅力。 当数据input不正确时,我不会收到错误响应。 我如何处理错误响应? 'use strict' // Imports the Google Cloud client library const BigQuery = require('@google-cloud/bigquery'); //Instantiates a client const bigquery = BigQuery({ projectId: 'projectid', keyFilename: './credentials/cloudkey.json' }); const datasetId = 'datasetId' const tableId = 'test' const rows = [ {"data": "data"}, //correct row {"dtaa": "test"} // incorrect row ] insertRowsAsStream(datasetId, tableId, rows) .then( […]

删除重复项并设置为一个新表

我试图: 从表中查询重复的值 插入表中,删除所有以前的值。 现在我正在这样做: var table = dataset.table('CleanTable'); return bigquery .startQuery({ destination: table, query: <Query without duplicates> } ) 但之后,目的地表不会改变。 我怎样才能做到这一点? 谢谢!

BigQuery Node.js API startQuery不会将数据注入到destinationTable中

考虑下面的BQ查询: const sourceQuery = '#standardSQL SELECT station_id, time FROM bryans_bike_analysis_data.2016_status_data ' + 'WHERE SAFE_CAST(bikes_available as INT64)=0 AND SAFE_CAST(docks_available AS INT64)=0' + 'GROUP BY station_id, time'; 并考虑以下代码(放置在Google云端函数中 – 删除了一些内容,保持简短): bqSource.startQuery({ destination: bqDest.dataset(destDataset).table(destTable), query: sourceQuery }, function(err, job) { if (!err) { console.log("Succesfully initialized query"); job.getQueryResults(function(err, rows, apiResponse) { if (!err) { console.log("Successfully completed inner"); console.log(apiResponse); } […]

如何从bigquery没有分区获取所有表ID?

我正在使用node.js bigquery客户端库,并需要从数据集中获取表的列表,而不需要分区块。 例如,我有一些分区表: table1_20170101 table1_20170102 … table1_20170131 table2_20170101 table2_20170102 … table2_20170131 我需要得到[table1,table2]作为结果,但使用getTables方法我得到[table1_20170101,table1_20170102 …] 下面的脚本示例: dataset.getTables(function (err, tables) { let result = []; for (let key in tables) { result.push(tables[key].id); } console.log(result); res.send(result); }); 有没有可用的方法来获得“未分区”的表名? 如果有大量分区表,使用_date获取所有表,拆分并使其唯一似乎是非常缓慢的。

在API查询中找不到BigQuerydate函数

我得到一个ApiError:function未find:STRFTIME_UTC_USEC错误,当我尝试运行下面的查询使用node.js BQ API: SELECT STRFTIME_UTC_USEC(created, "%h %d %Y") as user_created from `tablePath` 根据BQ文档https://cloud.google.com/bigquery/docs/reference/legacy-sql#datetimefunctions ,functionSTRFTIME_UTC_USEC在BQ中可用。 事实上,相同的查询在BQ控制台网站上的查询生成器中工作(只需将表转义字符从“更改为[]]。 调用查询的代码如下所示: const BigQuery = require('@google-cloud/bigquery'); const sqlQuery = SELECT STRFTIME_UTC_USEC(created, "%h %d %Y") as user_created from `tablePath` const options = { query: sqlQuery, useLegacySql: false // Use standard SQL syntax for queries. }; bigquery.query(options) .then(function (results) { const rows = […]

如何使用Nodejs插入到BigQuery?

我想使用google-api-nodejs-client将行stream传输到Google BigQuery 。 挖掘源代码我发现我需要一个“资源”参数。 我尝试了几种组合,并去apirequest的来源,但我总是得到错误No rows present in the request. 我终于成功地与另一个npm模块一次上传一行,但是这个模块不支持tabledata.insertAll()。 你可以给一个例子,说明如何使用“资源”参数来stream插入? bigquery.tabledata.insertAll({ auth: oauth2Client, 'projectId': config.google.projectId, 'datasetId': config.google.datasetId, 'tableId': config.google.tableId, 'resource ': { "kind": "bigquery#tableDataInsertAllRequest", "rows": [ { "insertId": 123456, "json": '{"id": 123,"name":"test1"}' } ] } }, function(err, result) { if (err) { return console.error(err); } console.log(result); });

错误:在作业configuration中将allowLargeResults设置为true后仍然出现错误?

我在我的代码中写了bigquery。 我想获取更大的结果。 我也设置propertie allowLargeResult:true ,但是我仍然得到错误: 响应太大,不能返回。 考虑在作业configuration中将allowLargeResults设置为true。 有关更多信息,请参阅http://cloud.google.com/bigquery/troubleshooting-errors 这是我的Node.js代码: var google = require('googleapis'); var bigquery = google.bigquery('v2'); var authClient = new google.auth.JWT( 'arjun-dev@mybank-bigquery.iam.gserviceaccount.com', 'keyA.pem', null, ['https://www.googleapis.com/auth/bigquery']); var request2 = { projectId: 'project-bank', jobId:'job_LHMRhoUfM038QA4jPZHaOESI3Uo', startIndex: 0, maxResults: 100000, timeoutMs: 10000, configuration:{ allowLargeResults: true }, auth: authClient }; var list1 = bigquery.jobs.getQueryResults(request2, function(err, result) { if (err) […]