This query against an empty Journal produces the stack trace listed below. The problem appears to be that a named solution set is generated by a bottom up rewrite of the query. There is probably an intermediate layer of this query that is forcing the bottom-up rewrite. It is that bottom-up rewrite that is hitting the problem. I would check to make sure that you do not have variables that have the same name in the top and bottom groups in this query that do not also appear in the intermediate levels. That is what forces a bottom up rewrite. This is also nearly always an error in the query.