【发布时间】:2015-11-11 08:46:32
【问题描述】:
我使用命令创建了一个名为“passthrough”的udf,
%%bigquery udf -m passthrough
function passthrough(row, emit) {
emit({outputA: row.inputA, outputB: row.inputB});
}
bigquery.defineFunction(
'passthrough',
['inputA', 'inputB'],
[{'name': 'outputA', 'type': 'string'},
{'name': 'outputB', 'type': 'string'}],
passthrough
);
然后,它返回了错误。
JavaScript 必须声明输入行和输出发射器 参数使用有效的 jsdoc 格式 cmets。输入行参数 声明必须输入为 {{field:type, field2:type}} 并且 输出发射器参数声明必须键入为 函数({{field:type, field2:type}}.
所以,我在透传功能上面加了jsdoc cmets,
/**
* @param {{field:string, field2:string}} row
* @param function({{field:string, field2:string}}) emit
*/
然后运行 sql 命令。但它仍然返回错误“Unknown TVF: passthrough”。
%%sql
SELECT outputA, outputB FROM (passthrough(SELECT "abc" AS inputA, "def" AS inputB))
如何声明参数,稍后在 datalab 上使用 UDF?
【问题讨论】:
标签: google-bigquery google-cloud-datalab