Skip to content

Commit 62239d2

Browse files
lmeyerovclaude
andcommitted
test(gfql): probe to_dicts before to_dict(orient=) for engine-agnostic records
The dual-path guards checked hasattr(out, 'to_dict') first, but polars DataFrame HAS to_dict (without orient) — so the polars branch was unreachable and these tests only ever ran because auto silently returned pandas. With auto routing polars-frame graphs natively they now receive polars frames; probe to_dicts first. Assertions (record values) unchanged and still pass on both engines. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6dQEcjdazEnzuvuwf73ZL
1 parent 5f8b60f commit 62239d2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

graphistry/tests/compute/gfql/cypher/test_lowering.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15997,7 +15997,7 @@ def test_connected_join_polars_nullable_columns_match_master(predicate: str, exp
1599715997
query = f"MATCH (p)-[]->(x), (p)-[]->(y) WHERE {predicate} RETURN count(p) AS n"
1599815998

1599915999
out = g.gfql(query)._nodes
16000-
records = out.to_dict(orient="records") if hasattr(out, "to_dict") else out.to_dicts()
16000+
records = out.to_dicts() if hasattr(out, "to_dicts") else out.to_dict(orient="records")
1600116001
assert records == expected
1600216002

1600316003

@@ -16027,7 +16027,7 @@ def test_arrow_table_nodes_match_master_results() -> None:
1602716027
def run(predicate: str) -> Any:
1602816028
query = f"MATCH (p)-[]->(x), (p)-[]->(y) WHERE {predicate} RETURN count(p) AS n"
1602916029
out = g.gfql(query)._nodes
16030-
return out.to_dict(orient="records") if hasattr(out, "to_dict") else out.to_dicts()
16030+
return out.to_dicts() if hasattr(out, "to_dicts") else out.to_dict(orient="records")
1603116031

1603216032
assert run("p.name = 5") == []
1603316033
assert run("p.name = 'ann'") == [{"n": 4}]
@@ -16084,7 +16084,7 @@ def test_connected_join_polars_decimal_matches_master(predicate: str, expected:
1608416084
query = f"MATCH (p)-->(a), (p)-->(b) WHERE {predicate} RETURN count(p) AS n"
1608516085

1608616086
result = g.gfql(query)._nodes
16087-
records = result.to_dict(orient="records") if hasattr(result, "to_dict") else result.to_dicts()
16087+
records = result.to_dicts() if hasattr(result, "to_dicts") else result.to_dict(orient="records")
1608816088
assert records == expected
1608916089

1609016090

@@ -16099,7 +16099,7 @@ def test_connected_join_polars_backed_graph_matches_pandas_results() -> None:
1609916099

1610016100
g_polars = graphistry.nodes(pl.from_pandas(nodes), "id").edges(pl.from_pandas(edges), "s", "d")
1610116101
result = g_polars.gfql(query)._nodes
16102-
records = result.to_dict(orient="records") if hasattr(result, "to_dict") else result.to_dicts()
16102+
records = result.to_dicts() if hasattr(result, "to_dicts") else result.to_dict(orient="records")
1610316103
assert records == []
1610416104

1610516105

0 commit comments

Comments
 (0)