[Mondrian] NULL literal

Julian Hyde julianhyde at speakeasy.net
Wed Feb 28 15:04:21 EST 2007


> Richard wrote:
>
> So I assume that for expressions like a+b,a-b,a*b,a/b if either
> a or b are NULL then:
> NULL+b == b
> a + NULL == a
> NULL - b == -b
> a - NULL == a
> a*NULL == NULL
> NULL*b == NULL
> a/NULL == NULL
> NULL/b == NULL
> and if both are NULL then the result is NULL.

Some of those are inconsistent with SQL, so they are surprising.  SQL
operators (with very few exceptions like the IS NULL operator) return
null if either of their operands are null.

So,

  a + NULL == NULL

and, for string operations,

  a || NULL == NULL

(which is very confusing to Oracle users!)

I this illustrates that specifications, even those written by Mosha, are
too malleable. The process I'd like to follow with this is to use
testcases. Until I see a query to illustrate each of these rules which I
can run against MSAS, and that query as a testcase in mondrian's test
suite, I will be skeptical that anything is the 'correct' behavior.

Richard, How to proceed? Shall I log a bug 'more tests for operations on
NULL and EMPTY values required' and assign to you?

I realise that this process requires that people have access to MSAS. If
that's a problem, I can get such a server set up and accessible via VNC.
(It would be for committers only, obviously.) Let me know.

> Michael wrote:
>
> As for the 'IS NULL' construct, that's to test Member expression and
> numeric expression for having the NULL value given that NULL=NULL
> yields false.

Is there a construct to test whether a scalar value is NULL? It will
make it easier to write these tests. We've been printing out values and
seeing whether you get an empty string, which is very error-prone.

> Michael wrote:
>
> You can also use NULL explicitly in Range function:
> [Time].[1997].FirstChild : NULL

Michael, I don't think Mondrian supports that. Can you log a bug?

> Richard wrote:
>
> The NULL Literal when compiled become an ConstantCalc
> instance.
> The change I believe is needed is in the ConstantCalc
> constructor. If the constructor parameter 'o' which
> is of type Object is a Java null, then the instance
> variables have the values:
> 
> Object o = null;
> int i = FunUtil.IntegerNull
> double d = FunUtil.DoubleNull

Sounds reasonable. If this code change makes the testcases pass, I'll be
happy.

Julian




More information about the Mondrian mailing list