MODE-1594 for prerequisite fix to get to this issue – without applying that fix the parser will break before the query executes and triggers this issue)
The INTERSECT and EXCEPT operations (and variants with the ALL flag set) are breaking.
INTERSECT enters an infinite loop upon the first successful compare since it never advances either iterator and the comparison always executes again on the first identical tuples.
EXCEPT throws an InvalidStateException on the second successful compare in a row, since in that state it will call Iterator.remove() a second time without having advanced.
None of the three classes extending SetOperationComponent (ExceptComponent, IntersectComponent, UnionComponent) have any test coverage that I noticed. I'm attaching a patch file with fixes to ExceptComponent and IntersectComponent, as well as a (very) basic testcase in a new file SetOperationComponentsTest.java.
MODE-1608 Intersect and Except query components breaking on successful comparisons