CROSS APPLY should not be used.
Correct:
* You run the following query.

The following Azure Cosmos DB NoSQL query fulfills the requirements by unnesting child array items and filtering the pet array:
To retrieve the family ID, the children's family names, and the rabbit's name, you can use the query below.
SELECT f.id, c.familyName AS FamilyName, p.givenName AS petName
FROM families f
JOIN f.children c
JOIN (SELECT VALUE p FROM p IN c.pets WHERE p.type = 'cat') AS p
1. Flatten the Children Array
To access individual properties within the children sub-array, use a JOIN statement. In Azure Cosmos DB, a JOIN performs an inner product between the document root (f) and the array (f.children). This filters out any family documents that contain no children.
2. Isolate Cat Pets
To inspect the properties of the pets array embedded inside each child, apply a secondary JOIN on c.pets. The WHERE clause then filters these projected items to only include cases where the property $p.type$ matches the string "cat".
3. Project Specific Attributes
The SELECT clause restricts the final JSON output schema to contain exactly three custom- aliased properties:
familyId: Extracted from the root document
IDchildFamilyName: Extracted from the current child item
iterationpetName: Extracted from the matching pet item iteration
Incorrect:
* You run the following query.

Use two JOINS and one subquery, not three JOINS and a subquery.
* You run the following query.

CROSS APPLY should not be used.
Reference:
https://learn.microsoft.com/en-us/cosmos-db/query/subquery