Re: SQL Property Graph Queries (SQL/PGQ)

From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Ajay Pal <ajay(dot)pal(dot)k(at)gmail(dot)com>
Cc: Imran Zaheer <imran(dot)zhir(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SQL Property Graph Queries (SQL/PGQ)
Date: 2024-10-29 19:55:25
Message-ID: 0b862b93-dc70-4ba1-b27f-e09104bc4c2c@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Patches 0001 - 0006 are same as the previous set.
> 0007 - fixes all the problems you reported till now and also the one I
> found. The commit message describes the fixes in detail.

Hi,

I found a potential bug in the parsing of the left and right arrows.
They can be broken up in - > and < - respectively. Does the SQL/PGQ
standard really allow this?

I found this while working on a patch of our own and I was trying to
figure out how you guys had solved this very same problem that we ran
into, and if you had done so in a better way. The fundamental problem is
that parsing the left arrow as one token is a bit tricky due to how
PostgreSQL treats operators ending with minus or plus.

I have attached our very ugly solution for it (broken out from our
patch) in case it helps you. Feel free to use it or ignore it. We do not
plan to work on this right now since you are already working on the same
problem.

I especially dislike the static variable in our patch. And as far as I
understand it you can avoid the static by changing the lexer to use the
push parser so it can emit multiple terminal tokens from one parsed
token, but I have not looked into push parsers and have no idea how this
would affect performance.

https://www.gnu.org/software/bison/manual/html_node/Push-Decl.html

Examples:

# SELECT count(*) FROM GRAPH_TABLE (g1 MATCH ()-[]->() COLUMNS (1 as one));
count
-------
32
(1 row)

# SELECT count(*) FROM GRAPH_TABLE (g1 MATCH ()-[]- >() COLUMNS (1 as one));
count
-------
32
(1 row)

# SELECT * FROM GRAPH_TABLE (myshop MATCH (o IS orders)<-[IS
customer_orders]-(c IS customers) COLUMNS (c.name, o.ordered_when));
name | ordered_when
-----------+--------------
customer1 | 2024-01-01
customer2 | 2024-01-02
(2 rows)

# SELECT * FROM GRAPH_TABLE (myshop MATCH (o IS orders)< -[IS
customer_orders]-(c IS customers) COLUMNS (c.name, o.ordered_when));
name | ordered_when
-----------+--------------
customer1 | 2024-01-01
customer2 | 2024-01-02
(2 rows)

Andreas

Attachment Content-Type Size
0001-Broken-out-tokeniziation-of-arrows.patch text/x-patch 9.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-10-29 20:05:50 Re: Eager aggregation, take 3
Previous Message Raghuveer Devulapalli 2024-10-29 19:23:58 Re: Popcount optimization using AVX512