Skip to content

Commit 7efc208

Browse files
lmeyerovclaude
andcommitted
review: keep the localized ignores matching the new error code
Widening filter_by_dict_polars to a constrained TypeVar changes the diagnostic at its two engine-neutral DataFrameT call sites from arg-type to type-var, so the existing localized ignore no longer applied. Retarget it and add the twin in gfql_fast_paths. Both sites are already gated on a polars engine; the cast is what the surrounding code has always asserted. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NxxTFpKiqA4FQa9Pjy8yR1
1 parent c394ae2 commit 7efc208

3 files changed

Lines changed: 21 additions & 13 deletions

File tree

graphistry/compute/gfql/index/bindings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ def _filter_frame(
149149
filter_by_dict_polars,
150150
)
151151

152-
return cast(DataFrameT, filter_by_dict_polars(frame, filter_dict)) # type: ignore[arg-type]
152+
# frame is DataFrameT (engine-neutral); on this branch it IS a polars frame,
153+
# which the helper's constrained TypeVar cannot see through the alias
154+
return cast(DataFrameT, filter_by_dict_polars(frame, filter_dict)) # type: ignore[type-var]
153155
from graphistry.compute.filter_by_dict import filter_by_dict
154156

155157
return filter_by_dict(frame, filter_dict, engine) # type: ignore[arg-type]

graphistry/compute/gfql/lazy/engine/polars/row_pipeline.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,19 +1185,19 @@ def _directed_fixed_point_binding_rows_polars(
11851185
)
11861186

11871187
# (a) depth probe: dedup-by-node frontier, so each hop costs O(N) not O(paths).
1188-
frontier = _lazy_collect(state.select(pl.col("__current__")).unique())
1188+
frontier_lf = state.select(pl.col("__current__")).unique()
11891189
depth = 0
11901190
exhausted = node_cap == 0 # no matched edges at all -> no walk of length >= 1
11911191
for hop in range(1, node_cap + 1):
11921192
frontier = _lazy_collect(
1193-
frontier.lazy()
1194-
.join(pairs_lf, left_on="__current__", right_on="__from__", how="inner")
1193+
frontier_lf.join(pairs_lf, left_on="__current__", right_on="__from__", how="inner")
11951194
.select(pl.col("__to__").alias("__current__"))
11961195
.unique()
11971196
)
11981197
if frontier.height == 0:
11991198
exhausted = True
12001199
break
1200+
frontier_lf = frontier.lazy()
12011201
depth = hop
12021202
if not exhausted:
12031203
RowPipelineMixin._gfql_bindings_error(
@@ -1215,7 +1215,7 @@ def binding_rows_polars(
12151215
binding_ops: Sequence[Dict[str, JSONVal]],
12161216
attach_prop_aliases: Optional[Sequence[str]] = None,
12171217
) -> Optional[Plottable]:
1218-
"""Native polars bindings-row table for FIXED-LENGTH connected patterns (#1709).
1218+
"""Native polars bindings-row table for connected alias patterns (#1709).
12191219
12201220
Materializes one row per matched path for an alternating ``n/e/n/...`` pattern
12211221
(the ``rows(binding_ops=...)`` op emitted by Cypher multi-alias lowering), with
@@ -1225,14 +1225,19 @@ def binding_rows_polars(
12251225
columns — raw ``node_id``, ``a__a_join__``, leaked ``__gfql_edge_index__`` —
12261226
that no lowered query references; those are intentionally not replicated.)
12271227
1228+
Covers fixed-length hops, bounded variable-length (directed ``-[*i..k]->`` and
1229+
undirected ``-[*1..k]-``), unbounded DIRECTED fixed point (``-[*]->`` /
1230+
``-[*0..]->``), and the node-only cartesian mode.
1231+
12281232
Returns None to DECLINE (caller raises the honest NIE) for anything outside
1229-
the supported subset: variable-length/multi-hop edges, shortestPath scalar
1230-
bindings, node ``query=`` / edge query or endpoint-match params, hop labels,
1231-
HAS_-label destination disambiguation on duplicate-node-id graphs (unique-id
1232-
graphs run native — pandas would not narrow there either), seeded re-entry
1233-
contexts, cartesian (node-only) mode, and the legacy ``alias_endpoints``
1234-
variant. NO-CHEATING:
1235-
never bridges to pandas. Parity gate: differential tests vs the pandas oracle.
1233+
that subset: undirected variable-length outside ``min_hops == 1`` (including
1234+
undirected unbounded), aliased variable-length relationships, unbounded
1235+
segments without ``to_fixed_point``, shortestPath scalar bindings, node
1236+
``query=`` / edge query or endpoint-match params, hop labels, HAS_-label
1237+
destination disambiguation on duplicate-node-id graphs (unique-id graphs run
1238+
native — pandas would not narrow there either), duplicate-id re-entry seeds,
1239+
and the legacy ``alias_endpoints`` variant. NO-CHEATING: never bridges to
1240+
pandas. Parity gate: differential tests vs the pandas oracle.
12361241
"""
12371242
import polars as pl
12381243
from graphistry.compute.ast import ASTEdge, ASTNode, ASTObject, from_json as ast_from_json

graphistry/compute/gfql_fast_paths.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1518,7 +1518,8 @@ def _connected_join_two_star_fast_rows(
15181518
def _filter_nodes_for_fast_count(nodes: DataFrameT, filter_dict: Optional[dict], *, engine: Engine) -> DataFrameT:
15191519
if engine in POLARS_ENGINES:
15201520
from graphistry.compute.gfql.lazy.engine.polars.predicates import filter_by_dict_polars
1521-
return cast(DataFrameT, filter_by_dict_polars(nodes, filter_dict))
1521+
# engine-neutral DataFrameT that IS a polars frame on this branch (see gate above)
1522+
return cast(DataFrameT, filter_by_dict_polars(nodes, filter_dict)) # type: ignore[type-var]
15221523
return filter_by_dict(nodes, filter_dict, engine=EngineAbstract(engine.value))
15231524

15241525

0 commit comments

Comments
 (0)