Re: SQL Property Graph Queries (SQL/PGQ)

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
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-30 11:27:15
Message-ID: CAExHW5uU9rb5yTTKFG=VzhJnagS1LHWM2u5tsYRPzRie18vgJQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 30, 2025 at 3:14 PM Ashutosh Bapat
<ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> wrote:
>
> On Thu, Dec 18, 2025 at 2:45 PM Ashutosh Bapat
> <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> wrote:
> >
> >
> > >
> > > I did another investigation about whether this level of checking is
> > > necessary. I think according to the letter of the SQL standard, the
> > > typmods must indeed match. It seems Oracle does not check (the example
> > > mentioned above came from an Oracle source). But I think it's okay to
> > > keep the check. In PostgreSQL, it is much less common to write like
> > > varchar(1000). And we can always consider relaxing it later.
> >
> > +1.
> >
> > Attached patch adds a couple more test statements.
> >
>
> Squashed this into the main patchset.
>
> > >
> > > 2) I had it in my notes to consider whether we should support the colon
> > > syntax for label expressions. I think we might have talked about that
> > > before.
> > >
> > > I'm now leaning toward not supporting it in the first iteration. I
> > > don't know that we have fully explored possible conflicts with host
> > > variable syntax in ecpg and psql and the like. Maybe avoid that for now.
> > >
> >
> > I was aware of ecpg and I vaguely remember we fixed something in ECPG
> > to allow : in MATCH statement. Probably following changes in
> > psqlscan.l and pgc.l
> > -self [,()\[\].;\:\+\-\*\/\%\^\<\>\=]
> > +self [,()\[\].;\:\|\+\-\*\/\%\^\<\>\=]
> >
> > Those changes add | after : (and not the : itself) so maybe they are
> > not about supporting : . Do you remember what those are?
>
> I reverted those changes from both the files and ran "meson test". I
> did not observe any failure. It seems those changes are not needed.
> But adding them as a separate commit (0004) in case CI bot reveals any
> failures without them.
>
> I noticed that there were no ECPG tests for SQL/PGQ. Added a basic
> test in patch 0003.
>
> >
> > I spotted some examples that use : in ddl.sgml.
> > <programlisting>
> > SELECT customer_name FROM GRAPH_TABLE (myshop MATCH
> > (c:customer)-[:has]->(o:"order" WHERE o.ordered_when = current_date)
> > COLUMNS (c.name AS customer_name));
> > </programlisting>
> >
> > The query demonstrates that one can use label names in a way that will
> > make the pattern look like an English sentence. Replacing : with IS
> > defeats that purpose.
> >
> > As written in that paragraph, the labels serve the purpose of exposing
> > the table with a different logical view (using different label and
> > property names). So we need that paragraph, but I think we should
> > change the example to use IS instead of :. Attached is suggested
> > minimal change, but I am not happy with it. Another possibility is we
> > completely remove that paragraph; I don't think we need to discuss all
> > possible usages the users will come up with.
> >
> > The patch changes one more instance of : by IS. But that's straight forward.
> >
> > In ddl.sgml I noticed a seemingly incomplete sentence
> > A property graph is a way to represent database contents, instead of using
> > relational structures such as tables.
> >
> > Represent the contents as what? I feel the complete sentence should be
> > one of the following
> > property graph is a way to represent database contents as a graph,
> > instead of representing those as relational structures OR
> > property graph is another way to represent database contents instead
> > of using relational structures such as tables
> >
> > But I can't figure out what was originally intended.
>
>
> 0002 contains some edits to this part of documentation. I think the
> paragraph reads better than before. Let me know what you think.
>
> Please let me know which of 0002 to 0004 look good to you. I will
> squash those into the patchset in the next version.

The previous patchset had a whitespace difference in ECPG expected
output files. Fixed in the attached patchset.

--
Best Wishes,
Ashutosh Bapat

Attachment Content-Type Size
v20251230-2-0001-WIP-SQL-Property-Graph-Queries-SQL-PGQ.patch text/x-patch 663.0 KB
v20251230-2-0002-Fix-some-more-references-and-edit-document.patch text/x-patch 6.2 KB
v20251230-2-0004-Possibly-unnecessary-changes.patch text/x-patch 1.5 KB
v20251230-2-0003-Test-SQL-PGQ-with-ECPG.patch text/x-patch 27.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message cca5507 2025-12-30 11:48:44 Minor refactor in catcache.c
Previous Message Daniil Davydov 2025-12-30 10:07:22 Re: Wrong comment for ReplicationSlotCreate