Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Fixed

- **GFQL comprehension-local `properties()`**: mapping values now return the same map instead of a bare backend `NotImplementedError`, while entity and direct-map rendering stay unchanged (#2339).
- **GFQL nullable entity keys on cuDF** (#2312): `keys(n)` now returns empty lists for rows with no non-null properties alongside populated rows. Native empty key lists use the string child type expected by the grouped result, and key lists remain aligned with their original entities after the native grouping join.
- **GFQL Cypher empty property maps**: an explicit node `{}` no longer replaces labels, so `MATCH (n:Foo {})` still selects `Foo` nodes. An explicit relationship `{}` no longer replaces relationship types with an empty tuple, so `MATCH ()-[r:R {}]->()` matches only typed `R` relationships on every supported engine, while untyped `n {}` and `r {}` controls remain untyped (#2318).

Expand Down
1 change: 1 addition & 0 deletions bin/test-polars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ POLARS_TEST_FILES=(
graphistry/tests/compute/gfql/cypher/test_issue_2261_grouped_identity.py
# quoted map keys/MATCH aliases are engine-parametrized; pandas runs in core,
# polars params only run in this lane
graphistry/tests/compute/gfql/test_properties_comprehension_map_2339.py
graphistry/tests/compute/gfql/cypher/test_backtick_identifiers.py
graphistry/tests/compute/gfql/test_conformance_ledger.py
graphistry/tests/compute/gfql/test_polars_nan_clean.py
Expand Down
6 changes: 6 additions & 0 deletions graphistry/compute/gfql/row/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2700,6 +2700,12 @@ def _gfql_eval_entity_graph_fn(
fn: str,
expr: str,
) -> Any:
if (
fn == "properties"
and hasattr(value, "astype")
and RowPipelineMixin._gfql_series_is_mapping_like(value)
):
return value.copy()
if hasattr(value, "astype"):
null_mask = self._gfql_null_mask(table_df, value)
if RowPipelineMixin._gfql_series_is_entity_text_like(value):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import os

import pandas as pd
import pytest

import graphistry
from graphistry.compute.exceptions import GFQLUnsupportedError


try:
import cudf # noqa: F401
_HAS_CUDF = True
except Exception: # pragma: no cover
_HAS_CUDF = False

try:
import polars # noqa: F401
_HAS_POLARS = True
except Exception: # pragma: no cover
_HAS_POLARS = False

_ENGINES = ["pandas"]
if _HAS_CUDF and os.environ.get("TEST_CUDF") == "1":
_ENGINES.append("cudf")
if _HAS_POLARS:
_ENGINES.append("polars")
if _HAS_CUDF and os.environ.get("TEST_POLARS_GPU") == "1":
_ENGINES.append("polars-gpu")


@pytest.fixture(params=_ENGINES)
def engine(request):
if request.param == "cudf":
pytest.importorskip("cudf")
if os.environ.get("TEST_CUDF") != "1":
pytest.skip("cudf tests need TEST_CUDF=1")
elif request.param == "polars-gpu":
pytest.importorskip("cudf_polars")
if os.environ.get("TEST_POLARS_GPU") != "1":
pytest.skip("requires actual polars-gpu")
return request.param


def _graph(engine):
nodes = pd.DataFrame({"id": [0]})
edges = pd.DataFrame({"s": [0], "d": [1], "eid": [0]})
if engine in {"polars", "polars-gpu"}:
import polars as pl

nodes, edges = pl.from_pandas(nodes), pl.from_pandas(edges)
elif engine == "cudf":
import cudf

nodes, edges = cudf.from_pandas(nodes), cudf.from_pandas(edges)
return graphistry.nodes(nodes, "id").edges(edges, "s", "d").bind(edge="eid")


def test_properties_of_comprehension_local_map_is_identity(engine):
query = "MATCH (n) RETURN [m IN [{a: 1}] | properties(m)][0] AS v"
if engine in {"polars", "polars-gpu"}:
with pytest.raises((NotImplementedError, GFQLUnsupportedError)):
_graph(engine).gfql(query, engine=engine)
return

result = _graph(engine).gfql(query, engine=engine)._nodes
if hasattr(result, "to_pandas"):
result = result.to_pandas()
assert result["v"].tolist() == [{"a": 1}]
Loading