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

Inconsistent MIN aggregation function behavior with conditional MATCH clauses #868

Open
dracoooooo opened this issue Dec 23, 2024 · 1 comment · May be fixed by #894
Open

Inconsistent MIN aggregation function behavior with conditional MATCH clauses #868

dracoooooo opened this issue Dec 23, 2024 · 1 comment · May be fixed by #894
Assignees
Labels
bug Something isn't working

Comments

@dracoooooo
Copy link

Description:

When executing Cypher queries that involve the MIN aggregation function with conditional MATCH clauses, the function exhibits inconsistent behavior. Specifically, under certain conditions where no matches are found, MIN returns null in one scenario and an empty set in another, contrary to the documented behavior.

Steps to Reproduce:

  1. Create Nodes:

    CREATE (n1:N1 {v: 1});
    CREATE (n2:N2 {v: 2});
  2. Execute First MATCH Query:

    MATCH (n1:N1), (n2:N2)
    WHERE (1 = 2)
    RETURN MIN(1);
  3. Execute Second MATCH Query:

    MATCH (n1:N1), (n2:N2)
    WHERE (1 = 2 AND n1.v = n2.v)
    RETURN MIN(1);

Expected Behavior:

Both queries should return null when the WHERE condition evaluates to false.

Actual Behavior:

  • The first query returns null as expected.
  • The second query returns an empty set, which is inconsistent with the documentation.
@swilly22
Copy link
Contributor

Hi @dracoooooo thank you for sharing this with us,
Looking at the generated execution plan for the second query:

GRAPH.explain g "MATCH (n1:N1), (n2:N2) WHERE (1 = 2 AND n1.v = n2.v) RETURN MIN(1)"
1) "Results"
2) "    Filter"
3) "        Aggregate"
4) "            Value Hash Join | property(n1,v,0) = property(n2,v,0)"
5) "                Node By Label Scan | (n1:N1)"
6) "                Node By Label Scan | (n2:N2)"

We see an unnecessary operation Value Hash Join as the condition after reduction evaluates to simply false.
We'll look into it and make sure the Value Hash Join operation isn't utilized in such cases.

@swilly22 swilly22 added the bug Something isn't working label Dec 25, 2024
@AviAvni AviAvni linked a pull request Jan 5, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants