Apply iff


#1

Good afternoon,

I have trouble with IFF in SciDB 14.3. This is my array:

MODIS_AMZ_EVI2<red:int16,nir:int16,quality:uint16,evi2:double> [col_id=0:10,502,5,row_id=0:10,502,5,time_id=0:275,1,0]

But when I try to do something like this:

apply(MODIS_AMZ_EVI2, myField, iff(time_id > 270, 1, 0));

I get this error:

UserQueryException in file: src/query/Expression.cpp function: internalCompile line: 577
Error id: scidb::SCIDB_SE_QPROC::SCIDB_LE_FUNCTION_NOT_FOUND
Error description: Query processor error. Function 'iff(bool, int64, int64)' not found.
apply(MODIS_AMZ_EVI2, quarter, iff(time_id > 274, 1, 0))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
Failed query id: 1101184747159

I’m sure IFF is installed since it appears in the results of this query:

list('functions');

What I want to achieve is to populate a field depending on intervals over a single dimension: For example,

if 0 <= myDimension < 43 then myField = 1
if 43 <= myDimension < 200 then myField = 2

and so on. I’d like to know:

What am I doing wrong regarding IFF?
Can I include AND or && inside the IFF clause?
What is the best way to evaluate many intervals in a single AFL expression?

Thank you!


#2

It’s “iif”, not “iff”. We basically copied the T-SQL syntax - see http://msdn.microsoft.com/en-us/library/hh213574.aspx.

– Hygiene …
DROP ARRAY Foo;


– Create the array …
CREATE ARRAY Foo < val : int32 > [ I=0:99,100,0, J=0:99,100,0 ];


– Populate the array …
SELECT val INTO Foo FROM build ( Foo, I * 100 + J );


– Do some queries …
SELECT SUM ( iif ( val%2 = 0, 1, 0 ) )
FROM Foo;


#3

My mistake

Thank you!