A query that references nested data may have sub-expressions included in a subquery for nested data to perform the query. A first query engine may rewrite the query to include one or more sub-expressions that reference the nested data into a subquery for the nested data as part of generating a plan to perform the query. A second query engine may then be caused to perform the subquery for the nested data. A result of the query may be inclusive of the performance of the subquery at the second query engine.