Skip to content

Commit 410f925

Browse files
lmeyerovclaude
andcommitted
review: strengthen EXISTS whole-entity RETURN regression test
Adversarial review findings: - (IMPORTANT) pandas-only in a cross-engine conformance file — add the file's parity-or-NIE invariant (_assert_invariant): non-pandas engines match pandas or decline honestly; whole-entity RETURN declines (NIE) on polars. - add explicit `len(pdf) == 1` so the guard is row-count-independent, not implicit in the single-row asserts. - document the string-id dependency (numeric id would render as a property) and that `n.id` is the #1650 internal flattened-projection column. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 85bbf40 commit 410f925

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎graphistry/tests/compute/gfql/test_engine_polars_conformance_matrix.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,11 @@ def test_exists_whole_entity_return_renders_entity_text():
757757
a WHOLE-ENTITY ``RETURN n`` over a simple-pattern ``EXISTS { }`` renders the
758758
correct entity text (label + property), not leaked internal marker columns.
759759
Graph mirrors the TCK fixture — node ``a`` is the only one with an out-edge —
760-
so the EXISTS filter keeps exactly ``a`` and it renders ``(:A {prop: 1})``."""
760+
so the EXISTS filter keeps exactly ``a`` and it renders ``(:A {prop: 1})``.
761+
762+
``id`` is a STRING on purpose: a numeric id would render as an extra
763+
property (``{id: 0, prop: 1}``). ``n.id`` is the #1650 flattened
764+
whole-entity projection column, not user-aliased output."""
761765
import pandas as pd
762766
from graphistry.compute.gfql.cypher.result_postprocess import render_entity_text
763767
nodes = pd.DataFrame({
@@ -770,10 +774,15 @@ def test_exists_whole_entity_return_renders_entity_text():
770774
})
771775
edges = pd.DataFrame({"s": ["a", "a", "a"], "d": ["b", "c", "d"], "eid": [0, 1, 2]})
772776
g = graphistry.nodes(nodes, "id").edges(edges, "s", "d").bind(edge="eid")
773-
res = g.gfql("MATCH (n) WHERE EXISTS { (n)-->() } RETURN n", engine="pandas")
777+
q = "MATCH (n) WHERE EXISTS { (n)-->() } RETURN n"
778+
res = g.gfql(q, engine="pandas")
774779
pdf = _to_pd(res._nodes)
775-
assert pdf["n.id"].tolist() == ["a"], "EXISTS keeps only the node with an out-edge"
780+
assert len(pdf) == 1, "EXISTS keeps exactly the one node with an out-edge"
781+
assert pdf["n.id"].tolist() == ["a"]
776782
assert render_entity_text(res, "n", table="nodes").tolist() == ["(:A {prop: 1})"]
783+
# Cross-engine (this file's invariant): non-pandas engines match pandas
784+
# parity or decline honestly (NIE) — whole-entity RETURN declines on polars.
785+
_assert_invariant(g, q, "exists-whole-entity-return")
777786

778787

779788
def test_tolower_non_string_declines_never_fabricates():

0 commit comments

Comments
 (0)