agensgraph icon indicating copy to clipboard operation
agensgraph copied to clipboard

Bug when use array_length() to limit var-length path's length

Open stupalpa opened this issue 8 months ago • 2 comments

Environment

Agensgraph Version: 2.15.0 Operating System: window 11 Installation Method: Docker API: Docker

Steps to Reproduce

Execute the following query:

MATCH (n0)-[m0*1..1]->(n1)-[m1*]->(n2) WHERE array_length(m0)=1 AND array_length(m1)=1 RETURN *;

The output is Error:

ERROR:  function array_length(edge[]) does not exist
LINE 1: MATCH (n0)-[m0*1..1]->(n1)-[m1*]->(n2) WHERE array_length(m0...

But when I execute:

MATCH (n0)-[m0*1..1]->(n1)-[m1*]->(n2), (n3 :L1)<-[r1 :T6]-(n4:L0) WHERE array_length(m0)=1 AND array_length(m1)=1 RETURN *;

I got the query result:

n0 | m0 | n1 | m1 | n2 | n3 | r1 | n4 
----+----+----+----+----+----+----+----
(0 rows)

I'm not sure why does the second query (with an additional pattern (n3:L1)<-[r1:T6]-(n4:L0)) bypass the array_length() error and return empty results, while the first query fails? Is there a ​​known workaround​​ for this issue until a fix is released? Thank you for your attention to this matter.

stupalpa avatar Apr 17 '25 08:04 stupalpa

@stupalpa I will look into this issue.

As a workaround, you can use length function.

MATCH (n0)-[m0*1..1]->(n1)-[m1*]->(n2) WHERE length(m0)=1 AND length(m1)=1 RETURN *;

MuhammadTahaNaveed avatar Apr 18 '25 08:04 MuhammadTahaNaveed

Thanks for the workaround! The length function works perfectly.

stupalpa avatar Apr 18 '25 09:04 stupalpa