Re: SQL Property Graph Queries (SQL/PGQ)

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: Junwang Zhao <zhjwpku(at)gmail(dot)com>
Cc: assam258(at)gmail(dot)com, zengman <zengman(at)halodbtech(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Amit Langote <amitlangote09(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-18 16:01:06
Message-ID: CAExHW5txUev5KuEqnzPTFTxL5JMyQgkYJL4FwX0AAgHD1_NydQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 18, 2026 at 6:45 PM Junwang Zhao <zhjwpku(at)gmail(dot)com> wrote:
>
> On Wed, Mar 18, 2026 at 7:49 PM Henson Choi <assam258(at)gmail(dot)com> wrote:
> >
> > Hi Junwang,
> >
> >>
> >> Yeah, I noticed that too, I will compose a patch for further review.
> >
> >
> > Great, looking forward to reviewing it.
>
> Here.

Thanks for the patch. I developed a similar patch parallely; attached
here. But I used the existing objects in graph_table.sql to add more
tests instead of creating a whole new set of objects. The new queries
test both the vertex as well as edge patterns as suggested by Henson.

In my patch I have added a test for forward reference, but didn't
implement the support for the same. I am not sure whether we want to
support forward references right now, for the reasons mentioned below

a. Other products allow cross referencing, but it seems it's optional
in SQL standard. Conformance rule 11 of subclause 10.6 seems to make
the feature optional. If that's the case, we need to throw an error in
case of cross reference. Peter, what do you think?

b. The graph pattern handling code will go through more revisions as
we support path list, nested path patterns, path pattern quantifiers
and other ways to specify path patterns. Implementing forward
referencing right now, in a way, that fits the current code might
create more work in future revisions. Doing it after we have a few
more of the above list supported, will require comparatively less
work. We may require subqueries to represent some path patterns like
embedded path patterns or path patterns with quantifiers. Forward
referencing in FROM clause is now allowed, so we will need to do magic
with condition pull to support forward referencing. Delaying the
forward referencing support till then is better.

c. It's not a blocker: users can write the forward referencing
condition in the graph pattern where clause instead of element pattern
where clause.

--
Best Wishes,
Ashutosh Bapat

Attachment Content-Type Size
v20260318-0002-Cross-variable-references-in-graph-pattern.patch text/x-patch 4.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-03-18 16:01:11 Re: Avoiding memory leakage in jsonpath evaluation
Previous Message Junwang Zhao 2026-03-18 15:58:07 Re: SQL Property Graph Queries (SQL/PGQ)