apoc
apoc copied to clipboard
apoc.nodes.group seems unable to use DateTime as a grouping operator
Issue by jgaskins
Saturday Mar 23, 2019 at 07:40 GMT
Originally opened as https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/1129
Expected Behavior (Mandatory)
Specifying min
or max
as a grouping operator on a datetime
property groups
Actual Behavior (Mandatory)
Specifying min
or max
as a grouping operator on a datetime
property results in an empty set.
I imagine this applies to other temporal types, as well, but I just happened to be using datetime
when I discovered it.
How to Reproduce the Problem
Simple Dataset (where it's possibile)
First we create some nodes with datetime
timestamps:
UNWIND range(1, 1000) AS minutes
CREATE (:Foo {
created_at: datetime({ year: 2019, month: 3, day: 23 }) - duration({minutes: minutes})
})
Then we truncate those timestamps to some level of granularity we'll be grouping on:
MATCH (foo:Foo)
WHERE NOT exists(foo.created_at_hour)
SET foo.created_at_hour = datetime.truncate('hour', foo.created_at)
Steps (Mandatory)
- Build the data set with the 2 Cypher queries above
- Execute [Query 1] below with no grouping operators, data is returned
- Execute [Query 2] below with a grouping operator specified for one of the
datetime
properties, no data is returned
[Query 1]
CALL apoc.nodes.group(['Foo'], ['created_at_hour'], [{}]) YIELD node
RETURN node
[Query 2]
CALL apoc.nodes.group(['Foo'], ['created_at_hour'], [{ created_at: 'min' }]) YIELD node
RETURN node
Screenshots (where it's possibile)
Specifications (Mandatory)
Currently used versions
Versions
- OS: Ubuntu 18.04
- Neo4j: 3.5.3 Community
- Neo4j-Apoc: 3.5.0.2