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: assam258(at)gmail(dot)com, Alexander Lakhin <exclusion(at)gmail(dot)com>, 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: 2026-03-25 09:34:47
Message-ID: 72a23702-6d96-4103-a54b-057c2352e885@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 25.03.26 10:12, Ashutosh Bapat wrote:
> On Wed, Mar 25, 2026 at 2:27 PM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>>
>> On 23.03.26 16:00, Ashutosh Bapat wrote:
>>> An empty pattern has no label expression which is equivalent to
>>> disjunction of all applicable labels. If we add an empty pattern in
>>> the rewrite phase, we will require its label expression to be resolved
>>> in the rewrite phase. Looking at the proposed changes for all
>>> properties reference [1], I am moving towards resolving the label
>>> expression in the transformation stage itself. So I think it's better
>>> to add the implicit vertex patterns during the transformation stage to
>>> be future proof. Rewriter should just then rewrite the patterns into
>>> joins and unions. Your point is correct that the implicit vertex
>>> should not be visible in view definition or deparsed query. For that I
>>> have added a flag implicit to GraphElementPattern.
>>> GraphElementPatterns with implicit = true are ignored by ruleutils.
>>> Implemented it that way in the attached patch.
>>>
>>> Vertex patterns without an edge pattern in between are not supported
>>> OTOH. Added an ereport for the same.
>>>
>>> I have also added a few tests. I didn't add queries with all the
>>> patterns you mentioned above. I tested a few by hand and all of them
>>> worked as expected. Can you please check?
>>
>> This functionality that you can leave off empty vertex patterns at the
>> beginning and end is part of the optional feature G047, which we don't
>> claim to support. So we should reject these path patterns.
>>
>
> Thanks for the clarification. What about the implicit empty vertex
> patterns in the middle of the path? Should we reject these path
> patterns also?
Yes, I think so.

The specification of feature G047 is:

"... in conforming SQL language, any <edge pattern> shall be immediately
preceded and followed by a <vertex pattern>."

So if you write

() -[]-> -[]-> ()

then the first edge pattern is not followed immediately by a vertex
pattern, and so it would be invalid without feature G047.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2026-03-25 09:51:26 Re: [PATCH] Precompute string lengths in PerformRadiusTransaction
Previous Message shveta malik 2026-03-25 09:33:27 Re: [Patch] add new parameter to pg_replication_origin_session_setup