Hi, 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 https://github.com/apache/calcite/blob/56def3946d7e30706b2845464f7fc575c66e4694/linq4j/src/main/java/org/apache/calcite/linq4j/EnumerableDefaults.java#L3257 This is the code in MergeJoinEnumerator: if (c != 0) { assert c < 0 : "not sorted"; break; } 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 language). 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 ? Enrico
