S02028
错误代码
S02028
报错信息
Only one parameter can be passed to row reduction operation [xxx] when it is used with PIVOT BY. RefId:S02028
错误原因
在使用 pivot by 生成的表中,每个分组的结果只返回最后一个元素,即每个组中只有一个元素。因此,在 pivot by 查询中,select 子句中使用的 row 系列函数必须是单目函数,如果向该单目函数传入多个参数,将会报该错误。如下例:
sym = `C`MS`MS`MS`IBM`IBM`C`C`C
price= [49.6, 29.46, 29.52, 30.02, 174.97, 175.23, 50.76, 50.32, 51.29]
qty = [2200, 1900, 2100, , 6800, 5400, 1300, 2500, 8800]
timestamp = [09:34:07,09:35:42,09:36:51,09:36:59,09:35:47,09:36:26,09:34:16,09:35:26,09:36:12]
t = table(timestamp, sym, qty, price);
select rowSum(qty) from t pivot by sym, timestamp // allow
select rowSum(qty, price) from t pivot by sym, timestamp // error
解决方案
为 select 子句中的单目函数传入1个参数,或者重新修改脚本逻辑。