Rust HogQL Parser Engine (src/lib.rs)

posthog · rust/hogql/parser/src/lib.rs · rust · MIT
database, dev-tools, analytics, lang:rust, tag:pyo3

A hand-rolled Rust HogQL query parser featuring precise structural decision points and PyO3 bindings for PostHog.

// Source: https://github.com/PostHog/posthog | License: MIT | Copyright 2020-2026 PostHog Inc
// Provided via justclaw.it.com; keep this notice with the code.
//! Hand-rolled Rust HogQL parser — ALL(*) variant.
//!
//! Forked from `hogql_parser_rs` at the ~99.88% cpp-parity baseline.
//! From here we make per-site upgrades to match cpp's ALL(*) behavior
//! exactly at the structural decision points that the Pratt+heuristic
//! parser couldn't resolve (BETWEEN body absorbing trailing AND,
//! lambda body inside an outer construct, paren-vs-subquery dispatch,
//! …). Each upgrade hard-codes whatever technique is fastest for that
//! specific site — AST surgery, scan probe, targeted backtrack — with
//! the cpp output as the spec.
//!
//! Each PyO3 entry point catches `ParseError`s and emits

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key