Skip to content

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

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

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
Copy Markdown

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>
@hvub
Copy link
Copy Markdown
Contributor

hvub commented Apr 20, 2026

Hello Ashley,

Thank you very much for this interesting proposal. As you can see on the openCypher website, "with ISO/IEC 39075 GQL, the purpose of openCypher is to pave the road to GQL for openCypher implementers. Changes to openCypher are made by adding GQL features to openCypher."

Unfortunately, your CIP does not propose functionality standardized in GQL at this point.

The route for adding functionality to openCypher is to contribute ISO/IEC 39075 GQL, which you can do by joining your national standards body.

The ISO/IEC JTC1 SC32 WG3, the working group responsible for GQL, has an open Language Opportunity — think of a backlog item — for bi-temporal support. However, there is a significant amount of work required to make the happen, even with the SQL precedence, so that no one has picked it up yet.

Thanks + Best
-Hannes

@hvub hvub closed this Apr 20, 2026
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.

2 participants