cwida / duckpgq-extension

DuckDB extension that adds support for SQL/PGQ
https://duckpgq.notion.site/b8ac652667964f958bfada1c3e53f1bb?v=3b47a8d44bdf4e0c8b503bf23f1b76f2
MIT License
86 stars 7 forks source link

0-edge graph is treated the same as no graph #163

Closed Arogova closed 1 week ago

Arogova commented 1 week ago

What happens?

Hello,

It appears that a graph with no edges is treated the same as "no graph has been generated". This becomes an issue when trying to match a shortest path, causing the error "Constraint Error: Need to initialize CSR before doing shortest path" to be thrown.

I discovered this issue while trying to run automated tests on duckpgq using randomly generated graphs (hence the absurd existence of a graph without edges).

To Reproduce

force install duckpgq from community;
load duckpgq;

CREATE TABLE nodes (id INTEGER);
CREATE TABLE edges (src INTEGER, dst INTEGER);

INSERT INTO nodes VALUES (1), (2), (3);

CREATE PROPERTY GRAPH testgraph
    VERTEX TABLES (
        nodes LABEL N
    )
    EDGE TABLES (
        edges SOURCE KEY (src) REFERENCES nodes (id)
              DESTINATION KEY (dst) REFERENCES nodes (id)
          LABEL E
);

FROM GRAPH_TABLE(testgraph
      MATCH p = ANY SHORTEST (n1:N)-[e:E]-> * (n2:N)
      COLUMNS (edges(p) AS path_edges)
);

OS:

Ubuntu 20.04.6 LTS (x86_64)

DuckDB Version:

1.1.0

DuckDB Client:

CLI (initially discovered using the Go driver)

Full Name:

Alexandra Rogova

Affiliation:

IRIF, Université Paris Cité

How did you load the extension?

Community extension version

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

Dtenwolde commented 1 week ago

Hi there,

Thanks for submitting the issue! This error indeed should not be thrown on edgeless graphs, I'll work on a fix :)

Kind regards, Daniel

Arogova commented 1 week ago

Thanks for the super quick fix!