Skip to main content

Module executor

Module executor 

Source
Expand description

In-memory SQL execution engine for testing and validation.

Provides the ability to run SQL queries against Rust data structures, supporting SELECT with WHERE, GROUP BY, HAVING, ORDER BY, LIMIT/OFFSET, JOINs, aggregate functions, subqueries, CTEs, and set operations.

§Example

use std::collections::HashMap;
use sqlglot_rust::executor::{execute, Table, Value};

let mut tables = HashMap::new();
tables.insert("t".to_string(), Table::new(
    vec!["a".to_string(), "b".to_string()],
    vec![
        vec![Value::Int(1), Value::String("x".to_string())],
        vec![Value::Int(2), Value::String("y".to_string())],
    ],
));
let result = execute("SELECT a, b FROM t WHERE a > 1", &tables).unwrap();
assert_eq!(result.row_count(), 1);

Structs§

ResultSet
The result of executing a SQL query.
Table
An in-memory table with named columns and rows of values.

Enums§

Value
A SQL value that can be stored in a table cell or produced by expression evaluation.

Functions§

execute
Execute a SQL query string against the provided tables.
execute_statement
Execute a pre-parsed Statement against the provided tables.

Type Aliases§

Tables
A mapping of table names to in-memory tables.