duckpgq-extension icon indicating copy to clipboard operation
duckpgq-extension copied to clipboard

Support path-finding on undirected edges

Open Dtenwolde opened this issue 1 year ago • 2 comments

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.

  • IC6
  • IC9
  • IC10
  • IC11
  • IC13
  • IC14v1 & IC14v2
  • BI10
  • BI15

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 avatar Feb 06 '24 15:02 Dtenwolde

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 avatar Feb 07 '24 16:02 Dtenwolde

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

Dtenwolde avatar Feb 14 '24 10:02 Dtenwolde