toTypedList
Generic Description
Wraps or accepts a list and coerces each element to a requested element type. It is documented separately because explicit type boundaries prevent planner tools from inventing hidden coercions for document-style values.
Simple example:
RETURN toTypedList(['1', '2'], 'INTEGER') AS value
Consumer-Level Explanation
Use it when imported arrays need an explicit homogeneous type before analytics. Prefer this function when the input shape is mixed or imported and the query must state the intended type before comparison or aggregation.
More Detailed Explanation
toTypedList makes value shape explicit in Cypher. It is most useful around ingestion, document payloads, and assistant-generated queries where the planner should see the intended type boundary rather than relying on hidden client conversion.
Advanced Example
This example applies toTypedList at the point where a semi-structured value enters typed query logic, making the conversion boundary explicit.
WITH ['1', '2', '3'] AS raw_scores
RETURN raw_scores, toTypedList(raw_scores, 'INTEGER') AS score_list
Real Use Cases
- normalizing imported CSV or document fields before comparison
- guarding mixed payloads before list, map, or numeric operations
- making assistant-authored query contracts explicit and reviewable
Real Limitations And Tradeoffs
- conversion only works when the input can be interpreted unambiguously
- heavy conversion inside analytical queries can hide ingestion contract problems
- type checks describe runtime values, not full schema validation