Summary
When a variable-length path is chained to a further hop ((person)-[:KNOWS*2..2]-(friend)-[:IS_LOCATED_IN]->(city)) and crosses a WITH barrier, the VLP endpoint projections in the generated WITH CTE are not rewritten to the VLP CTE columns (t.start_id/t.end_id). The CTE selects raw friend.id / person.id, but its FROM is vlp_person_friend AS t (+ chained joins), where those base-table aliases are not in scope → ClickHouse Code 47.
Minimal repro (LDBC schema)
MATCH (person:Person {id: 14})-[:KNOWS*2..2]-(friend:Person)-[:IS_LOCATED_IN]->(city:City)
WITH person, friend, city
RETURN friend.id
Generated (abridged):
with_city_friend_person_cte_0 AS (SELECT
friend.id AS "p6_friend_id" -- ❌ should be t.end_id
FROM vlp_person_friend AS t
INNER JOIN ldbc.Person_isLocatedIn_Place AS t2 ON t2.PersonId = t.end_id
INNER JOIN ldbc.Place AS city ON city.id = t2.CityId
WHERE (t.start_id = 14 AND ...))
→ Code 47: Unknown expression identifier 'friend.id'.
Isolation
- Without the chained
-[:IS_LOCATED_IN]->(city) hop, *2..2 renders as flat joins (not a recursive VLP CTE) and friend.id resolves correctly (r2.Person2Id). The chained hop is what forces the recursive vlp_person_friend CTE form.
- In that recursive form,
rewrite_vlp_union_branch_aliases does not descend into the generated WITH CTE's inner SELECT, so person(start)→t.start_id and friend(end)→t.end_id rewrites are missed.
Impact
Acceptance
- The chained-VLP endpoint projections in the WITH CTE resolve to
t.start_id/t.end_id.
- Golden SQL fixture + live execution on LDBC SF1.
Surfaced from the LDBC SNB re-measurement (IC10 root cause), after the #1100 slices landed.
Summary
When a variable-length path is chained to a further hop (
(person)-[:KNOWS*2..2]-(friend)-[:IS_LOCATED_IN]->(city)) and crosses aWITHbarrier, the VLP endpoint projections in the generated WITH CTE are not rewritten to the VLP CTE columns (t.start_id/t.end_id). The CTE selects rawfriend.id/person.id, but its FROM isvlp_person_friend AS t(+ chained joins), where those base-table aliases are not in scope → ClickHouse Code 47.Minimal repro (LDBC schema)
Generated (abridged):
→
Code 47: Unknown expression identifier 'friend.id'.Isolation
-[:IS_LOCATED_IN]->(city)hop,*2..2renders as flat joins (not a recursive VLP CTE) andfriend.idresolves correctly (r2.Person2Id). The chained hop is what forces the recursivevlp_person_friendCTE form.rewrite_vlp_union_branch_aliasesdoes not descend into the generated WITH CTE's inner SELECT, soperson(start)→t.start_idandfriend(end)→t.end_idrewrites are missed.Impact
(person)-[:KNOWS*2..2]-(friend)-[:IS_LOCATED_IN]->(city)+ WITH is exactly this shape). Related to the closed VLP endpoint referenced across a WITH/UNWIND barrier fails to resolve (standard schema; 7 of 17 LDBC SNB non-passing queries) #1100 (VLP endpoint across WITH barrier) and Multiple VLPs with non-overlapping aliases in one scope: one VLP silently dropped, its endpoint conflated with the other's #544 (chained VLP), but this is the chained-hop-forces-recursive-VLP variant.Acceptance
t.start_id/t.end_id.Surfaced from the LDBC SNB re-measurement (IC10 root cause), after the #1100 slices landed.