Extracting number from singleton array?


#1

Am I correct in thinking that the second parameter of build() must be an expression that evaluates to a numeric value? If this is the case, is there a way to extract a single numeric value from a 1x1 numeric array?

Suppose, for example, I’d like to use an AFL expression as the expression parameter of build(), an AFL expression that evaluates to a 1x1 singleton array. SciDB throws an error when I try to run the query, stating that it expects a number as the parameter, not an array.

Any suggestions appreciated, thanks, Patrick


#2

Yes.

[quote=“pleyshock”]If this is the case, is there a way to extract a single numeric value from a 1x1 numeric array?
Suppose, for example, I’d like to use an AFL expression as the expression parameter of build(), an AFL expression that evaluates to a 1x1 singleton array. SciDB throws an error when I try to run the query, stating that it expects a number as the parameter, not an array.[/quote]

Currently nested queries/array expressions not supported in scalar expressions. I think it will be supported in next releases along with full featured aggregates. For now I see only one way to emulate such feature: you can create scalar function which will be take array name as parameter and directly access to storage/network to fetch cell value and return it as result of function. Yes it’s ugly but must work.


#3

Thanks for the fast response, I’ll see what I can do!

Patrick