Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List comprehension as property constraint of MERGE clause errors out #1611

Open
MuhammadTahaNaveed opened this issue Feb 14, 2024 · 2 comments
Labels
bug Something isn't working override-stale To keep issues/PRs untouched from stale action

Comments

@MuhammadTahaNaveed
Copy link
Member

Describe the bug
List comprehension as property constraint of MERGE clause errors out.

How are you accessing AGE (Command line, driver, etc.)?

  • command line

What is the command that caused the error?

SELECT * from cypher('graph_name', $$
  MERGE ({list:[u IN [1,2,3]]})
$$) as (a agtype);
ERROR:  Aggref found in non-Agg plan node

Expected behavior
Should execute without any error.

Environment (please complete the following information):

  • Version: latest
@MuhammadTahaNaveed MuhammadTahaNaveed added the bug Something isn't working label Feb 14, 2024
@diangamichael
Copy link

To apply a workaround to the query and avoid using list comprehensions in the MERGE clause, you can modify the query to precompute the list before using it in the MERGE clause. Here's how you can rewrite the query:

WITH input_list AS (
SELECT [1,2,3] AS list
)
SELECT * FROM cypher('graph_name', $$
MERGE ({list: u.list})
ON CREATE SET ...
ON MATCH SET ...
$$) AS (a agtype);
In this modified query:

We first create a Common Table Expression (CTE) named input_list to compute the list [1,2,3].
Then, we reference this computed list u.list within the MERGE clause.
You need to replace ON CREATE SET ... and ON MATCH SET ... with the appropriate actions you want to perform when the MERGE clause creates or matches a node.
By precomputing the list outside the MERGE clause, we avoid using list comprehensions directly within it, potentially bypassing the error you encountered.

To apply a workaround to the query and avoid using list comprehensions in the MERGE clause, you can modify the query to precompute the list before using it in the MERGE clause. Here's how you can rewrite the query:

sql
Copy code
WITH input_list AS (
SELECT [1,2,3] AS list
)
SELECT * FROM cypher('graph_name', $$
MERGE ({list: u.list})
ON CREATE SET ...
ON MATCH SET ...
$$) AS (a agtype);
In this modified query:

We first create a Common Table Expression (CTE) named input_list to compute the list [1,2,3].
Then, we reference this computed list u.list within the MERGE clause.
You need to replace ON CREATE SET ... and ON MATCH SET ... with the appropriate actions you want to perform when the MERGE clause creates or matches a node.
By precomputing the list outside the MERGE clause, we avoid using list comprehensions directly within it, potentially bypassing the error you encountered.

@sir-sa
Copy link

sir-sa commented Apr 9, 2024

SELECT * FROM cypher('graph_name', $$
UNWIND [1,2,3] AS value
MERGE (n {property: value})
$$) AS (a agtype);

@MuhammadTahaNaveed MuhammadTahaNaveed added the override-stale To keep issues/PRs untouched from stale action label May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working override-stale To keep issues/PRs untouched from stale action
Projects
None yet
Development

No branches or pull requests

3 participants