[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[DISCUSS] Problem with 'assert' ignored in production, leading to inconsistent query results

one of my customer got into a very weird situation when a merge join
was returning less results than expected.

Reproducing the issue on a unit test the query execution resulted in
an assertion error so that is was easy to find the problem (a bug in
the top level application in this case).

This is the case

This is the code in MergeJoinEnumerator:

if (c != 0) {
    assert c < 0 : "not sorted";

I am reaching dev list because I would like to raise the discussion
about this kind of assertions, which in my opinion should be turned
into explicit invariant checks to be executed even in production code.

IMHO it is better to have something that fails instead of something
which return non accurate results silently (SQL is not an approximate

It there is agreement I will scan Calcite codebase and look for
potential "assert" to be turned into explicit checks which will throw
IllegalStateException (or other runtime exception).

Thoughts ?