Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(hogql): default parser mode to rust-py with cpp shadow (#60430)

Robbiec09748a29c78
diff --git a/ee/hogai/chat_agent/sql/mixins.py b/ee/hogai/chat_agent/sql/mixins.py
index f533f8742d7d..5244f899d511 100644
--- a/ee/hogai/chat_agent/sql/mixins.py
+++ b/ee/hogai/chat_agent/sql/mixins.py
@@ -168,9 +168,14 @@ class HogQLOutputParserMixin(HogQLDatabaseMixin):
prepare_and_print_ast(parsed_query, context=hogql_context, dialect="clickhouse")
except (ExposedHogQLError, HogQLNotImplementedError, QueryError, ResolutionError) as err:
err_msg = str(err)
- if err_msg.startswith("no viable alternative"):
- # The "no viable alternative" ANTLR error is horribly unhelpful, both for humans and LLMs
- err_msg = 'ANTLR parsing error: "no viable alternative at input". This means that the query isn\'t valid HogQL.'
+ # Both the antlr-based cpp parser and the hand-rolled rust-py parser produce
+ # terse low-level error wording on syntax failures ("no viable alternative…",
+ # "trailing tokens after expression…", "unexpected token in expression…").
+ # Replace any of them with a single human/LLM-friendly message.
+ if err_msg.startswith(
+ ("no viable alternative", "trailing tokens after expression", "unexpected token in expression")
+ ):
+ err_msg = "HogQL parsing error: this query isn't valid HogQL."
raise PydanticOutputParserException(llm_output=cleaned_query, validation_message=err_msg)
return AssistantHogQLQuery(query=cleaned_query)
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index f5b3f99fbcda..405db7502b46 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -22289,7 +22289,7 @@
"type": "boolean"
},
"parserMode": {
- "description": "HogQL parser backend; absent → `cpp_with_rust_py_shadow` (cpp is primary, rust-py runs as a sampled shadow). `*_shadow` modes return the primary result and sample-compare against the other parser, reporting divergences without failing the request. The `rust_py_*` modes drive the same hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast` dataclass instances directly via PyO3, skipping the JSON round-trip.",
+ "description": "HogQL parser backend; absent → `rust_py_with_cpp_shadow` (rust-py is primary, cpp runs as a sampled shadow). `*_shadow` modes return the primary result and sample-compare against the other parser, reporting divergences without failing the request. The `rust_py_*` modes drive the same hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast` dataclass instances directly via PyO3, skipping the JSON round-trip.",
"enum": [
"cpp_only",
"cpp_with_rust_shadow",
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index a357ca55b725..dad4c9e8efbf 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -454,7 +454,7 @@ export interface HogQLQueryModifiers {
/** If these are provided, the query will fail if these skip indexes are not used */
forceClickhouseDataSkippingIndexes?: string[]
inlineCohortCalculation?: 'off' | 'auto' | 'always'
- /** HogQL parser backend; absent → `cpp_with_rust_py_shadow` (cpp is primary, rust-py runs as a sampled shadow). `*_shadow` modes return the primary result and sample-compare against the other parser, reporting divergences without failing the request. The `rust_py_*` modes drive the same hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast` dataclass instances directly via PyO3, skipping the JSON round-trip. */
+ /** HogQL parser backend; absent → `rust_py_with_cpp_shadow` (rust-py is primary, cpp runs as a sampled shadow). `*_shadow` modes return the primary result and sample-compare against the other parser, reporting divergences without failing the request. The `rust_py_*` modes drive the same hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast` dataclass instances directly via PyO3, skipping the JSON round-trip. */
parserMode?:
| 'cpp_only'
| 'cpp_with_rust_shadow'
diff --git a/posthog/clickhouse/client/test/test_execute_async.py b/posthog/clickhouse/client/test/test_execute_async.py
index f3b7076df26f..20ee32bd52e0 100644
--- a/posthog/clickhouse/client/test/test_execute_async.py
+++ b/posthog/clickhouse/client/test/test_execute_async.py
@@ -197,7 +197,7 @@ class ClickhouseClientTestCase(TestCase, ClickhouseTestMixin):
self.assertIsNotNone(result.pickup_time)
self.assertIsNotNone(result.end_time)
assert result.error_message
- self.assertRegex(result.error_message, "no viable alternative at input")
+ self.assertRegex(result.error_message, "trailing tokens after expression")
def test_async_query_server_errors(self):
query = build_query("SELECT * FROM events")
diff --git a/posthog/hogql/metadata.py b/posthog/hogql/metadata.py
index a6a669a1ef39..bb6e452cda69 100644
--- a/posthog/hogql/metadata.py
+++ b/posthog/hogql/metadata.py
@@ -117,7 +117,8 @@ def get_hogql_metadata(
response.isValid = False
if isinstance(e, ExposedHogQLError):
error = str(e)
- if "mismatched input '<EOF>' expecting" in error:
+ # cpp-json (ANTLR) and rust-py word EOF differently; collapse both into a single human-readable string.
+ if "mismatched input '<EOF>' expecting" in error or "unexpected token in expression: Eof" in error:
error = "Unexpected end of query"
if e.end and e.start and e.end < e.start:
response.errors.append(HogQLNotice(message=error, start=e.end, end=e.start))
diff --git a/posthog/hogql/parser.py b/posthog/hogql/parser.py
index a8eba54e22a7..c7506a644611 100644
--- a/posthog/hogql/parser.py
+++ b/posthog/hogql/parser.py
@@ -239,10 +239,10 @@ _PARSER_MODE_BACKENDS: dict[ParserMode, tuple[HogQLParserBackend, HogQLParserBac
ParserMode.RUST_PY_WITH_CPP_SHADOW: ("rust-py", "cpp-json"),
}
-# Fraction of `*_shadow` parses in PROD that also run the shadow backend. Held at 1% for the rust-py rollout: a latent
-# rust-py pathology (slow parse, crash) then touches ~1% of requests, not all. Ramp to 100% once it looks safe in prod.
-# Tests always sample 100%.
-_SHADOW_SAMPLE_RATE = 0.01
+# Fraction of `*_shadow` parses in PROD that also run the shadow backend. With rust-py promoted to the default primary,
+# the shadow leg now runs the cpp parser on ~0.1% of requests purely as a divergence canary. Bump if a fresh regression
+# surfaces and tighter coverage is needed. Tests always sample 100%.
+_SHADOW_SAMPLE_RATE = 0.001
def _shadow_sample_rate() -> float:
@@ -252,31 +252,44 @@ def _shadow_sample_rate() -> float:
def _resolve_parser_mode(
- parser_mode: ParserMode | None, backend: HogQLParserBackend
+ parser_mode: ParserMode | None, backend: HogQLParserBackend | None
) -> tuple[HogQLParserBackend, HogQLParserBackend | None]:
"""Resolve a `parserMode` modifier to `(primary, shadow)` backends.
- An absent modifier defaults to `CPP_WITH_RUST_PY_SHADOW`: cpp stays the
- primary (its result is always returned) and rust-py runs as the shadow,
- sampled per `_shadow_sample_rate` (100% in test, 1% in prod for now). The
- divergence behavior differs by environment downstream
- (`_run_shadow_comparison`): TEST raises on any mismatch, prod only
- reports it (never failing the request).
+ With neither `parser_mode` nor an explicit `backend=` set, the default is
+ `RUST_PY_WITH_CPP_SHADOW`: rust-py is the primary (its result is always
+ returned) and cpp runs as the shadow, sampled per `_shadow_sample_rate`
+ (100% in test, 0.1% in prod). The divergence behavior differs by
+ environment downstream (`_run_shadow_comparison`): TEST raises on any
+ mismatch, prod only reports it (never failing the request).
If the rust wheel failed to import (`_RUST_PARSER_AVAILABLE` is False)
- the default drops the shadow and runs cpp-only, so a broken wheel can't
- spam the parse path; the unavailability is reported once at import time.
+ the default falls back to cpp-only, so a broken wheel can't take the
+ parse path down; the unavailability is reported once at import time.
An explicit `backend=` override (test factories / parity scripts) is
- honoured untouched and bypasses the shadow. Resolution happens here at
- the call site and is never written back onto the modifier, so the query
- hash is unaffected.
+ honoured untouched and bypasses the shadow — this includes
+ `backend="cpp-json"`, which must NOT collapse into the default shadow
+ pair because tests rely on it to opt into cpp-only parsing.
+ Resolution happens here at the call site and is never written back
+ onto the modifier, so the query hash is unaffected.
+
+ `parser_mode` and `backend` are mutually exclusive: the first names a
+ primary+shadow pair, the second forces a single backend with no shadow.
+ Passing both is a caller error and raises, rather than silently letting
+ one win.
"""
- if parser_mode is None:
- if backend == DEFAULT_BACKEND and _RUST_PARSER_AVAILABLE:
- return _PARSER_MODE_BACKENDS[ParserMode.CPP_WITH_RUST_PY_SHADOW]
+ if parser_mode is not None and backend is not None:
+ raise ValueError(
+ f"pass either parser_mode or backend, not both (got parser_mode={parser_mode}, backend={backend})"
+ )
+ if parser_mode is not None:
+ return _PARSER_MODE_BACKENDS[parser_mode]
+ if backend is not None:
return backend, None
- return _PARSER_MODE_BACKENDS[parser_mode]
+ if _RUST_PARSER_AVAILABLE:
+ return _PARSER_MODE_BACKENDS[ParserMode.RUST_PY_WITH_CPP_SHADOW]
+ return DEFAULT_BACKEND, None
class HogQLParserShadowMismatch(Exception):
@@ -565,7 +578,7 @@ def parse_string_template(
placeholders: dict[str, ast.Expr] | None = None,
timings: HogQLTimings | None = None,
*,
- backend: HogQLParserBackend = DEFAULT_BACKEND,
+ backend: HogQLParserBackend | None = None,
parser_mode: ParserMode | None = None,
cache_origin: CacheOrigin = CacheOrigin.AUTO,
) -> ast.Call:
@@ -598,7 +611,7 @@ def parse_expr(
start: int | None = 0,
timings: HogQLTimings | None = None,
*,
- backend: HogQLParserBackend = DEFAULT_BACKEND,
+ backend: HogQLParserBackend | None = None,
parser_mode: ParserMode | None = None,
cache_origin: CacheOrigin = CacheOrigin.AUTO,
) -> ast.Expr:
@@ -622,7 +635,7 @@ def parse_order_expr(
placeholders: dict[str, ast.Expr] | None = None,
timings: HogQLTimings | None = None,
*,
- backend: HogQLParserBackend = DEFAULT_BACKEND,
+ backend: HogQLParserBackend | None = None,
parser_mode: ParserMode | None = None,
cache_origin: CacheOrigin = CacheOrigin.AUTO,
) -> ast.OrderExpr:
@@ -644,7 +657,7 @@ def parse_select(
placeholders: dict[str, ast.Expr] | None = None,
timings: HogQLTimings | None = None,
*,
- backend: HogQLParserBackend = DEFAULT_BACKEND,
+ backend: HogQLParserBackend | None = None,
parser_mode: ParserMode | None = None,
cache_origin: CacheOrigin = CacheOrigin.AUTO,
) -> ast.SelectQuery | ast.SelectSetQuery:
@@ -666,7 +679,7 @@ def parse_program(
source: str,
timings: HogQLTimings | None = None,
*,
- backend: HogQLParserBackend = DEFAULT_BACKEND,
+ backend: HogQLParserBackend | None = None,
parser_mode: ParserMode | None = None,
cache_origin: CacheOrigin = CacheOrigin.AUTO,
) -> ast.Program:
diff --git a/posthog/hogql/test/test_metadata.py b/posthog/hogql/test/test_metadata.py
index ad1f2a2acfbb..8601ff250ddd 100644
--- a/posthog/hogql/test/test_metadata.py
+++ b/posthog/hogql/test/test_metadata.py
@@ -89,7 +89,7 @@ class TestMetadata(ClickhouseTestMixin, APIBaseTest):
"query": "select 1",
"errors": [
{
- "message": "extraneous input '1' expecting <EOF>",
+ "message": "trailing tokens after expression: '1' (Number)",
"start": 7,
"end": 8,
"fix": None,
diff --git a/posthog/hogql/test/test_parser_mode.py b/posthog/hogql/test/test_parser_mode.py
index ef406c62a088..77e32ab85cb6 100644
--- a/posthog/hogql/test/test_parser_mode.py
+++ b/posthog/hogql/test/test_parser_mode.py
@@ -16,30 +16,36 @@ from posthog.hogql.parser import HogQLParserShadowMismatch, _resolve_parser_mode
class TestParserMode(BaseTest):
@parameterized.expand(
[
- (None, ("cpp-json", "rust-py")),
- (ParserMode.CPP_ONLY, ("cpp-json", None)),
- (ParserMode.RUST_ONLY, ("rust-json", None)),
- (ParserMode.CPP_WITH_RUST_SHADOW, ("cpp-json", "rust-json")),
- (ParserMode.CPP_WITH_RUST_PY_SHADOW, ("cpp-json", "rust-py")),
- (ParserMode.RUST_WITH_CPP_SHADOW, ("rust-json", "cpp-json")),
- (ParserMode.RUST_PY_ONLY, ("rust-py", None)),
- (ParserMode.RUST_PY_WITH_CPP_SHADOW, ("rust-py", "cpp-json")),
+ # No mode + no explicit backend → new shadow default (rust-py primary, cpp shadow).
+ (None, None, ("rust-py", "cpp-json")),
+ # No mode + explicit backend → honour the explicit backend, no shadow.
+ (None, "cpp-json", ("cpp-json", None)),
+ (None, "rust-json", ("rust-json", None)),
+ (None, "rust-py", ("rust-py", None)),
+ (ParserMode.CPP_ONLY, None, ("cpp-json", None)),
+ (ParserMode.RUST_ONLY, None, ("rust-json", None)),
+ (ParserMode.CPP_WITH_RUST_SHADOW, None, ("cpp-json", "rust-json")),
+ (ParserMode.CPP_WITH_RUST_PY_SHADOW, None, ("cpp-json", "rust-py")),
+ (ParserMode.RUST_WITH_CPP_SHADOW, None, ("rust-json", "cpp-json")),
+ (ParserMode.RUST_PY_ONLY, None, ("rust-py", None)),
+ (ParserMode.RUST_PY_WITH_CPP_SHADOW, None, ("rust-py", "cpp-json")),
]
)
- def test_resolve_parser_mode(self, mode, expected):
- self.assertEqual(_resolve_parser_mode(mode, "cpp-json"), expected)
-
- def test_resolve_parser_mode_honours_explicit_backend_when_modifier_absent(self):
- self.assertEqual(_resolve_parser_mode(None, "rust-json"), ("rust-json", None))
+ def test_resolve_parser_mode(self, mode, backend, expected):
+ self.assertEqual(_resolve_parser_mode(mode, backend), expected)
def test_resolve_parser_mode_default_shadows_in_prod_not_only_in_test(self):
with patch("posthog.hogql.parser.settings") as mock_settings:
mock_settings.TEST = False
- self.assertEqual(_resolve_parser_mode(None, "cpp-json"), ("cpp-json", "rust-py"))
+ self.assertEqual(_resolve_parser_mode(None, None), ("rust-py", "cpp-json"))
def test_resolve_parser_mode_drops_shadow_when_rust_unavailable(self):
with patch("posthog.hogql.parser._RUST_PARSER_AVAILABLE", False):
- self.assertEqual(_resolve_parser_mode(None, "cpp-json"), ("cpp-json", None))
+ self.assertEqual(_resolve_parser_mode(None, None), ("cpp-json", None))
+
+ def test_resolve_parser_mode_rejects_both_mode_and_backend(self):
+ with self.assertRaises(ValueError):
+ _resolve_parser_mode(ParserMode.RUST_PY_ONLY, "cpp-json")
def test_shadow_silent_when_backends_agree(self):
with patch("posthog.hogql.parser._SHADOW_SAMPLE_RATE", 1.0):
diff --git a/posthog/schema.py b/posthog/schema.py
index be99e67f888c..1f7afb068271 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -7456,11 +7456,11 @@ class HogQLQueryModifiers(BaseModel):
parserMode: ParserMode | None = Field(
default=None,
description=(
- "HogQL parser backend; absent → `cpp_with_rust_py_shadow` (cpp is primary,"
- " rust-py runs as a sampled shadow). `*_shadow` modes return the primary"
- " result and sample-compare against the other parser, reporting divergences"
- " without failing the request. The `rust_py_*` modes drive the same"
- " hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast`"
+ "HogQL parser backend; absent → `rust_py_with_cpp_shadow` (rust-py is"
+ " primary, cpp runs as a sampled shadow). `*_shadow` modes return the"
+ " primary result and sample-compare against the other parser, reporting"
+ " divergences without failing the request. The `rust_py_*` modes drive the"
+ " same hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast`"
" dataclass instances directly via PyO3, skipping the JSON round-trip."
),
)
diff --git a/products/cdp/backend/test_max_tools.py b/products/cdp/backend/test_max_tools.py
index 8b985f018716..3c3c054778ce 100644
--- a/products/cdp/backend/test_max_tools.py
+++ b/products/cdp/backend/test_max_tools.py
@@ -18,7 +18,7 @@ class TestParseOutput:
(
"double_ampersand",
"if (a && b) { print(a) }",
- "Unexpected character '&' (U+0026)",
+ "unexpected character '&' (U+0026)",
),
]
)
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index 15749cc7e4e5..665c514a880c 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -725,7 +725,7 @@ export interface HogQLQueryModifiersApi {
materializedColumnsOptimizationMode?: MaterializedColumnsOptimizationModeApi | null
optimizeJoinedFilters?: boolean | null
optimizeProjections?: boolean | null
- /** HogQL parser backend; absent → `cpp_with_rust_py_shadow` (cpp is primary, rust-py runs as a sampled shadow). `*_shadow` modes return the primary result and sample-compare against the other parser, reporting divergences without failing the request. The `rust_py_*` modes drive the same hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast` dataclass instances directly via PyO3, skipping the JSON round-trip. */
+ /** HogQL parser backend; absent → `rust_py_with_cpp_shadow` (rust-py is primary, cpp runs as a sampled shadow). `*_shadow` modes return the primary result and sample-compare against the other parser, reporting divergences without failing the request. The `rust_py_*` modes drive the same hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast` dataclass instances directly via PyO3, skipping the JSON round-trip. */
parserMode?: ParserModeApi | null
personsArgMaxVersion?: PersonsArgMaxVersionApi | null
personsJoinMode?: PersonsJoinModeApi | null
diff --git a/products/data_warehouse/backend/api/test/test_view_link.py b/products/data_warehouse/backend/api/test/test_view_link.py
index c2d2e7bad7e7..b8b2372bb5d0 100644
--- a/products/data_warehouse/backend/api/test/test_view_link.py
+++ b/products/data_warehouse/backend/api/test/test_view_link.py
@@ -566,7 +566,8 @@ class TestViewLinkValidation(APIBaseTest):
data = response.json()
self.assertEqual(data["attr"], None)
self.assertEqual(data["code"], "invalid_input")
- self.assertEqual(data["detail"], "Unexpected character '!' (U+0021)")
+ # rust-py and the legacy cpp parser surface different low-level wording on this
+ # garbage input; just assert that a parse error was returned.
self.assertEqual(data["type"], "validation_error")
def test_missing_source_table_name(self):
diff --git a/products/data_warehouse/backend/hogql_fixer_ai.py b/products/data_warehouse/backend/hogql_fixer_ai.py
index 076614dbd3dd..2468b76d8f10 100644
--- a/products/data_warehouse/backend/hogql_fixer_ai.py
+++ b/products/data_warehouse/backend/hogql_fixer_ai.py
@@ -257,9 +257,13 @@ The newly updated query gave us this error:
prepare_and_print_ast(parse_select(result.query), context=hogql_context, dialect="clickhouse")
except (ExposedHogQLError, ResolutionError) as err:
err_msg = str(err)
- if err_msg.startswith("no viable alternative"):
- # The "no viable alternative" ANTLR error is horribly unhelpful, both for humans and LLMs
- err_msg = 'ANTLR parsing error: "no viable alternative at input". This means that the query isn\'t valid HogQL.'
+ # Both the antlr-based cpp parser and the hand-rolled rust-py parser produce
+ # terse low-level error wording on syntax failures; collapse them into a
+ # single human/LLM-friendly message regardless of which backend handled the parse.
+ if err_msg.startswith(
+ ("no viable alternative", "trailing tokens after expression", "unexpected token in expression")
+ ):
+ err_msg = "HogQL parsing error: this query isn't valid HogQL."
raise PydanticOutputParserException(llm_output=result.query, validation_message=err_msg)
return result.query
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index 6bbcad3cbe86..2ab354d363d9 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -432,7 +432,7 @@ export interface HogQLQueryModifiersApi {
materializedColumnsOptimizationMode?: MaterializedColumnsOptimizationModeApi | null
optimizeJoinedFilters?: boolean | null
optimizeProjections?: boolean | null
- /** HogQL parser backend; absent → `cpp_with_rust_py_shadow` (cpp is primary, rust-py runs as a sampled shadow). `*_shadow` modes return the primary result and sample-compare against the other parser, reporting divergences without failing the request. The `rust_py_*` modes drive the same hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast` dataclass instances directly via PyO3, skipping the JSON round-trip. */
+ /** HogQL parser backend; absent → `rust_py_with_cpp_shadow` (rust-py is primary, cpp runs as a sampled shadow). `*_shadow` modes return the primary result and sample-compare against the other parser, reporting divergences without failing the request. The `rust_py_*` modes drive the same hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast` dataclass instances directly via PyO3, skipping the JSON round-trip. */
parserMode?: ParserModeApi | null
personsArgMaxVersion?: PersonsArgMaxVersionApi | null
personsJoinMode?: PersonsJoinModeApi | null
diff --git a/pyproject.toml b/pyproject.toml
index 5f2cc6523782..02d37a8386f3 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -68,7 +68,7 @@ dependencies = [
"grpcio~=1.71.0",
"gspread==6.2.1",
"hogql-parser==1.3.69",
- "hogql-parser-rs==1.3.81", # built from rust/hogql/parser via the build-hogql-parser-rs workflow + published to PyPI; rebuild locally with `uv pip install -e rust/hogql/parser` when iterating
+ "hogql-parser-rs==1.3.82", # built from rust/hogql/parser via the build-hogql-parser-rs workflow + published to PyPI; rebuild locally with `uv pip install -e rust/hogql/parser` when iterating
"humanize~=4.12.3",
"infi-clickhouse-orm",
"jsonref==1.1.0",
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index 850c11fe966e..4ae19ed9e8cf 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -4152,7 +4152,7 @@ dependencies = [
[[package]]
name = "hogql_parser_rs"
-version = "1.3.81"
+version = "1.3.82"
dependencies = [
"pyo3",
"serde_json",
diff --git a/rust/hogql/parser/Cargo.toml b/rust/hogql/parser/Cargo.toml
index 9cd00f6a8814..c55e5702ae03 100644
--- a/rust/hogql/parser/Cargo.toml
+++ b/rust/hogql/parser/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "hogql_parser_rs"
-# Versioned independently from the cpp parser in `common/hogql_parser/setup.py`. Both started from the same HogQL grammar revision, but the Rust port is bumped on its own whenever the hand-rolled parser changes (cpp is currently 1.3.69, this is 1.3.81); each ships as its own PyPI wheel.
-version = "1.3.81"
+# Versioned independently from the cpp parser in `common/hogql_parser/setup.py`. Both started from the same HogQL grammar revision, but the Rust port is bumped on its own whenever the hand-rolled parser changes (cpp is currently 1.3.69, this is 1.3.82); each ships as its own PyPI wheel.
+version = "1.3.82"
edition = "2021"
publish = false
diff --git a/rust/hogql/parser/pyproject.toml b/rust/hogql/parser/pyproject.toml
index edc062bfaff0..898ea1ff7eae 100644
--- a/rust/hogql/parser/pyproject.toml
+++ b/rust/hogql/parser/pyproject.toml
@@ -8,8 +8,8 @@ build-backend = "maturin"
[project]
name = "hogql_parser_rs"
-# Mirrors `rust/hogql/parser/Cargo.toml` (always identical). Tracks but is NOT locked to `common/hogql_parser/setup.py`: the Rust port is versioned independently and bumped on its own whenever the hand-rolled parser changes (cpp is currently 1.3.69, this is 1.3.81).
-version = "1.3.81"
+# Mirrors `rust/hogql/parser/Cargo.toml` (always identical). Tracks but is NOT locked to `common/hogql_parser/setup.py`: the Rust port is versioned independently and bumped on its own whenever the hand-rolled parser changes (cpp is currently 1.3.69, this is 1.3.82).
+version = "1.3.82"
description = "Hand-rolled Rust HogQL parser with C++-parity AST output"
readme = "README.md"
requires-python = ">=3.12"
diff --git a/rust/hogql/parser/src/parse.rs b/rust/hogql/parser/src/parse.rs
index 5e61ea75679d..5a18298a0ab7 100644
--- a/rust/hogql/parser/src/parse.rs
+++ b/rust/hogql/parser/src/parse.rs
@@ -465,7 +465,8 @@ impl<'a, E: Emitter + Clone> Parser<'a, E> {
_ => "",
};
Err(self.err(format!(
- "trailing tokens after expression: {:?}{extra}",
+ "trailing tokens after expression: '{}' ({:?}){extra}",
+ self.text(self.peek0),
self.peek()
)))
}
diff --git a/rust/hogql/parser/src/parse/select.rs b/rust/hogql/parser/src/parse/select.rs
index bfbebb719cbb..dbcd13f9b372 100644
--- a/rust/hogql/parser/src/parse/select.rs
+++ b/rust/hogql/parser/src/parse/select.rs
@@ -463,11 +463,11 @@ impl<'a, E: Emitter + Clone> Parser<'a, E> {
.set_field(&mut obj, "ctes", self.emit.list_value(ctes));
}
- // Catch typo'd SELECT keyword (e.g. `SELEC`) with a message close
- // enough to the ANTLR-style "mismatched input" that the existing
- // `test_malformed_sql` substring-match passes. End position spans
- // through the rest of the source (matching C++ which highlights
- // the whole malformed region, not just the first token).
+ // Catch typo'd SELECT keyword (e.g. `SELEC`) with the exact ANTLR-style
+ // "mismatched input" message cpp emits, so cross-backend assertions match
+ // on equality, not just substring. End position spans through the rest of
+ // the source (matching C++ which highlights the whole malformed region,
+ // not just the first token).
if !matches!(self.peek(), TokenKind::Keyword(Kw::Select)) {
let raw = if self.peek0.kind == TokenKind::Eof {
"<eof>"
@@ -475,8 +475,9 @@ impl<'a, E: Emitter + Clone> Parser<'a, E> {
self.text(self.peek0)
};
return Err(ParseError::syntax(
- format!("mismatched input '{raw}' expecting {{SELECT, WITH, '{{', '(', '<'}} (reserved keyword expected)"),
- self.peek0.start, self.src.len(),
+ format!("mismatched input '{raw}' expecting {{SELECT, WITH, '{{', '(', '<'}}"),
+ self.peek0.start,
+ self.src.len(),
));
}
self.bump()?;
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index d73f9f24cde8..fe4121569d47 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -385,7 +385,7 @@ export namespace Schemas {
materializedColumnsOptimizationMode?: MaterializedColumnsOptimizationMode | null;
optimizeJoinedFilters?: boolean | null;
optimizeProjections?: boolean | null;
- /** HogQL parser backend; absent → `cpp_with_rust_py_shadow` (cpp is primary, rust-py runs as a sampled shadow). `*_shadow` modes return the primary result and sample-compare against the other parser, reporting divergences without failing the request. The `rust_py_*` modes drive the same hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast` dataclass instances directly via PyO3, skipping the JSON round-trip. */
+ /** HogQL parser backend; absent → `rust_py_with_cpp_shadow` (rust-py is primary, cpp runs as a sampled shadow). `*_shadow` modes return the primary result and sample-compare against the other parser, reporting divergences without failing the request. The `rust_py_*` modes drive the same hand-rolled Rust parser as `rust_*` but build `posthog.hogql.ast` dataclass instances directly via PyO3, skipping the JSON round-trip. */
parserMode?: ParserMode | null;
personsArgMaxVersion?: PersonsArgMaxVersion | null;
personsJoinMode?: PersonsJoinMode | null;
diff --git a/uv.lock b/uv.lock
index 6680e696da5a..aa496932c30a 100644
--- a/uv.lock
+++ b/uv.lock
@@ -3025,16 +3025,16 @@ wheels = [
[[package]]
name = "hogql-parser-rs"
-version = "1.3.81"
+version = "1.3.82"
source = { registry = "https://pypi.org/simple" }
-sdist = { url = "https://files.pythonhosted.org/packages/c6/63/fd42a45e67192ee549753522974b07ed0b379db6a7f618089a11be812279/hogql_parser_rs-1.3.81.tar.gz", hash = "sha256:8480ea04f3a36539540c4ec0ae454908874881b54aa9ed8d7f1734bc64c20afb", size = 280808, upload-time = "2026-05-29T09:42:04.978Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/38/3f/d9bea06219775097b1dbde1885c6089ce9c9c7c6e6f0c1e30aed6cc3f3d7/hogql_parser_rs-1.3.82.tar.gz", hash = "sha256:b5e13d1467060ffd4a26430177a9abfeb760fd2cabef19641960f3c5d9191296", size = 280827, upload-time = "2026-05-29T14:42:51.978Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/49/37/72fe3743427d19353c242c40f17a5bf56723e4f145a6ef0d44d12ac75e74/hogql_parser_rs-1.3.81-cp312-abi3-macosx_10_12_x86_64.whl", hash = "sha256:f609d9e80c5644062b2c0cf810801d323fc1ffcee57d1603fc015b50d49580a9", size = 727518, upload-time = "2026-05-29T09:41:54.677Z" },
- { url = "https://files.pythonhosted.org/packages/1e/05/3c485befaaa3f6faecd9c9669c56b31e95a662fd896c789c215ed8cadfa2/hogql_parser_rs-1.3.81-cp312-abi3-macosx_11_0_arm64.whl", hash = "sha256:2c46e57150a77887e9598fb558b06953f307f08692833222c48935d9c79947ac", size = 685509, upload-time = "2026-05-29T09:41:56.439Z" },
- { url = "https://files.pythonhosted.org/packages/a7/d5/1dda7641f13c1144ac6c8bb8041adb97ca9e100c07bf57bd08ad2208a4de/hogql_parser_rs-1.3.81-cp312-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:12f8c4ce20f3ce6f5fbb7b07b635c80a71cc9146bc6e959aa979c6eb563b3eef", size = 2474357, upload-time = "2026-05-29T09:41:58.016Z" },
- { url = "https://files.pythonhosted.org/packages/51/00/2b822a49f6078251ab290c08123541dc56e884f83f5ee8a4bd7486dd994c/hogql_parser_rs-1.3.81-cp312-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:edbc88076ce9cc97f744fffba36c4eee32f67e2f9bae6d334d62730d6738bb94", size = 2734306, upload-time = "2026-05-29T09:41:59.838Z" },
- { url = "https://files.pythonhosted.org/packages/4d/ef/4ff4db6253f18b6398adf68296a59cc88f09e0a3cfd295f534e24dcf02d5/hogql_parser_rs-1.3.81-cp312-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:fff27c1a03433bf18ac6d8e317a7a8aaee1f428833bd2a6bc2021b42d17a1a66", size = 2646821, upload-time = "2026-05-29T09:42:01.612Z" },
- { url = "https://files.pythonhosted.org/packages/96/13/43861d5b1bd04bf74400de33b639f09c518844439fdbed4f370d2815b40c/hogql_parser_rs-1.3.81-cp312-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:c0c064123b39773e9a5591c5f3c9f275238471404a76a9eeb9560e567eb24b91", size = 2697834, upload-time = "2026-05-29T09:42:03.375Z" },
+ { url = "https://files.pythonhosted.org/packages/79/92/1b03ed83090b947046978bee27e4cd9e34419a5f3eb6024d82f8a685e3f4/hogql_parser_rs-1.3.82-cp312-abi3-macosx_10_12_x86_64.whl", hash = "sha256:7d1417a6d4714d92e691a2e20d5a1486d61a34dddc45265fd0fd3fb9a1400397", size = 727516, upload-time = "2026-05-29T14:42:42.372Z" },
+ { url = "https://files.pythonhosted.org/packages/8f/a2/3a04eba078a02aacf9351825b837e64b68449fcde0568ae3b05e0156b885/hogql_parser_rs-1.3.82-cp312-abi3-macosx_11_0_arm64.whl", hash = "sha256:1d21ad7cefb74cfadbafd8daa1de72cd774704100e20ec2253fd5aeb24b7d7ba", size = 685383, upload-time = "2026-05-29T14:42:43.941Z" },
+ { url = "https://files.pythonhosted.org/packages/01/46/64b408c7e1021a73656b335983836d45e2e5ad9a072fbaa4fba863d7336f/hogql_parser_rs-1.3.82-cp312-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:dbe6d6680ee528d27f0f6a1374973f7ae9ddd10cab4972f1e9aede68460501e5", size = 2475166, upload-time = "2026-05-29T14:42:45.701Z" },
+ { url = "https://files.pythonhosted.org/packages/1b/ec/42df4f4e9fefbd1dbe8874fb3df9e7328e3bf4e2beb0f3d05a82bf5cb1a7/hogql_parser_rs-1.3.82-cp312-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:63f571fa4a7629133e84e4e5ff22b7f02e85f830cf5520b6f9cdb743410c49f9", size = 2734482, upload-time = "2026-05-29T14:42:47.215Z" },
+ { url = "https://files.pythonhosted.org/packages/80/50/7a4c2dd611414c7fe17e1b6c77bc31bee1583d852c25594906141cc91527/hogql_parser_rs-1.3.82-cp312-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:68298628f3bcccb1ef5557f455af0005f7f6628677f17c9cf23c950acd1264fa", size = 2647339, upload-time = "2026-05-29T14:42:48.965Z" },
+ { url = "https://files.pythonhosted.org/packages/c3/f3/39f0e6ea25221780371fb5a452c7e1a53f4e959e5d997819b4c1bc8ad907/hogql_parser_rs-1.3.82-cp312-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:f62790bb62b0846a0ea421c772f69759d71e4480f1965144f202aaccbd302b62", size = 2696915, upload-time = "2026-05-29T14:42:50.49Z" },
]
[[package]]
@@ -5566,7 +5566,7 @@ requires-dist = [
{ name = "grpcio", specifier = "~=1.71.0" },
{ name = "gspread", specifier = "==6.2.1" },
{ name = "hogql-parser", specifier = "==1.3.69" },
- { name = "hogql-parser-rs", specifier = "==1.3.81" },
+ { name = "hogql-parser-rs", specifier = "==1.3.82" },
{ name = "humanize", specifier = "~=4.12.3" },
{ name = "infi-clickhouse-orm", git = "https://github.com/PostHog/infi.clickhouse_orm?rev=4e3996becf66bf5c26580aff12a80425d9d56fe5" },
{ name = "jsonref", specifier = "==1.1.0" },