support subqueries in JOIN (MARMOTTA-538)