Skip to content

#3996 fix(cypher): CALL...YIELD preserves variables carried in from WITH#4009

Merged
robfrank merged 3 commits into
mainfrom
fix/3996-call-yield-loses-with-variables
Apr 28, 2026
Merged

#3996 fix(cypher): CALL...YIELD preserves variables carried in from WITH#4009
robfrank merged 3 commits into
mainfrom
fix/3996-call-yield-loses-with-variables

Conversation

@robfrank

Copy link
Copy Markdown
Collaborator

Summary

  • CALL db.labels() YIELD label (and all other procedures) were silently dropping variables bound by a preceding WITH or MATCH clause - x returned null on every row instead of its bound value.
  • Root cause: CallStep.executeChainedCall() collected procedure result iterators into a flat List<Iterator<?>> with no link back to the originating input row, so outer-scope variables were never merged into the yielded results.
  • Fix: changed to List<Map.Entry<Result, Iterator<?>>> pairs; the lazy iterator now tracks currentInputRow and calls the existing mergeWithInputRow() helper for every yielded result, restoring standard Cypher semantics.

Test plan

  • CypherCallYieldWithVariablesTest - 4 new regression tests covering db.labels(), db.relationshipTypes(), db.propertyKeys(), and aggregated count(*) carried through WITH
  • OpenCypherUnionCallProfileTest - existing CALL tests still pass
  • Full Cypher test suite - no regressions

Fixes #3996

🤖 Generated with Claude Code

Variables bound by a preceding WITH or MATCH clause were silently nulled
out after a CALL...YIELD. The root cause was that CallStep collected
procedure result iterators into a flat list with no association to the
originating input row, so outer-scope variables were never merged into
the yielded results.

Fix: track each (inputRow, resultIterator) pair and merge inputRow
properties into every yielded result via the existing mergeWithInputRow
helper, restoring standard Cypher semantics across db.labels(),
db.relationshipTypes(), db.propertyKeys(), and any registered procedure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codacy-production

codacy-production Bot commented Apr 28, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Coverage 86.67% diff coverage · -7.85% coverage variation

Metric Results
Coverage variation -7.85% coverage variation
Diff coverage 86.67% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (983da3f) 120063 87787 73.12%
Head commit (5851530) 151308 (+31245) 98751 (+10964) 65.26% (-7.85%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4009) 15 13 86.67%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an issue where variables from preceding clauses were lost after a CALL ... YIELD statement by tracking and merging the original input row with procedure results. A comprehensive regression test suite has been added to verify this behavior across various database procedures. The review feedback suggests avoiding redundant merging in optional calls to prevent potential variable shadowing and recommends a performance optimization for the allPairs list initialization by setting an initial capacity.

Comment thread engine/src/main/java/com/arcadedb/query/opencypher/executor/steps/CallStep.java Outdated
Comment thread engine/src/main/java/com/arcadedb/query/opencypher/executor/steps/CallStep.java Outdated
robfrank and others added 2 commits April 28, 2026 09:27
… allPairs

- OPTIONAL CALL with null result: use new ResultInternal() instead of
  pre-merging inputRow, avoiding redundant copy and preventing YIELD
  from seeing outer-scope variables under same-name collision
- pre-size allPairs list with nRecords (capped at 1M) to avoid
  unnecessary ArrayList resizes during batch collection

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@robfrank
robfrank merged commit 63ec984 into main Apr 28, 2026
15 of 17 checks passed
@robfrank
robfrank deleted the fix/3996-call-yield-loses-with-variables branch April 28, 2026 07:36
tae898 pushed a commit to humemai/arcadedb-embedded-python that referenced this pull request Apr 28, 2026
@codecov

codecov Bot commented Apr 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.23%. Comparing base (983da3f) to head (5851530).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...dedb/query/opencypher/executor/steps/CallStep.java 80.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4009      +/-   ##
==========================================
+ Coverage   64.20%   64.23%   +0.03%     
==========================================
  Files        1597     1597              
  Lines      120063   120069       +6     
  Branches    25556    25557       +1     
