VALID
Generic Description
Filter rows by valid-time interval as of a point in time.
Simple example:
MATCH (e:Employment) VALID e.valid_from TO e.valid_to AS OF datetime('2025-01-15T00:00:00Z') RETURN e
Consumer-Level Explanation
Use VALID when the query must filter rows by valid-time interval as of a point in time and the planner needs to see that operation as part of the Cypher row pipeline. Keep the clause explicit because it controls row grain, variable scope, and what later clauses are allowed to reference.
More Detailed Explanation
VALID is about truth in the modeled domain, not only occurrence time. It is the right tool when facts have a period of validity and the query asks what was true at some moment.
What this clause is really for:
- it defines one concrete stage in the Cypher row pipeline, so variables available before and after
VALIDmust be clear - it should make graph structure, temporal filters, document payload shaping, or procedure output explicit instead of relying on client-side interpretation
- planner tooling depends on this clause boundary to know row grain, variable scope, and whether later expressions are reads, writes, schema operations, or projections
Advanced Example
This example keeps VALID inside a complete query pipeline so the clause boundary, visible variables, and returned row shape are clear to planner tooling.
MATCH (s:Sensor)-[r:EMITS]->(m:Measurement)
TIME r.ts BETWEEN datetime('2025-01-01T00:00:00Z') AND datetime('2025-01-07T00:00:00Z')
WITH s, r, m, date_trunc('hour', r.ts) AS bucket, properties(m) AS payload
RETURN s.sensor_id, bucket, keys(payload) AS payload_keys, unpivot(payload) AS metrics
ORDER BY bucket DESC
Real Use Cases
- policy or entitlement history
- contractual or legal validity windows
- business-state reconstruction with bitemporal flavor
Real Limitations And Tradeoffs
- requires disciplined modeling of validity endpoints
- easy to confuse with event time if naming is poor
- open-ended intervals need consistent handling in the data model