Skip to content

gfql polars: an unnamed untyped single-hop chain keeps duplicate node rows that pandas, cuDF and polars' own multi-hop collapse #2051

Description

@lmeyerov

Summary

Sibling of #1993 (polars hop() de-dups its output node table like pandas). The polars chain path still returns a duplicated node row for the unnamed, untyped single-hop shape; every other shape — named steps, a typed edge, hops=2, undirected, hop() itself — collapses the duplicate, as pandas and cuDF do on every shape.

Repro

import pandas as pd, polars as pl, graphistry
from graphistry.compute.ast import n, e_forward
nodes = pd.DataFrame({"key": [1, 2, 3, 4, 5], "id": [10, 20, 30, 40, 50]})
nodes = pd.concat([nodes, nodes.iloc[[0]]], ignore_index=True)          # key 1 twice
edges = pd.DataFrame({"s": [1, 1, 2, 3, 3, 4], "d": [2, 3, 3, 1, 1, 5], "eid": range(6)})
g = graphistry.nodes(pl.from_pandas(nodes), "key").edges(pl.from_pandas(edges), "s", "d", "eid")
g.gfql([n({"key": 1}), e_forward(), n()], engine="polars")._nodes["key"].to_list()              # [1, 1, 2, 3]
g.gfql([n({"key": 1}, name="a"), e_forward(name="e"), n(name="b")], engine="polars")._nodes["key"].to_list()  # [1, 2, 3]
g.gfql([n({"key": 1}), e_forward({"type": "KNOWS"}), n()], engine="polars")   # [1, 2, 3] with a typed edge column

pandas gives [1, 2, 3] for all three. Same with index_policy="off" and with the seeded polars lane and the chain fast path forced to decline, so it is the general _chain_traversal_polars route for the simple single-hop shape.

Found by the sibling-specialization sweep run after #2046 (plans/gfql-benchmark-numbers/spec-sweep/).

Expected

The polars chain collapses duplicate node rows on every shape, matching pandas' combine (the contract test_fast_path_dedups_duplicate_node_ids_on_hop states for pandas/cuDF).

Pins

A strict-xfail pin lives in graphistry/tests/compute/gfql/lazy/engine/polars/ next to the #2039 pins and flips when this is fixed.

Activity

  1. added a commit that references this issue on Sep 20, 2026
  2. lmeyerov commented on Oct 3, 2026

    @lmeyerov
    ContributorAuthor

    Closing: #2056 (f45469c, on master) made the polars plain single-hop branch return one row per node id like the full path, and flipped the strict xfails that pinned this divergence. Reopen if an unnamed untyped single-hop chain on polars shows duplicate node rows at current master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions