datashield / dsBase

DataSHIELD server side base functions
GNU General Public License v3.0
9 stars 27 forks source link

Subsetting a table is broken in DSI / v6 branch #56

Open fdlk opened 4 years ago

fdlk commented 4 years ago

I have a table patient with column age. I want to subset the table to get all patients with age >= 40.

ds.subset(x = 'patient', subset = 'less_patients', logicalOperator = 'age>=', threshold = 40, datasources = conns)

Expected

A new table less_patients is created with the patients of age>=40. Or perhaps a message that I do not have enough patients to filter them.

Actual

I get an error message

Error: Command 'subsetDS("patient", FALSE, NULL, NULL, 2, 40, "age")' failed on 'opal-dsi': Error while evaluating 'is.null(base::assign('less_patients', value={dsBase::subsetDS("patient", FALSE, NULL, NULL, 2, 40, "age")}))' ->
Error in D[, 1] : object of type 'closure' is not subsettable
fdlk commented 4 years ago

See https://gist.github.com/fdlk/0b51a10758cd279c0d535aaba91aba48 for a script that reproduces this.

fdlk commented 4 years ago

@StuartWheater We investigated a bit and think this is caused by 698e2e509a91de1529b5d9fe1a0457a2752e2485. The D created here: https://github.com/datashield/dsBase/blob/fb61acdfc0c4753095888aa4480a9927c8c5de11/R/subsetDS.R#L54 does not exist in the global scope where the eval is executed. https://github.com/datashield/dsBase/blob/fb61acdfc0c4753095888aa4480a9927c8c5de11/R/subsetDS.R#L113 If we do create a D in the global scope, the method returns, but with incorrect results.

OllyButters commented 4 years ago

Thanks for the bug report @fdlk (and for the good description of how to reproduce it!).

This does seem like something for @StuartWheater but I'll also tag @davraam and @alexwesterberg in case they want in.

Thanks!

davraam commented 4 years ago

thanks @fdlk. You can try to subset your dataframe using our recently developed ds.dataFrameSubset function until we investigate and fix the issue with the ds.subset. Thanks!

StuartWheater commented 4 years ago

While trying to reproduce what is in https://gist.github.com/fdlk/0b51a10758cd279c0d535aaba91aba48 I found that my equivalent of 'datashield.assign.table(conns, "patient", "datashield.PATIENT")' was failing. If replaced by equivalent of 'datashield.assign(conns, "patient", as.symbol("datashield.PATIENT"))', the following "ds.submit" worked.

StuartWheater commented 4 years ago

@fdlk are you still seeing the same behavior with latest version of dsBase?