Skip to content

Chained VLP endpoint projection not rewritten to CTE column across WITH barrier (recursive-VLP form) #1106

Description

@genezhang

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    design-cycleSystemic root cause; needs a design-cycle fix, not a per-shape patch. Excluded from bug count.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions