Skip to content

Present default-label vertices and edges consistently across access paths - #2614

Open
ksaiharshavinay wants to merge 1 commit into
apache:masterfrom
ksaiharshavinay:fix/2612-default-label-consistency
Open

ksaiharshavinay wants to merge 1 commit into
apache:masterfrom
ksaiharshavinay:fix/2612-default-label-consistency

Conversation

@ksaiharshavinay

Copy link
Copy Markdown

Fixes #2612.

A vertex that lives in the default vertex label (_ag_label_vertex)
was presented with two different labels depending on how it was
reached:

  • pattern matching and CREATE present it as having no label
    ("label": "", labels() -> [""]) - the "no label" presentation
    AGE has used since its early versions, via _label_name();
  • startNode()/endNode() (and _get_vertex_by_graphid) presented
    it as "_ag_label_vertex", and VLE paths did the same.

So in the reported case, two isomorphic queries disagree: rebinding
an endpoint by id across OPTIONAL MATCH barriers changed
labels(alias2) from ["_ag_label_vertex"] to [""] while id()
and properties() agreed.

This change makes the reconstruct-for-output sites use the same
presentation:

  • Add get_display_label_name() in ag_label.c, mapping the default
    vertex/edge label names to "", and use it in _label_name()
    (replacing its inline check).
  • get_vertex() in agtype.c (used by startNode(), endNode() and
    _get_vertex_by_graphid) now builds the vertex with the display
    label. The real label name is still used for the table lookup.
  • The VLE path/edges builders in age_vle.c map the label obtained
    from the label table oid through the same helper, for vertices and
    edges.

Regression: updated expectations in cypher_match, cypher_unwind,
cypher_with, cypher_vle and age_global_graph (only the label string
of default-label vertices/edges in the affected outputs changed),
and a new test in expr.sql comparing labels() for the same vertex
across pattern matching, startNode()/endNode(), an OPTIONAL MATCH
id-rebind, and a variable-length path. Full suite: all 43 tests
pass (PG 18.6, AGE master).

Disclosure: this fix was developed with AI assistance (Claude), and
every change was reproduced, tested and reviewed locally by me.

…aths

Vertices and edges in the default labels (_ag_label_vertex and
_ag_label_edge) are presented as having no label when they are built
by pattern matching or CREATE, but startNode()/endNode() and the VLE
path builder used the internal label name, so the same vertex could
report labels() as ["_ag_label_vertex"] or [""] depending on how it
was reached - e.g. when rebound by id across an OPTIONAL MATCH
barrier.

Add get_display_label_name() and use it wherever a vertex or edge is
reconstructed for output: get_vertex() (startNode, endNode and
_get_vertex_by_graphid) and the VLE path/edges builders. _label_name()
now uses the same helper. Update the affected regression expectations
and add a regression test comparing labels() across access paths.

Fixes apache#2612
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.

Graph-isomorphism barrier changes labels of an unlabeled endpoint

1 participant