hogql-parser-rs
Hand-rolled Rust HogQL parser with C++-parity AST output
Decision gist · record as of 2026-08-14
Yes, if you are using PostHog and need faster HogQL parsing. The package is actively maintained, has no known vulnerabilities, and delivers substantial performance gains (15–50×) over the C++ reference. Install friction is moderate due to compiled wheels, but prebuilt binaries cover common platforms. The MIT license is permissive. Only caveat: you must run Python 3.12+, and the parser is designed as a PostHog internal tool—verify that your use case aligns with its role as a C++ parser candidate rather than a standalone HogQL implementation.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.12 or later; prebuilt wheels available for common platforms but local Rust toolchain needed if building from source.
- Medium install friction due to compiled Rust wheels; prebuilt binaries exist for Linux (x86_64/aarch64, manylinux 2_28 + musllinux 1_2) and macOS (arm64/x86_64), all targeting Python 3.12+.
- Active maintenance with recent releases.
License · maintenance · safety
MIT (permissive) — MIT license permits unrestricted use, modification, and distribution with minimal attribution requirements.
last release 2026-07-12 (33 days) · last repo commit 2026-08-14 · 37,684 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,078,797 downloads/mo, #3,310 on PyPI
Alternatives
Verify before relying
import hogql_parser_rs
result = hogql_parser_rs.parse_expr_json('1 + 2')
print(result)- Whether the parser handles all HogQL grammar features or only a subset of the C++ reference implementation.
- Performance benchmarks against the C++ parser on real-world PostHog query workloads beyond the synthetic `parse_expr` and `parse_select` tests.
- Stability guarantees for the JSON AST shape across minor version updates.
What it is and what it does
hogql_parser_rs is a Rust-based HogQL query parser that emits JSON AST output compatible with PostHog's C++ ANTLR reference parser. It exposes five PyO3 entry points (`parse_expr_json`, `parse_select_json`, `parse_program_json`, `parse_order_expr_json`, `parse_full_template_string_json`) that return JSON strings; parse errors are wrapped in an error envelope that PostHog's `posthog/hogql/json_ast.py` decodes into structured exceptions.
The parser is hand-rolled using Pratt + recursive descent techniques and deliberately maintains AST shape parity with the C++ parser to enable cross-validation. It ships as a compiled Python extension via maturin, targeting Python 3.12+ across Linux (x86_64/aarch64), macOS (arm64/x86_64), and musl-based systems. The implementation includes a lexer, expression parser with binding-power precedence, and per-rule parsing modules; the C++ ANTLR parser is treated as the source of truth for grammar and AST shape, making this a performance-optimized candidate implementation rather than an independent parser.
Use it for
- Accelerate HogQL query parsing in PostHog analytics pipelines where parse latency is a bottleneck.
- Validate HogQL syntax and generate AST for query planning or optimization without invoking the C++ parser.
- Drive parser-parity fuzzing and regression testing via the coverage-instrumented build mode (`--features coverage`).
- Embed HogQL parsing in Python applications that need fast, deterministic query expression evaluation.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you are using PostHog and need faster HogQL parsing.
The package is actively maintained, has no known vulnerabilities, and delivers substantial performance gains (15–50×) over the C++ reference. Install friction is moderate due to compiled wheels, but prebuilt binaries cover common platforms. The MIT license is permissive. Only caveat: you must run Python 3.12+, and the parser is designed as a PostHog internal tool—verify that your use case aligns with its role as a C++ parser candidate rather than a standalone HogQL implementation.
Install
hogql-parser-rs on PyPI
Before you install
Medium install friction due to compiled Rust wheels; prebuilt binaries exist for Linux (x86_64/aarch64, manylinux 2_28 + musllinux 1_2) and macOS (arm64/x86_64), all targeting Python 3.12+. Active maintenance with recent releases.
Requires Python 3.12 or later; prebuilt wheels available for common platforms but local Rust toolchain needed if building from source.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal attribution requirements.
Quickstart
import hogql_parser_rs
result = hogql_parser_rs.parse_expr_json('1 + 2')
print(result)
Verify before relying
- Whether the parser handles all HogQL grammar features or only a subset of the C++ reference implementation.
- Performance benchmarks against the C++ parser on real-world PostHog query workloads beyond the synthetic `parse_expr` and `parse_select` tests.
- Stability guarantees for the JSON AST shape across minor version updates.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.12 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 33 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,078,797 / month, #3,310 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Rust |
Evidence: hogql_parser_rs-1.3.108-cp312-abi3-macosx_10_12_x86_64.whl; hogql_parser_rs-1.3.108-cp312-abi3-macosx_11_0_arm64.whl; hogql_parser_rs-1.3.108-cp312-abi3-manylinux_2_28_aarch64.whl; hogql_parser_rs-1.3.108-cp312-abi3-manylinux_2_28_x86_64.whl; hogql_parser_rs-1.3.108-cp312-abi3-musllinux_1_2_aarch64.whl; hogql_parser_rs-1.3.108-cp312-abi3-musllinux_1_2_x86_64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “query expression parsing”
- hogql-parser-rsParses HogQL query expressions into JSON AST format via a hand-rolled…
- promql-parserParses Prometheus query language (PromQL) expressions into a…
- hogql-parserParses HogQL query expressions and Hog programs into abstract syntax…
Give your agent the search over MCP, or paste the wish link into any chat.
More Text Processing packages
A drop-in replacement for Python's standard `re` module that adds advanced regex features like nested sets, fuzzy matching, lookaround in conditionals, and full Unicode case-folding while maintaining backward compatibility.
pyparsing provides a library for building text parsers directly in Python code using composable grammar classes, handling quoted strings, whitespace variation, and embedded comments without regex or lex/yacc.
Install it if you need to parse text or define grammars programmatically.
fonttools manipulates font files in multiple formats (TrueType, OpenType, AFM, Type 1, Mac-specific) and includes TTX, a tool to convert fonts to and from XML text format.
Install it if you need to read, write, or manipulate fonts programmatically or via the TTX command-line tool.
Docutils converts plaintext documentation in reStructuredText format into multiple output formats including HTML, XML, and LaTeX using a modular processing system.
RapidFuzz provides fast fuzzy string matching using Levenshtein Distance and related metrics, implemented mostly in C++ with Python bindings for rapid similarity scoring and approximate string matching.
Install it if you need fuzzy string matching; it's a solid replacement for FuzzyWuzzy with better licensing and performance.
tinycss2 parses CSS strings into token and block objects, and generates CSS strings from those objects, following the CSS Syntax Level 3 specification without enforcing specific properties or values.
Install it if your project requires CSS tokenization or syntax manipulation.
See also ast-serialize · cql2 · hogql-parser · moviepilot-rust · promql-parser · tree-sitter-rust · fugue-sql-antlr · lark-parser · tree-sitter-swift · sqlfluffrs