You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sqlite: transform CROSS APPLY to projection when possible #34375
EF translates the inner Select to a CROSS APPLY, with OPENJSON (on SQL Server) to extract the JSON data as relational for materialization:
SELECT [c].[Id], [c].[Name], JSON_VALUE([c0].[value], '$.FirstName'), JSON_VALUE([c0].[value], '$.LastName'), JSON_VALUE([c0].[value], '$.Address'), JSON_VALUE([c0].[value], '$.Email'), JSON_VALUE([c0].[value], '$.PhoneNumber'), [c0].[key]
FROM [Clients] AS [c]
OUTER APPLY OPENJSON([c].[Contacts], '$') AS [c0]
ORDER BY [c].[Id], CAST([c0].[key] ASint)
This fails on SQLite, because CROSS/OUTER APPLY isn't supported there.
If the CROSS APPLY is only referenced in the projection (and not e.g. in a filter), then it should be able to transform the query to replace the CROSS APPLY with a projection subquery instead. This seems particularly useful around SQLite JSON processing, as above.
Note the similarity with #34256, where we do the opposite, lifting a subquery projection to CROSS APPLY on SQL Server (where an aggregate function is involved).
Activity
Rewrite APPLY over json_each into a join on SQLite
Rewrite APPLY over json_each into a join on SQLite (#38688)
Rewrite APPLY over json_each into a join on SQLite (#38688)