[Mondrian] Parenthesized queries in UNION

Julian Hyde jhyde at pentaho.com
Tue Dec 4 01:44:03 EST 2012


Tiago,

What was the error that made you make the following change, and on what database?

Before your change, the code used to generate

 SELECT ... ORDER BY UNION SELECT ... ORDER BY

and after your change generates

 (SELECT ... ORDER BY) UNION (SELECT ... ORDER BY)

ORDER BY inside a subquery is illegal per the SQL standard (and as it happens makes MongoDB's parser barf), so I wonder if that was the real problem you were facing. I am fixing it to generate

  (SELECT ...) UNION (SELECT ...) ORDER BY

and, since simpler is better, I wonder if I could go one step further and generate

  SELECT ... UNION SELECT ... ORDER BY

To help me decide, it would help to know why you added the parentheses in the first place.

Julian


More information about the Mondrian mailing list