Jep 3.3: Evaluator.setTrapNullValues(false) doesn't seem to be working

45 views
Skip to first unread message

Eric

unread,
Dec 17, 2008, 11:48:20 AM12/17/08
to JEP Users
I just upgraded to jep 3.3 from 3.2 and when setting setTrapNullValues
(false) on either FastEvaluator or StandardEvaluator it doesn't seem
to be working. If I pass in a value that is null & call the evaluate()
method on my Jep instance, I am getting the following exception:

com.singularsys.jep.functions.IllegalParameterException: *: lllegal
parameters null, 0.0(Double)

When I switch back to Jep 3.2 with the exact same expressions & data
everything works fine. Am I missing something?

Richard Morris

unread,
Dec 18, 2008, 1:03:03 PM12/18/08
to jep-...@googlegroups.com

It looks like your trying to evaluate an expression "null * 0.0" the
exception is being raised in the com.singularsys.jep.functions.Multiply
(*) function which does not know how to multiply by null. This does seem
to be the correct behaviour.

The internal type checking of many functions has changed and they now
typically throw IllegalParameterException rather than
EvaluationException. The former is a subclass of the latter so existing
code should work.

I'm not quite sure why your getting changes between 3.2 and 3.3 here.

Rich


--
Richard Morris
Web: www.singsurf.org www.pfaf.org
Email: ri...@singsurf.org
Tel: (+44) 01208 872963
Post: 1 Lerryn View, Lerryn, Lostwithiel, Cornwall, PL22 0QJ

Richard Morris

unread,
Dec 22, 2008, 4:15:33 AM12/22/08
to jep-...@googlegroups.com
Richard Morris wrote:
> Eric wrote:
>> I just upgraded to jep 3.3 from 3.2 and when setting setTrapNullValues
>> (false) on either FastEvaluator or StandardEvaluator it doesn't seem
>> to be working. If I pass in a value that is null & call the evaluate()
>> method on my Jep instance, I am getting the following exception:
>>
>> com.singularsys.jep.functions.IllegalParameterException: *: lllegal
>> parameters null, 0.0(Double)
>>
>> When I switch back to Jep 3.2 with the exact same expressions & data
>> everything works fine. Am I missing something?
>
> It looks like your trying to evaluate an expression "null * 0.0" the
> exception is being raised in the com.singularsys.jep.functions.Multiply
> (*) function which does not know how to multiply by null. This does seem
> to be the correct behaviour.

Thinking about this I wonder what the preferred behaviour for null would
be. In a database or spreadsheet application the behaviour for
arithmetic seems to be that any operation using null results in a null
result so "null * 0" would be null. Is this what you would like?

Eric

unread,
Jan 5, 2009, 7:53:40 AM1/5/09
to JEP Users
Sorry for the delay in getting back to you but I have been out on
vacation for a few weeks...

I believe in the 3.2 version if I try and multiply null * anything I
would get null back. Now in 3.3 I am getting an exception which is
going to force me to make a code change to handle the exception. I
would prefer just to get a null result back to set back to my data
set. This is what version 3.2 does using the StandardEvaluator.
Because I am explicitly calling setTrapNullValues(false) I would
expect to be able to pass in null arguments and have the expression be
evaluated appropriately.

-Eric
> Email: r...@singsurf.org
> Tel: (+44) 01208 872963
> Post:  1 Lerryn View, Lerryn, Lostwithiel, Cornwall, PL22 0QJ- Hide quoted text -
>
> - Show quoted text -

Richard Morris

unread,
Jan 7, 2009, 5:24:59 PM1/7/09
to jep-...@googlegroups.com
> From: Eric
> Date: Mon, Jan 5, 2009 at 12:53 PM
> Subject: [jep-users] Re: Jep 3.3: Evaluator.setTrapNullValues(false)

> doesn't seem to be working
> To: JEP Users <jep-...@googlegroups.com>

>
> Sorry for the delay in getting back to you but I have been out on
> vacation for a few weeks...

Likewise, still getting into the swing of the new year.

> I believe in the 3.2 version if I try and multiply null * anything I
> would get null back. Now in 3.3 I am getting an exception which is
> going to force me to make a code change to handle the exception. I
> would prefer just to get a null result back to set back to my data
> set. This is what version 3.2 does using the StandardEvaluator.
> Because I am explicitly calling setTrapNullValues(false) I would
> expect to be able to pass in null arguments and have the expression be
> evaluated appropriately.
>
> -Eric

I'm working on a solution to the problem at the moment. Its not really a
problem with the evaluator more with the individual functions. To solve
it I've created wrapper functions which test for null values on input
and return null if found, otherwise they use the wrapped function for
evaluation. Most but not all functions want this behaviour. I'm still
working on the code at the moment but its not fully tested yet.

I've not been able to reproduce the null * anything == null behaviour in
the 3.2.


Rich
--
Richard Morris
Web: www.singsurf.org www.pfaf.org

Email: ri...@singsurf.org

Reply all
Reply to author
Forward
0 new messages