[Mondrian] DialectTest.assertQueryFails() behavior question

Julian Hyde jhyde at pentaho.com
Fri Feb 22 19:54:52 EST 2013

On Feb 22, 2013, at 11:18 AM, Curtis Boyden <cboyden at pentaho.com> wrote:

> I have a case where the dialect has allowsCountDistinct() returning
> false, even though the database supports this.
> My question is what should happen when assertQueryFails() is called but
> the query actually succeeds?
> My assumption was that the unit test would fail to let us know that the
> dialect is incorrect, or that something has changed regarding the database.
> What I am actually seeing is that the unit test passes because the
> errors are only looked up when an exception is thrown / caught.
> The only possibility I see, if my assumption is correct, is that
> assertTrue(resultSet.next()); (in assertQueryFails() on line 866) should
> actually be assertFalse(...) thus indicating that we have received an
> empty resultset.
> Can someone please clarify for me the expected behavior of assertQueryFails() when the query succeeds?

I think your hunch is correct. assertQueryFails should fail if the query doesn't throw an exception, but it succeeds. I wrote that method, and I don't think it ever worked.


            Object col1 = resultSet.getObject(1);


            throw new AssertionFailedError(
                "query [" + sql + "] was expected to fail but did not; "
                + "got result set " + resultSet
                + "; probably dialect is incorrect about the capabilities of "
                + "this database version");

and see what happens. You may cause DialectTest to fail for several databases, in which case we should fix them one by one as they come up.

The good news is that we will discover places where dialects are too pessimistic, and after we fix the dialects Mondrian will start generating better & maybe more efficient SQL.


More information about the Mondrian mailing list