Skip to main content

Crate polars_cypher

Crate polars_cypher 

Source
Expand description

§polars-cypher

Run Cypher queries on a property Graph stored as Parquet, using Polars.

A graph is written with a GraphWriter, or exported from Neo4j with Export (behind the neo4j feature). Graph::query then plans a query as a Polars LazyFrame, to collect or compose further.

use polars_cypher::Graph;

let graph = Graph::open("graph/")?;
let lf = graph
    .query("MATCH (p:Person) WHERE p.born < $year RETURN p.name")
    .parameter("year", 1970)
    .lazy()?;

§Cypher

Queries are read-only, of the form MATCH ... [WHERE ...] RETURN ..., supporting:

  • One or more comma-separated patterns, with node labels, relationship directions and types (:A|B), and inline property maps
  • Comparisons, arithmetic, AND/OR/NOT/XOR, IS [NOT] NULL, IN [...], and STARTS WITH/ENDS WITH/CONTAINS
  • Parameters ($x), bound with QueryBuilder::parameter
  • RETURN with aliases, DISTINCT, ORDER BY, SKIP, and LIMIT
  • Aggregations (count, sum, avg, min, max, collect) with implicit grouping
  • Functions id, labels, type, coalesce, toUpper, toLower, size, and abs

Variable-length relationships, OPTIONAL MATCH, WITH, UNWIND, and CASE aren’t supported yet.

Structs§

Error
A failure writing, opening, or querying a graph, with the underlying error as its source when there is one.
Export
Exports every node and relationship from a Neo4j database into a Graph.
Graph
A property Graph stored as a directory of Parquet tables, written by a GraphWriter.
GraphWriter
Writes a Graph incrementally, so it needn’t fit in memory.
Manifest
The tables of a Graph, as recorded in its manifest.json.
NodeId
The id of a node added to a GraphWriter, to add relationships between nodes with.
NodeTable
A table of the nodes with a label.
PropertySchema
A property column in a NodeTable or RelTable.
QueryBuilder
A Cypher query and its bound parameters, built with Graph::query.
RelTable
A table of the relationships of a type.

Enums§

BoundParameter
A query parameter value, bound with QueryBuilder::parameter.
PropertyType
The Polars column type of a property.
Value
A property value. Values without an equivalent variant should be converted to Value::String.

Type Aliases§

Properties
The properties of a node or relationship, by name.