Skip to content

fix: exclude internal VLE helper vars from RETURN * expansion (#2540) - #2545

Open
waterWang wants to merge 1 commit into
apache:masterfrom
waterWang:fix-vle-return-star
Open

fix: exclude internal VLE helper vars from RETURN * expansion (#2540)#2545
waterWang wants to merge 1 commit into
apache:masterfrom
waterWang:fix-vle-return-star

Conversation

@waterWang

Copy link
Copy Markdown

Description

Fixes #2540

MATCH p = ()-[*1]->(n:End {id: 2})
RETURN *

fails with ERROR: return row and column definition list do not match while the equivalent explicit RETURN p, n succeeds.

Root cause

When a variable-length edge pattern has no explicit start/end variable, build_VLE_relation in cypher_gram.y assigns internal helper names via create_unique_name(AGE_DEFAULT_PREFIX"vle_function_{start,end}_var") (e.g. _age_default_vle_function_start_var_1). Those columns land in the parse namespace and are picked up by RETURN * expansion (ExpandAllTables -> expand_pnsi_attrs). The SRF is then invoked with one extra column, producing the row/column mismatch error.

Fix

In expand_pnsi_attrs, skip columns whose name begins with AGE_DEFAULT_PREFIX "vle_function_", the same way the existing hidden-var (AGE_DEFAULT_VARNAME_PREFIX) and hidden-alias (AGE_DEFAULT_ALIAS_PREFIX) filters work.

Verification

  • make installcheck: 41/43 pass (only pre-existing age_load/file-path and age_upgrade env failures, unrelated to this change)
  • Manual repro now returns the expected (n, p) columns matching the AGE convention that RETURN * orders entities before the path variable

…#2540)

When a variable-length edge pattern assigns internal helper column names
via create_unique_name(AGE_DEFAULT_PREFIX"vle_function_{start,end}_var")
in cypher_gram.y, those columns land in the namespace and are picked up
by RETURN * expansion (ExpandAllTables -> expand_pnsi_attrs). The SRF is
then invoked with one column more than the caller's column definition
list declares, producing:

  ERROR: return row and column definition list do not match

e.g.

  MATCH p = ()-[*1]->(n:End {id: 2})
  RETURN *
  AS (p agtype, n agtype)

Filter out the internal VLE helper columns in expand_pnsi_attrs the same
way hidden vars/aliases are already excluded. Regression-tested with
make installcheck: 41/43 pass (age_load/age_upgrade fail for pre-existing
environment reasons unrelated to this change).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a RETURN * expansion bug in Apache AGE Cypher parsing where internal variable-length edge (VLE) helper variables leaked into the parse namespace expansion, causing ERROR: return row and column definition list do not match for patterns like MATCH p = ()-[*1]->(n:End {id: 2}) RETURN *.

Changes:

  • Extend expand_pnsi_attrs()’s hidden-column filtering to also exclude internal VLE helper columns whose names begin with AGE_DEFAULT_PREFIX "vle_function_".
  • Add explanatory in-code documentation clarifying why these VLE helper columns must not be included in RETURN *.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jrgemignani

Copy link
Copy Markdown
Contributor

@waterWang Two things to point out, please address the code change, which is minor. Also, as this is fixing an issue, please provide regression tests showing that it resolves that issue.

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.

Variable-length path with RETURN * fails with a row/column definition error

3 participants