cwida / duckpgq-extension

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

Support path-finding on undirected edges #87

Closed Dtenwolde closed 2 months ago

Dtenwolde commented 8 months ago

Currently only right-directed edges are allowed to have (un)bounded path patterns. For example:

MATCH o = ANY SHORTEST (a:Person)-[k:knows]->{2,3}(b:Person)

The following should also be possible:

MATCH o = ANY SHORTEST (a:Person)-[k:Knows]-{2,3}(b:Person)

The (un)bounded path pattern should still be on the right of the edge pattern as is defined by the specification

Some LDBC SNB queries (see here) require path-finding over undirected edges.

This can be implemented by inserting the edges into the CSR in both directions. Once src -> dst, and also dst -> src. We already did this previously for IC13 previously

Dtenwolde commented 8 months ago

Trying to duplicate the edge both ways using a UNION ALL seems to run into an Internal exception in the current (v0.9.2) version

SELECT min(CREATE_CSR_EDGE(0, (SELECT count(c.id) as vcount FROM student c),
CAST ((SELECT sum(CREATE_CSR_VERTEX(0, (SELECT count(c.id) as vcount FROM student c),
sub.dense_id, sub.cnt)) AS numEdges
FROM (
    SELECT c.rowid as dense_id, count(t.src) as cnt
    FROM student c
    LEFT JOIN know t ON t.src = c.id
    GROUP BY c.rowid
) sub) AS BIGINT),
edges.src_rowid, edges.dst_rowid, edges.edge_rowid))
FROM (SELECT src.rowid as src_rowid, dst.rowid as dst_rowid, t.rowid as edge_rowid
FROM Know t
  JOIN student src ON t.src = src.id
  JOIN student dst ON t.dst = [dst.id](http://dst.id/)
UNION ALL
SELECT dst.rowid as src_rowid, src.rowid as dst_rowid, t.rowid as edge_rowid
FROM know t
JOIN student dst on t.src = [dst.id](http://dst.id/)
JOIN student src on t.dst = [src.id](http://src.id/)) edges;

Error: INTERNAL Error: Attempted to access index 8 within vector of size 8

Seems like a DuckDB issue which is potentially already solved https://github.com/duckdb/duckdb/issues/9455

Try again after updating to 0.10.*

Dtenwolde commented 8 months ago

Update after merging with v0.10.0 Same behaviour Error: INTERNAL Error: Attempted to access index 8 within vector of size 8