protected Query parseQuery( TokenStream tokens,
TypeSystem typeSystem ) {
AtomicBoolean isDistinct = new AtomicBoolean(false);
List<ColumnExpression> columnExpressions = parseSelect(tokens, isDistinct, typeSystem);
Source source = parseFrom(tokens, typeSystem);
Constraint constraint = parseWhere(tokens, typeSystem, source);
// Parse the order by and limit (can be in any order) ...
List<Ordering> orderings = parseOrderBy(tokens, typeSystem, source);
Limit limit = parseLimit(tokens);
if (orderings == null) parseOrderBy(tokens, typeSystem, source);