age icon indicating copy to clipboard operation
age copied to clipboard

SKIP clause contradicts docs: error when using computed variable

Open zihaozeng0021 opened this issue 2 months ago • 4 comments

Configuration

AGE Version: apache/age:latest (pulled 2025-12-07)

Operating System: WSL2 – Ubuntu 24.04.1 LTS

Installation Method: Docker


Steps to reproduce

  1. Start AGE via Docker
docker run \
  --name age \
  -p 5455:5432 \
  -e POSTGRES_USER=postgresUser \
  -e POSTGRES_PASSWORD=postgresPW \
  -e POSTGRES_DB=postgresDB \
  -d \
  apache/age:latest
  1. Connect with psql
PGPASSWORD='postgresPW' psql -h localhost -p 5455 -U postgresUser -d postgresDB
  1. Run the following query
CREATE EXTENSION IF NOT EXISTS age;

LOAD 'age';
SET search_path = ag_catalog, "$user", public;

SELECT create_graph('test_graph');

SELECT *
FROM cypher('test_graph', $$
  WITH 1 AS skipAmount
  UNWIND [1, 2] AS a
  RETURN a
  SKIP skipAmount
$$) AS (a agtype);

Expected behaviour

The query runs sucessfully

Actual behaviour

The query failed with the message:

ERROR:  argument of SKIP must not contain variables
LINE 7:   SKIP skipAmount

Key points:

  1. There is a contradiction between this result and the documentation.
  2. The documentation states SKIP accepts any expression that evaluates to a positive integer.
  3. Expressions are combinations of variables and numbers, and the skipAmount is a variable that is always 1 (a positive integer). However, the results state that the argument of SKIP must not contain variables.

zihaozeng0021 avatar Dec 07 '25 01:12 zihaozeng0021

@zihaozeng0021 Per the openCypher specification, only an expression can be used. An expression is not to be confused with a variable.

jrgemignani avatar Dec 09 '25 16:12 jrgemignani

@jrgemignani I wish to further argue for the issue.

From a mathematical perspective, I am 100% sure that a variable can be considered an expression.

From a query language perspective, I’m not as certain, but here is a supporting documentation:

The Cypher Query Language Reference (Version 9) states that An expression in Cypher can be a variable (See page 36).

Image

zihaozeng0021 avatar Dec 09 '25 23:12 zihaozeng0021

@zihaozeng0021 You can argue that all you want :) I would suggest taking it up with Neo4j who is the creator of Cypher :)

Unfortunately, in this particular case, an expression is just an expression, not a variable. Neo4j's documents state just that and if you use their docker container, it says just that when you enter your query. Apache AGE tries to be as close to 100% compatible with Neo4j where possible. The Boolean issue is an example of where we can't be.

jrgemignani avatar Dec 10 '25 01:12 jrgemignani

Thanks for your suggestion.

I previously reported the same issue to Neo4j, but I haven’t received a response yet. I’ll update here once they accept or decline it.

zihaozeng0021 avatar Dec 10 '25 02:12 zihaozeng0021