openCypher icon indicating copy to clipboard operation
openCypher copied to clipboard

Allow integer expressions in LIMIT clause

Open fbiville opened this issue 7 years ago • 2 comments

This is currently forbidden:

$> UNWIND [1,2,3] AS x WITH x,2 as foo RETURN x LIMIT foo
Error: org.neo4j.graphdb.QueryExecutionException: It is not allowed to refer to variables in LIMIT

This specific example would of course directly benefit from constant folding but the issue is about the general case, where foo can be any computable integer expression.

fbiville avatar Mar 06 '17 10:03 fbiville

I think the real problem here is that this will only work if the variable is the same for all rows. What if foo is based upon some differing computation between rows? On some rows foo is 200, on others foo is -4, on some foo is zero. How should we resolve this?

InverseFalcon avatar Mar 06 '17 10:03 InverseFalcon

@InverseFalcon I'm not sure how simple it is to detect this kind of dependent expression but allowing "independent" variables (and disallowing the rest) would already be a big step forward

fbiville avatar Mar 06 '17 10:03 fbiville