Re: SQL Property Graph Queries (SQL/PGQ)

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Cc: Amit Langote <amitlangote09(at)gmail(dot)com>, Junwang Zhao <zhjwpku(at)gmail(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>, Ajay Pal <ajay(dot)pal(dot)k(at)gmail(dot)com>, Imran Zaheer <imran(dot)zhir(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SQL Property Graph Queries (SQL/PGQ)
Date: 2025-12-13 19:57:56
Message-ID: d290c749-9ebb-46a2-845d-5842ce0da626@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 09.12.25 11:21, Ashutosh Bapat wrote:
>> It looks like undirected matching -[ ]- (without arrows) doesn't work
>> correctly. It seems to just match in one direction. I don't see any
>> tests. Is this implemented?
>>
> -[]- is called full edge any direction
> <full edge any direction> ::=
> <minus left bracket> <element pattern filler> <right bracket minus>
>
> ~[]~ is defined as full edge undirected
> <full edge undirected> ::=
> <tilde left bracket> <element pattern filler> <right bracket tilde>
>
> The patch supports full edge any direction since [1] in response to
> Ajay Pal's report. Such a pattern matches edges in both the
> directions. There's also a test
> -- edges directed in both ways - to and from v2
> SELECT * FROM GRAPH_TABLE (g1 MATCH (v1 IS vl2)-[conn]-(v2) COLUMNS
> (v1.vname AS v1name, conn.ename AS cname, v2.vname AS v2name));
> v1name | cname | v2name
> --------+-------+--------
> v21 | e122 | v12
> v22 | e121 | v11
> v22 | e231 | v32
> (3 rows)
>
> SELECT * FROM GRAPH_TABLE (g1 MATCH (v1 IS vl2)-(v2) COLUMNS (v1.vname
> AS v1name, v2.vname AS v2name));
> v1name | v2name
> --------+--------
> v21 | v12
> v22 | v11
> v22 | v32
> (3 rows)
>
> it's matching edges to and from vertices in v2. For example e121 is an
> edge from v11 to v22 whereas e231 is an edge from v22 to v32.

Attached is a test case from an Oracle web site (the URL is in the
file). At the end there are three queries, one left, one right, one any
direction. The latter should result in the union of the first two, but
it doesn't.

Attachment Content-Type Size
test2.sql text/plain 4.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-12-13 21:25:50 Re: Making jsonb_agg() faster
Previous Message Antonin Houska 2025-12-13 19:39:21 Re: Adding REPACK [concurrently]