==========================================
+ Hits        77083    77125      +42     
+ Misses      32306    32276      -30     
+ Partials    10674    10668       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

robfrank added a commit that referenced this pull request May 12, 2026
tae898 pushed a commit to humemai/arcadedb-embedded-python that referenced this pull request Jun 28, 2026
tae898 pushed a commit to humemai/arcadedb-embedded-python that referenced this pull request Jun 28, 2026
tae898 pushed a commit to humemai/arcadedb-embedded-python that referenced this pull request Jun 28, 2026
mergify Bot added a commit that referenced this pull request Jul 12, 2026
…o [skip ci]

Bumps [marked](https://github.com/markedjs/marked) from 18.0.5 to 18.0.6.
Release notes

*Sourced from [marked's releases](https://github.com/markedjs/marked/releases).*

> v18.0.6
> -------
>
> [18.0.6](markedjs/marked@v18.0.5...v18.0.6) (2026-07-09)
> -----------------------------------------------------------------------------------
>
> ### Bug Fixes
>
> * Avoid O(n^2) backtracking in inline link href regex ([#4013](https://redirect.github.com/markedjs/marked/issues/4013)) ([a009808](markedjs/marked@a009808))
> * Fix ordered lists after blockquotes ([#4003](https://redirect.github.com/markedjs/marked/issues/4003)) ([33928d0](markedjs/marked@33928d0))
> * keep trailing text on HTML block close line for PI, declarations, and CDATA ([#3991](https://redirect.github.com/markedjs/marked/issues/3991)) ([bbb84c8](markedjs/marked@bbb84c8))


Commits

* [`39bd884`](markedjs/marked@39bd884) chore(release): 18.0.6 [skip ci]
* [`6bce57d`](markedjs/marked@6bce57d) chore(deps-dev): bump `@​semantic-release/github` from 12.0.8 to 12.0.9 ([#4009](https://redirect.github.com/markedjs/marked/issues/4009))
* [`63a4bba`](markedjs/marked@63a4bba) chore(deps-dev): bump markdown-it from 14.2.0 to 14.3.0 ([#4010](https://redirect.github.com/markedjs/marked/issues/4010))
* [`a009808`](markedjs/marked@a009808) fix: Avoid O(n^2) backtracking in inline link href regex ([#4013](https://redirect.github.com/markedjs/marked/issues/4013))
* [`33928d0`](markedjs/marked@33928d0) fix: Fix ordered lists after blockquotes ([#4003](https://redirect.github.com/markedjs/marked/issues/4003))
* [`bbb84c8`](markedjs/marked@bbb84c8) fix: keep trailing text on HTML block close line for PI, declarations, and CD...
* [`d2af54e`](markedjs/marked@d2af54e) chore(deps-dev): bump eslint from 10.5.0 to 10.6.0 ([#4005](https://redirect.github.com/markedjs/marked/issues/4005))
* [`f403898`](markedjs/marked@f403898) chore(deps-dev): bump `@​arethetypeswrong/cli` from 0.18.3 to 0.18.4 ([#4006](https://redirect.github.com/markedjs/marked/issues/4006))
* [`f8f4112`](markedjs/marked@f8f4112) chore(deps): bump actions/checkout from 6 to 7 ([#4000](https://redirect.github.com/markedjs/marked/issues/4000))
* [`5ddfd8a`](markedjs/marked@5ddfd8a) chore: Update repository metadata URLs ([#3998](https://redirect.github.com/markedjs/marked/issues/3998))
* Additional commits viewable in [compare view](markedjs/marked@v18.0.5...v18.0.6)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=marked&package-manager=npm\_and\_yarn&previous-version=18.0.5&new-version=18.0.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CALL ... YIELD may null out variables carried in from WITH

1 participant