openCypher
openCypher copied to clipboard
Allow integer expressions in LIMIT clause
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.
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 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