SAY-5 opened a new pull request, #2399:
URL: https://github.com/apache/age/pull/2399

   Fixes #2384.
   
   `age_tail()` in `src/backend/utils/adt/agtype.c` had an explicit early 
return that mapped both the empty-list and the singleton-list cases to SQL 
`NULL`:
   
   ```c
   count = AGT_ROOT_COUNT(agt_arg);
   /* if we have an empty list or only one element in the list, return null */
   if (count <= 1)
   {
       PG_RETURN_NULL();
   }
   ```
   
   The Cypher specification — and Neo4j / Memgraph, as shown in the issue — 
both define `tail(list)` as "the list without its first element". For a 
zero-or-one-element input that is an empty list `[]`, not `null`. Differential 
tests against Neo4j surface this divergence immediately.
   
   Removing the early return is enough: the loop below already iterates from `i 
= 1`, so it naturally emits `[]` for `count <= 1` and emits the correct tail 
for the general case. No behaviour change for `count >= 2`.
   
   Regression tests and expected output are updated accordingly — the two 
"should return null" cases at the end of the `tail()` section now expect `[]` 
and the comment is corrected.
   
   ```sql
   SELECT * FROM cypher('list', $$ RETURN tail([1]) $$) AS (tail agtype);   -- 
[]
   SELECT * FROM cypher('list', $$ RETURN tail([])  $$) AS (tail agtype);   -- 
[]
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to