age icon indicating copy to clipboard operation
age copied to clipboard

List comprehensions

Open ilyalasy opened this issue 2 years ago • 8 comments

Hey, are list comprehensions supported in AGE? Using syntax from Neo4j doesnt seem to work, simple example:

SELECT * FROM cypher('g1', $$
MATCH (v)
RETURN [x in v.array_field]
$$) as (a agtype);

ilyalasy avatar Aug 17 '21 12:08 ilyalasy

You mean that this query(array_field) is working or not with AGE?

I tried that query. Once it works as 'query' (return as jsonb from Pgadmin).

But I'm not sure this result is correct(Because it returns null).

Someone who knows this issue?

Halkrine avatar Aug 17 '21 14:08 Halkrine

You mean that this query(array_field) is working or not with AGE?

I tried that query. Once it works as 'query' (return as jsonb from Pgadmin).

But I'm not sure this result is correct(Because it returns null).

Someone who knows this issue?

array_field is some random array which is an attribute of a graph vertex. i'm trying it with AGE and receiving following error:

ERROR:  variable `x` does not exist
LINE 3: RETURN [x in v.array_field]

ilyalasy avatar Aug 17 '21 14:08 ilyalasy

replace x -> v and try it.

Halkrine avatar Aug 17 '21 14:08 Halkrine

replace x -> v and try it.

no, it should be another variable: it should iterate through the array like in any list comprehension

ilyalasy avatar Aug 17 '21 14:08 ilyalasy

Understood.

Maybe, that function is not supported yet now..

Halkrine avatar Aug 18 '21 05:08 Halkrine

Hi, List Comprehensions are not currently supported

JoshInnis avatar Aug 18 '21 15:08 JoshInnis

Its a useful feature. Not sure if it will be the case on AGE but with Neo4j they can especially help with performance.

jasperblues avatar Sep 20 '22 00:09 jasperblues

List comp. was "nearly" completed until it was found to have serious issues for any nested cases. It will be revisited soon.

jrgemignani avatar Sep 20 '22 16:09 jrgemignani