Skip to content

CIP2026-03-18: Temporal Graph Queries — AS OF Clause#584

Open
ADunfield wants to merge 1 commit intoopencypher:mainfrom
DIGITAL-FABRIC-AI:cip/temporal-as-of
Open

CIP2026-03-18: Temporal Graph Queries — AS OF Clause#584
ADunfield wants to merge 1 commit intoopencypher:mainfrom
DIGITAL-FABRIC-AI:cip/temporal-as-of

Conversation

@ADunfield
Copy link

Summary

This CIP proposes a FOR VALID_TIME AS OF clause (shorthand: AS OF) for Cypher MATCH patterns, enabling point-in-time queries over relationships annotated with valid time periods.

Motivation

Temporal data — ownership changes, organisational structures, regulatory assignments, contract periods — is ubiquitous in graph modelling. Cypher has no native syntax for querying a graph as it existed at a point in time. Today, developers must write manual IS NULL OR predicates on every relationship hop, producing verbose, error-prone, and optimiser-opaque queries.

A three-hop temporal traversal today requires six predicates. This CIP reduces it to a single AS OF clause.

Proposed syntax

-- Single-hop point-in-time query
MATCH (e:Employee {id: $id})-[r:MANAGED_BY]->(m:Manager) AS OF date('2024-06-15')
RETURN m.name

-- Multi-hop temporal traversal
MATCH (f:Facility)-[:OWNED_BY]->(:Company)-[:SUBJECT_TO]->(:Authority) AS OF $asOf
RETURN *

Full EBNF, semantics, six examples, SQL:2011 alignment, and a Phase 1 parse-time rewrite rule (no storage changes required) are in the CIP document.

Reference implementation

A working implementation demonstrating these semantics as Neo4j procedures and user functions, validated on a production graph with 3.1M+ temporally-annotated relationships:

https://github.com/DIGITAL-FABRIC-AI/neo4j-temporal-graph

Prior art

Aligned with SQL:2011 FOR VALID_TIME AS OF semantics, adapted for Cypher's relationship-centric data model.


Author: Ashley Dunfield ashley@digital-fabric.com

Proposes FOR VALID_TIME AS OF / AS OF clause for MATCH patterns,
enabling point-in-time queries over temporally-annotated relationships
without verbose manual IS NULL OR predicate patterns.

Aligned with SQL:2011 valid time semantics. Includes EBNF grammar
additions, point-in-time predicate specification, six Cypher examples,
comparison with SQL/SPARQL/graph systems, benefits, caveats, and
a Phase 1 parse-time rewrite rule (no storage layer changes required).

Reference implementation (3.1M+ relationships, production-validated):
https://github.com/DIGITAL-FABRIC-AI/neo4j-temporal-graph

Authored-by: Ashley Dunfield <ashley@digital-fabric.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant