Skip to main content

cypher_expr_to_df

Function cypher_expr_to_df 

Source
pub fn cypher_expr_to_df(
    expr: &Expr,
    context: Option<&TranslationContext>,
) -> Result<Expr>
Expand description

Convert a Cypher expression to a DataFusion expression.

Translates the Cypher AST representation into DataFusion’s expression model for use in filter predicates, projections, and aggregations.

§Arguments

  • expr - The Cypher expression to translate
  • context - Optional translation context for resolving variables

§Errors

Returns an error if the expression contains unsupported constructs such as list comprehensions, reduce expressions, or subqueries.

§Examples

use uni_query::query::ast::{Expr, Operator};
use uni_query::query::df_expr::cypher_expr_to_df;

// Simple property comparison: n.age > 30
let cypher_expr = Expr::BinaryOp {
    left: Box::new(Expr::Property(
        Box::new(Expr::Variable("n".to_string())),
        "age".to_string(),
    )),
    op: BinaryOp::Gt,
    right: Box::new(Expr::Literal(serde_json::json!(30))),
};

let df_expr = cypher_expr_to_df(&cypher_expr, None)?;
// Result: col("n.age") > lit(30)