Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Using LIMIT/SKIP/ORDER BY with UNION is only applied to the last union set #1879

Closed
wenic opened this Issue · 8 comments

6 participants

chris Michael Hunger Wes Freeman Chris Leishman somnathmuluk Zonito
chris

with the following cypher query;

MATCH (movie:com.test.domain.Movie) WHERE NOT (movie)<-[:RATED]-()
RETURN movie, 0.0 AS avgStars
UNION ALL
MATCH (movie:com.test.domain.Movie)<-[r:RATED]-() WITH movie, avg(r.stars) AS avgStars
RETURN movie, avgStars
LIMIT 100

LIMIT is only applied to the result set of the last MATCH, so it will limit the last MATCH to 100 and include what ever rows the first MATCH returns.

Same happens when using SKIP and ORDER BY.

Michael Hunger
Collaborator

You can apply a separate limit / skip / oder by to the first match too

Wes Freeman

I think this is a valid feature request that I've been interested in as well. There's no way to apply a limit to the overall query (similarly, you can't aggregate over the UNION, etc.).

chris

sorry, i should have said the expected results would be. As wfreeman says would be good if you could apply the skip, limit, order by to the overall query.

The original issue came across when I tried to make the results pagable, so instead of getting a page of 100 results I got 100+. The issue was more noticeable, for example when you apply order by on the movie.title; the list you get back, the first half is unsorted and the second half is sorted.

So if you apply an order by on the first match as well, what you get back is two ordered lists joined together so you get [(A-Z)(A-Z)] and not the overall [A-Z] list.

Chris Leishman
Collaborator

Yes, this is a current known limitation in the use of UNION. We'll look at ways to improve it in future.

chris

Thanks, would be good to see it working. Had a read around stackoverflow, but haven't found an alternative query that could do the same thing.

somnathmuluk

Is this feature is released?

Zonito

Can we have approx estimation time?

Thanks!

Chris Leishman
Collaborator

Will track this in #2725

Chris Leishman cleishm closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.