# Empty output in subquery CALL leads to null output

**URL:** <https://community.neo4j.com/t/empty-output-in-subquery-call-leads-to-null-output/66319>\
**Category:** Cypher\
**Created:** [February 14, 2024, 11:02am UTC](https://community.neo4j.com/t/empty-output-in-subquery-call-leads-to-null-output/66319 "2024-02-14T11:02:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergii.suchkov](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/sergii.suchkov/32/30840_2.png) [@sergii.suchkov](https://community.neo4j.com/u/sergii.suchkov)\
**Post date:** [February 14, 2024, 11:02am UTC](https://community.neo4j.com/t/empty-output-in-subquery-call-leads-to-null-output/66319/1 "2024-02-14T11:02:42Z")

</div>

Hi, I recently found some behaviour which confuses me, furthermore I haven't notice such things before neo4j 4.4.

When I do cypher

```auto
CALL {
    UNWIND ["a", "b", "c"] as arr1
    RETURN arr1 as include
}
WITH include
RETURN include

```

I obviously have `"a", "b", "c"` output.

Then if I do

```auto
CALL {
    UNWIND ["a", "b", "c"] as arr1
    RETURN arr1 as include
}
CALL {
    UNWIND ["a"] as arr2
    RETURN arr2 as exclude
}
WITH include, exclude
WHERE include<>exclude
RETURN include

```

I also have assumed output `"b","c"`

Weird things starts when second call returns empty set.  
Hence cypher

```auto
CALL {
    UNWIND ["a", "b", "c"] as arr1
    RETURN arr1 as include
}
CALL {
    UNWIND [] as arr2
    RETURN arr2 as exclude
}
WITH include, exclude
WHERE include<>exclude
RETURN include

```

Returns nothing. Also if we ignore second call like

```auto
CALL {
    UNWIND ["a", "b", "c"] as arr1
    RETURN arr1 as include
}
CALL {
    UNWIND [] as arr2
    RETURN arr2 as exclude
}
WITH include
RETURN include

```

We also have nothing.

I understand that I use cypher maybe not in most canonical way, but can that be some sort of a bug or something ?

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [February 14, 2024, 2:02pm UTC](https://community.neo4j.com/t/empty-output-in-subquery-call-leads-to-null-output/66319/2 "2024-02-14T14:02:38Z")

</div>

What you are observing is expected. The subquery results are appended to the outer query’s result. As such, when your subquery produces no results, the total result is also no result. Just as what would happen if you had two sequential matches and the second produced no match.

---

<div class="post-metadata">

**Author:** ![sergii.suchkov](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/sergii.suchkov/32/30840_2.png) [@sergii.suchkov](https://community.neo4j.com/u/sergii.suchkov)\
**Post date:** [February 15, 2024, 9:05am UTC](https://community.neo4j.com/t/empty-output-in-subquery-call-leads-to-null-output/66319/3 "2024-02-15T09:05:53Z")

</div>

Hi @glilienfield  
thank you for the response 🙂
