Bug 3929 - R aggregate not recognized when using 3 or more parameters
Summary: R aggregate not recognized when using 3 or more parameters
Status: RESOLVED FIXED
Alias: None
Product: SQL
Classification: Unclassified
Component: all (show other bugs)
Version: 11.21.13 (Jul2015-SP2)
Hardware: x86_64 (amd64/em64t) Linux
: Normal normal
Assignee: SQL devs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-23 16:13 CET by tim.brown
Modified: 2016-04-11 11:16 CEST (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tim.brown 2016-02-23 16:13:11 CET
User-Agent:       Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
Build Identifier: 

Creating an embedded R aggregate with 3 or more parameters succeeds, but the aggregate is then not recognized in SELECT queries. Error message:

Error: SELECT: no such operator 'r_sw'
SQLState:  22000
ErrorCode: 0

In my example, I am trying to create a sliding window sum

Reproducible: Always

Steps to Reproduce:
1.
CREATE AGGREGATE r_sw(val double, part varchar(255), endtime timestamp, starttime timestamp) RETURNS double LANGUAGE R {
	library(data.table)
	library(zoo)
	DT=data.table(ag=aggr_group,pa=part,va=val,et=endtime,st=starttime)
	setorder(DT,pa,et)
	DT[, o:=mapply(function(x,y) DT[(et>=x & pa==y),.N], DT$st, DT$pa)]
	as.data.frame(DT[,.(s:=rollapply(va,o,sum), by=pa)]$s)
};

2.
SELECT id, mygroup, r_sw(myval,mygroup,myend,mystart) from mytable group by id, mygroup

Actual Results:  
Error: SELECT: no such operator 'r_sw'
SQLState:  22000
ErrorCode: 0

Expected Results:  
Any resultset.
Comment 1 Niels Nes cwiconfidential 2016-03-30 13:53:39 CEST
for 3 and more arguments general aggregates weren't handled at all. This is fixed, now an error in the R code or R binding is coming up.
Comment 2 Sjoerd Mullender cwiconfidential 2016-04-11 11:16:12 CEST
Jul2015-SP4 has been released.