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.

fix(hogql): compile simple case expressions natively (#79090)

Thiago Salvatorec30d27369287
diff --git a/common/hogql_parser/package.json b/common/hogql_parser/package.json
index c7c52bfe701f..86dbb32ec0f8 100644
--- a/common/hogql_parser/package.json
+++ b/common/hogql_parser/package.json
@@ -1,6 +1,6 @@
{
"name": "@posthog/hogql-parser",
- "version": "1.3.83",
+ "version": "1.3.84",
"description": "WebAssembly HogQL Parser - Parse HogQL queries in JavaScript/TypeScript",
"keywords": [
"antlr4",
diff --git a/common/hogql_parser/parser_json.cpp b/common/hogql_parser/parser_json.cpp
index bc9c75a78173..229bce7edd7c 100644
--- a/common/hogql_parser/parser_json.cpp
+++ b/common/hogql_parser/parser_json.cpp
@@ -2269,58 +2269,30 @@ class HogQLParseTreeJSONConverter : public HogQLParserBaseVisitor {
size_t columns_size = column_expr_ctx.size();
vector<Json> columns = visitAsVectorOfJSON(column_expr_ctx);
+ if (!ctx->elseExpr) {
+ Json null_default = Json::object();
+ null_default["node"] = "Constant";
+ null_default["value"] = nullptr;
+ columns.push_back(std::move(null_default));
+ columns_size++;
+ }
+
Json json = Json::object();
json["node"] = "Call";
if (!is_internal) addPositionInfo(json, ctx);
if (ctx->caseExpr) {
- // CASE expr WHEN ... THEN ... ELSE ... END
- // Transform to: transform(expr, [conditions], [results], else_result)
- json["name"] = "transform";
-
- Json args = Json::array();
-
- // arg_0: the case expression
- args.pushBack(columns[0]);
-
- // arg_1: Array of conditions (odd indices from 1 to columns_size-2)
- Json conditions_array = Json::object();
- conditions_array["node"] = "Array";
- Json conditions_exprs = Json::array();
- for (size_t index = 1; index < columns_size - 1; index++) {
- if ((index - 1) % 2 == 0) {
- conditions_exprs.pushBack(columns[index]);
- }
- }
- conditions_array["exprs"] = std::move(conditions_exprs);
- args.pushBack(std::move(conditions_array));
-
- // arg_2: Array of results (even indices from 1 to columns_size-2)
- Json results_array = Json::object();
- results_array["node"] = "Array";
- Json results_exprs = Json::array();
- for (size_t index = 1; index < columns_size - 1; index++) {
- if ((index - 1) % 2 == 1) {
- results_exprs.pushBack(columns[index]);
- }
- }
- results_array["exprs"] = std::move(results_exprs);
- args.pushBack(std::move(results_array));
-
- // arg_3: else result (last element)
- args.pushBack(columns[columns_size - 1]);
-
- json["args"] = args;
+ json["name"] = "_caseWithExpression";
} else {
- // CASE WHEN ... THEN ... ELSE ... END
json["name"] = columns_size == 3 ? "if" : "multiIf";
- Json args = Json::array();
- for (const auto& col : columns) {
- args.pushBack(col);
- }
- json["args"] = std::move(args);
}
+ Json args = Json::array();
+ for (auto& column : columns) {
+ args.pushBack(std::move(column));
+ }
+ json["args"] = std::move(args);
+
return json;
}
diff --git a/common/hogql_parser/setup.py b/common/hogql_parser/setup.py
index 1e360c58cc8d..8d747f959bb7 100644
--- a/common/hogql_parser/setup.py
+++ b/common/hogql_parser/setup.py
@@ -36,7 +36,7 @@ module = Extension(
setup(
name="hogql_parser",
- version="1.3.83",
+ version="1.3.84",
url="https://github.com/PostHog/posthog/tree/master/common/hogql_parser",
description="HogQL parser for internal PostHog use",
author="PostHog Inc.",
diff --git a/frontend/package.json b/frontend/package.json
index 35975091dd3d..38eb41f43a6f 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -76,7 +76,7 @@
"@posthog/docs-onboarding": "workspace:*",
"@posthog/esbuilder": "workspace:*",
"@posthog/hedgehog-mode": "^0.0.52",
- "@posthog/hogql-parser": "1.3.75",
+ "@posthog/hogql-parser": "1.3.84",
"@posthog/hogvm": "workspace:*",
"@posthog/icons": "catalog:",
"@posthog/llm-normalizer": "workspace:*",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f46aab784c53..2aebe3263726 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -624,8 +624,8 @@ importers:
specifier: ^0.0.52
'@posthog/hogql-parser':
- specifier: 1.3.75
- version: 1.3.75
+ specifier: 1.3.84
+ version: 1.3.84
'@posthog/hogvm':
specifier: workspace:*
version: link:../common/hogvm/typescript
@@ -10106,8 +10106,8 @@ packages:
react: 18.3.1
react-dom: 18.3.1
- '@posthog/[email protected]':
- resolution: {integrity: sha512-r282QitLBwxaT5YHGi6iAq1lCE5SMkg0Oq/qzvqNio4jh/P4lK70UpyTRMDZ6VFbqJWDg8Ly7T6TBUHxhmmiVg==}
+ '@posthog/[email protected]':
+ resolution: {integrity: sha512-dDBrHb5TcyM+APFAb+1VhdIVg1LHHF+f2SlogX7ZcWwCvBg2shPwUsdFQyNBr/vfxZzzR9Tvet57JOhgn0eTnA==}
'@posthog/[email protected]':
resolution: {integrity: sha512-Y458v7A9ipKvHCo77rAc2/ELUDvfNjFpn9AwV8aVYUl5/wvLH9CwEfq1IxgQDj33OaML4IE2w5LQ0TbKbo63XA==}
@@ -29712,7 +29712,7 @@ snapshots:
transitivePeerDependencies:
- prop-types
- '@posthog/[email protected]': {}
+ '@posthog/[email protected]': {}
dependencies:
diff --git a/posthog/hogql/functions/mapping.py b/posthog/hogql/functions/mapping.py
index eaa275be728a..c4b4c1940f89 100644
--- a/posthog/hogql/functions/mapping.py
+++ b/posthog/hogql/functions/mapping.py
@@ -60,6 +60,7 @@ HOGQL_CLICKHOUSE_FUNCTIONS: dict[str, HogQLFunctionMeta] = {
"xor": HogQLFunctionMeta("xor", 2, None),
"not": HogQLFunctionMeta("not", 1, 1, case_sensitive=False),
# conditional
+ "_caseWithExpression": HogQLFunctionMeta("caseWithExpression", 4, None),
"if": HogQLFunctionMeta("if", 3, 3, case_sensitive=False),
"multiIf": HogQLFunctionMeta("multiIf", 3, None),
"throwIf": HogQLFunctionMeta("throwIf", 2, 2),
diff --git a/posthog/hogql/printer/mysql_functions.py b/posthog/hogql/printer/mysql_functions.py
index 1e358f18689a..43f7920b2a3e 100644
--- a/posthog/hogql/printer/mysql_functions.py
+++ b/posthog/hogql/printer/mysql_functions.py
@@ -1,6 +1,7 @@
from collections.abc import Callable
from posthog.hogql.printer.postgres_functions import (
+ _handle_case_with_expression,
_handle_e,
_handle_empty,
_handle_if,
@@ -281,6 +282,7 @@ MYSQL_FUNCTION_HANDLERS: dict[str, Callable[[list[str]], str]] = {
"subtractQuarters": _make_date_add_handler("QUARTER", fn="DATE_SUB"),
"subtractYears": _make_date_add_handler("YEAR", fn="DATE_SUB"),
# Conditional
+ "_caseWithExpression": _handle_case_with_expression,
"if": _handle_if,
"multiIf": _handle_multi_if,
# Null/empty
diff --git a/posthog/hogql/printer/postgres_functions.py b/posthog/hogql/printer/postgres_functions.py
index 8984bb745ae7..63d4692fd9fe 100644
--- a/posthog/hogql/printer/postgres_functions.py
+++ b/posthog/hogql/printer/postgres_functions.py
@@ -97,6 +97,16 @@ def _handle_multi_if(args: list[str]) -> str:
return " ".join(parts)
+def _handle_case_with_expression(args: list[str]) -> str:
+ parts = [f"CASE {args[0]}"]
+ index = 1
+ while index < len(args) - 1:
+ parts.append(f"WHEN {args[index]} THEN {args[index + 1]}")
+ index += 2
+ parts.append(f"ELSE {args[-1]} END")
+ return " ".join(parts)
+
+
def _handle_empty(args: list[str]) -> str:
return f"({args[0]} IS NULL OR {args[0]} = '')"
@@ -259,6 +269,7 @@ POSTGRES_FUNCTION_HANDLERS: dict[str, Callable[[list[str]], str]] = {
# Date diff
"dateDiff": _handle_date_diff,
# Conditional
+ "_caseWithExpression": _handle_case_with_expression,
"if": _handle_if,
"multiIf": _handle_multi_if,
# Null/empty
diff --git a/posthog/hogql/printer/snowflake_functions.py b/posthog/hogql/printer/snowflake_functions.py
index 7ab401e0b800..4cf72b7ce367 100644
--- a/posthog/hogql/printer/snowflake_functions.py
+++ b/posthog/hogql/printer/snowflake_functions.py
@@ -1,6 +1,7 @@
from collections.abc import Callable
from posthog.hogql.printer.postgres_functions import (
+ _handle_case_with_expression,
_handle_e,
_handle_empty,
_handle_ends_with,
@@ -239,6 +240,7 @@ SNOWFLAKE_FUNCTION_HANDLERS: dict[str, Callable[[list[str]], str]] = {
"subtractQuarters": _make_dateadd_handler("quarter", negate=True),
"subtractYears": _make_dateadd_handler("year", negate=True),
# Conditional
+ "_caseWithExpression": _handle_case_with_expression,
"if": _handle_if,
"multiIf": _handle_multi_if,
# Null / empty
diff --git a/posthog/hogql/printer/test/test_printer.py b/posthog/hogql/printer/test/test_printer.py
index c3572ae6e310..10a76c2049bb 100644
--- a/posthog/hogql/printer/test/test_printer.py
+++ b/posthog/hogql/printer/test/test_printer.py
@@ -2167,9 +2167,18 @@ class TestPrinter(BaseTest):
def test_case_when_case(self):
self.assertEqual(
self._expr("case 0 when 1 then 2 when 3 then 4 else 5 end"),
- "transform(0, [1, 3], [2, 4], 5)",
+ "caseWithExpression(0, 1, 2, 3, 4, 5)",
)
+ @parameterized.expand(
+ [
+ ("searched_case", "case when 1 then 2 end", "if(1, 2, NULL)"),
+ ("simple_case", "case 0 when 1 then 2 end", "caseWithExpression(0, 1, 2, NULL)"),
+ ]
+ )
+ def test_case_without_else(self, _name: str, expression: str, expected: str):
+ self.assertEqual(self._expr(expression), expected)
+
def test_select(self):
self.assertEqual(self._select("select 1"), f"SELECT 1 LIMIT {MAX_SELECT_RETURNED_ROWS}")
self.assertEqual(self._select("select 1 + 2"), f"SELECT plus(1, 2) LIMIT {MAX_SELECT_RETURNED_ROWS}")
@@ -7750,6 +7759,11 @@ class TestPostgresPrinter(BaseTest):
"multiIf(1, 'a', 0, 'b', 'c')",
"CASE WHEN 1 THEN %(hogql_val_0)s WHEN 0 THEN %(hogql_val_1)s ELSE %(hogql_val_2)s END",
),
+ (
+ "simple_case",
+ "CASE event WHEN '$pageview' THEN event ELSE '' END",
+ "CASE events.event WHEN %(hogql_val_0)s THEN events.event ELSE %(hogql_val_1)s END",
+ ),
# Null/empty
("empty", "empty('test')", "(%(hogql_val_0)s IS NULL OR %(hogql_val_0)s = '')"),
("notEmpty", "notEmpty('test')", "(%(hogql_val_0)s IS NOT NULL AND %(hogql_val_0)s != '')"),
@@ -8216,6 +8230,11 @@ class TestMySQLPrinter(BaseTest):
("uniq", "uniq(event)", "COUNT(DISTINCT events.event)"),
("if_null", "ifNull(event, 'a')", "IFNULL(events.event, %(hogql_val_0)s)"),
("if_", "if(1 = 1, 'a', 'b')", "CASE WHEN (1 = 1) THEN %(hogql_val_0)s ELSE %(hogql_val_1)s END"),
+ (
+ "simple_case",
+ "CASE event WHEN '$pageview' THEN event ELSE '' END",
+ "CASE events.event WHEN %(hogql_val_0)s THEN events.event ELSE %(hogql_val_1)s END",
+ ),
(
"starts_with",
"startsWith(event, 'a')",
@@ -8328,6 +8347,11 @@ SNOWFLAKE_EMIT_CASES: list[tuple[str, str, str]] = [
),
# Conditional / null
("if", "if(1, 2, 3)", "CASE WHEN 1 THEN 2 ELSE 3 END"),
+ (
+ "simple_case",
+ "CASE event WHEN '$pageview' THEN event ELSE '' END",
+ 'CASE events."event" WHEN %(hogql_val_0)s THEN events."event" ELSE %(hogql_val_1)s END',
+ ),
("isNull", "isNull(1)", "(1 IS NULL)"),
# Regex operators → REGEXP_INSTR (match()-style "found anywhere"); 'i' = case-insensitive
("regex_match", "'h' =~ 'h.*o'", "(REGEXP_INSTR(%(hogql_val_0)s, %(hogql_val_1)s) != 0)"),
diff --git a/posthog/hogql/test/_test_parser.py b/posthog/hogql/test/_test_parser.py
index 42e86340dbd9..ecc17e89304b 100644
--- a/posthog/hogql/test/_test_parser.py
+++ b/posthog/hogql/test/_test_parser.py
@@ -3021,16 +3021,46 @@ def parser_test_factory(backend: HogQLParserBackend):
self.assertEqual(
self._expr("case 0 when 1 then 2 when 3 then 4 else 5 end"),
ast.Call(
- name="transform",
+ name="_caseWithExpression",
args=[
ast.Constant(value=0),
- ast.Array(exprs=[ast.Constant(value=1), ast.Constant(value=3)]),
- ast.Array(exprs=[ast.Constant(value=2), ast.Constant(value=4)]),
+ ast.Constant(value=1),
+ ast.Constant(value=2),
+ ast.Constant(value=3),
+ ast.Constant(value=4),
ast.Constant(value=5),
],
),
)
+ @parameterized.expand(
+ [
+ (
+ "searched_case",
+ "case when 1 then 2 end",
+ ast.Call(
+ name="if",
+ args=[ast.Constant(value=1), ast.Constant(value=2), ast.Constant(value=None)],
+ ),
+ ),
+ (
+ "simple_case",
+ "case 0 when 1 then 2 end",
+ ast.Call(
+ name="_caseWithExpression",
+ args=[
+ ast.Constant(value=0),
+ ast.Constant(value=1),
+ ast.Constant(value=2),
+ ast.Constant(value=None),
+ ],
+ ),
+ ),
+ ]
+ )
+ def test_case_without_else(self, _name: str, expression: str, expected: ast.Call):
+ self.assertEqual(self._expr(expression), expected)
+
def test_window_functions(self):
query = "SELECT person.id, min(timestamp) over (PARTITION by person.id ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) AS timestamp FROM events"
expr = self._select(query)
diff --git a/posthog/hogql/test/test_query.py b/posthog/hogql/test/test_query.py
index 5c6d1ec35cf5..1cdaaa70f43e 100644
--- a/posthog/hogql/test/test_query.py
+++ b/posthog/hogql/test/test_query.py
@@ -100,6 +100,21 @@ class TestQuery(ClickhouseTestMixin, APIBaseTest):
def test_extended_query_time(self):
self.assertEqual(HOGQL_INCREASED_MAX_EXECUTION_TIME, 600)
+ def test_simple_case_with_row_dependent_results(self):
+ response = execute_hogql_query(
+ """
+ SELECT
+ CASE value WHEN 1 THEN value * 10 WHEN 2 THEN value * 20 ELSE value END,
+ CASE value WHEN 1 THEN value * 10 END,
+ CASE WHEN value = 1 THEN value * 10 END
+ FROM (SELECT arrayJoin([1, 2, 3]) AS value)
+ ORDER BY value
+ """,
+ team=self.team,
+ )
+
+ self.assertEqual(response.results, [(10, 10, 10), (40, None, None), (3, None, None)])
+
@pytest.mark.usefixtures("unittest_snapshot")
def test_query(self):
with freeze_time("2020-01-10"):
diff --git a/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr b/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr
index c36dba72a364..b87753020901 100644
--- a/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr
+++ b/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr
@@ -65,7 +65,7 @@
HogQL defines what functions are available with most (but not all) having a 1:1 mapping to ClickHouse functions.
These are the non-aggregated HogQL functions:
```
- ['plus', 'minus', 'multiply', 'divide', 'intDiv', 'intDivOrZero', 'modulo', 'moduloOrZero', 'positiveModulo', 'negate', 'abs', 'gcd', 'lcm', 'max2', 'min2', 'multiplyDecimal', 'divideDecimal', 'empty', 'notEmpty', 'length', 'reverse', 'array', 'range', 'arrayConcat', 'arrayElement', 'has', 'hasAll', 'hasAny', 'hasSubstr', 'indexOf', 'arrayCount', 'countEqual', 'arrayEnumerate', 'arrayEnumerateUniq', 'arrayPopBack', 'arrayPopFront', 'arrayPushBack', 'arrayPushFront', 'arrayResize', 'arraySlice', 'arraySort', 'arrayReverseSort', 'arrayUniq', 'arrayJoin', 'arrayDifference', 'arrayDistinct', 'arrayEnumerateDense', 'arrayIntersect', 'arrayReduce', 'arrayReverse', 'arrayFilter', 'arrayFlatten', 'arrayCompact', 'arrayZip', 'arrayAUC', 'arrayMap', 'arrayFill', 'arrayFold', 'arrayWithConstant', 'arraySplit', 'arrayReverseFill', 'arrayReverseSplit', 'arrayRotateLeft', 'arrayRotateRight', 'arrayExists', 'arrayAll', 'arrayFirst', 'arrayLast', 'arrayFirstIndex', 'arrayLastIndex', 'arrayMin', 'arrayMax', 'arraySum', 'arrayAvg', 'arrayCumSum', 'arrayCumSumNonNegative', 'arrayProduct', 'arrayStringConcat', 'generateSeries', 'hex', 'unhex', 'reinterpretAsUInt8', 'reinterpretAsUInt16', 'reinterpretAsUInt32', 'reinterpretAsUInt64', 'reinterpretAsUInt128', 'reinterpretAsUInt256', 'reinterpretAsInt8', 'reinterpretAsInt16', 'reinterpretAsInt32', 'reinterpretAsInt64', 'reinterpretAsInt128', 'reinterpretAsInt256', 'reinterpretAsFloat32', 'reinterpretAsFloat64', 'reinterpretAsUUID', 'accurateCast', 'accurateCastOrNull', 'toInt', 'toIntOrZero', 'toIntOrDefault', '_toInt8', '_toInt16', '_toInt32', '_toInt64', '_toUInt8', '_toUInt64', '_toUInt128', 'toFloat', 'toFloatOrNull', 'toFloat64OrNull', 'toFloatOrZero', 'toFloatOrDefault', 'toDecimal', '_toDate', 'toUUID', 'toUUIDOrDefault', 'toString', 'toNullableString', 'toBool', 'toJSONString', 'parseDateTime', 'parseDateTimeBestEffort', 'dynamicType', 'toTypeName', 'defaultValueOfTypeName', 'cityHash64', 'UUIDv7ToDateTime', 'toDate', 'to_date', 'toDateTime', 'toDateTime64', 'toDateTimeUS', 'isnull', 'isNotNull', 'coalesce', 'ifnull', 'nullif', 'assumeNotNull', 'toNullable', 'timeZoneOf', 'timeZoneOffset', 'toYear', 'toQuarter', 'toMonth', 'toDayOfYear', 'toDayOfMonth', 'toDayOfWeek', 'toHour', 'toMinute', 'toSecond', 'toUnixTimestamp', 'toUnixTimestamp64Milli', 'fromUnixTimestamp64Milli', 'toStartOfInterval', 'toStartOfYear', 'toStartOfISOYear', 'toStartOfQuarter', 'toStartOfMonth', 'toLastDayOfMonth', 'toMonday', 'toStartOfWeek', 'toStartOfDay', 'toLastDayOfWeek', 'toStartOfHour', 'toStartOfMinute', 'toStartOfSecond', 'toStartOfFiveMinutes', 'toStartOfTenMinutes', 'toStartOfFifteenMinutes', 'toTime', 'toISOYear', 'toISOWeek', 'toWeek', 'toYearWeek', 'age', 'dateAdd', 'dateSub', 'date_bin', 'date_add', 'date_subtract', 'date_diff', 'dateDiff', 'timeStampAdd', 'timeStampSub', 'nowInBlock', 'rowNumberInBlock', 'rowNumberInAllBlocks', 'timeSlot', 'toYYYYMM', 'toYYYYMMDD', 'toYYYYMMDDhhmmss', 'addYears', 'addMonths', 'addWeeks', 'addDays', 'addHours', 'addMinutes', 'addSeconds', 'addQuarters', 'subtractYears', 'subtractMonths', 'subtractWeeks', 'subtractDays', 'subtractHours', 'subtractMinutes', 'subtractSeconds', 'subtractQuarters', 'timeSlots', 'formatDateTime', 'dateName', 'monthName', 'fromUnixTimestamp', 'toModifiedJulianDay', 'fromModifiedJulianDay', 'toIntervalSecond', 'toIntervalMinute', 'toIntervalHour', 'toIntervalDay', 'toIntervalWeek', 'toIntervalMonth', 'toIntervalQuarter', 'toIntervalYear', 'now', 'yesterday', 'current_timestamp', 'today', 'current_date', 'date_part', 'date_trunc', 'dateTrunc', 'to_timestamp', 'to_char', 'make_timestamp', 'make_date', 'make_interval', 'make_timestamptz', 'timezone', 'toTimeZone', 'greatCircleDistance', 'geoDistance', 'greatCircleAngle', 'pointInEllipses', 'pointInPolygon', 'geohashEncode', 'geohashDecode', 'geohashesInBox', 'h3IsValid', 'h3GetResolution', 'h3GetBaseCell', 'h3EdgeAngle', 'h3EdgeLengthM', 'h3EdgeLengthKm', 'geoToH3', 'h3ToGeo', 'h3ToGeoBoundary', 'h3kRing', 'h3HexAreaM2', 'h3HexAreaKm2', 'h3IndexesAreNeighbors', 'h3ToChildren', 'h3ToParent', 'h3ToString', 'stringToH3', 'h3IsResClassIII', 'h3IsPentagon', 'h3GetFaces', 'h3CellAreaM2', 'h3CellAreaRads2', 'h3ToCenterChild', 'h3ExactEdgeLengthM', 'h3ExactEdgeLengthKm', 'h3ExactEdgeLengthRads', 'h3NumHexagons', 'h3PointDistM', 'h3PointDistKm', 'h3PointDistRads', 'h3GetRes0Indexes', 'h3GetPentagonIndexes', 'h3Line', 'h3Distance', 'h3HexRing', 'h3GetUnidirectionalEdge', 'h3UnidirectionalEdgeIsValid', 'h3GetOriginIndexFromUnidirectionalEdge', 'h3GetDestinationIndexFromUnidirectionalEdge', 'h3GetIndexesFromUnidirectionalEdge', 'h3GetUnidirectionalEdgesFromHexagon', 'h3GetUnidirectionalEdgeBoundary', 'isValidJSON', 'JSONHas', 'JSONLength', 'JSONArrayLength', 'JSONType', 'JSONExtract', 'JSONExtractUInt', 'JSONExtractInt', 'JSONExtractFloat', 'JSONExtractBool', 'JSONExtractString', 'JSONExtractKeys', 'JSONExtractRaw', 'JSONExtractArrayRaw', 'JSONExtractKeysAndValues', 'JSONExtractKeysAndValuesRaw', 'JSON_VALUE', 'e', 'pi', 'exp', 'log', 'ln', 'exp2', 'log2', 'exp10', 'log10', 'sqrt', 'cbrt', 'erf', 'erfc', 'lgamma', 'tgamma', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'pow', 'power', 'intExp2', 'intExp10', 'cosh', 'acosh', 'sinh', 'asinh', 'atanh', 'atan2', 'hypot', 'log1p', 'sign', 'degrees', 'radians', 'factorial', 'width_bucket', 'floor', 'ceil', 'trunc', 'round', 'roundBankers', 'roundToExp2', 'roundDuration', 'roundAge', 'roundDown', 'rand', 'left', 'right', 'lengthUTF8', 'leftPad', 'rightPad', 'leftPadUTF8', 'rightPadUTF8', 'lower', 'upper', 'lowerUTF8', 'upperUTF8', 'isValidUTF8', 'toValidUTF8', 'format', 'reverseUTF8', 'concat', 'substring', 'substringUTF8', 'appendTrailingCharIfAbsent', 'convertCharset', 'base58Encode', 'base58Decode', 'tryBase58Decode', 'base64Encode', 'base64Decode', 'tryBase64Decode', 'endsWith', 'startsWith', 'encodeXMLComponent', 'decodeXMLComponent', 'extractTextFromHTML', 'ascii', 'concatWithSeparator', 'position', 'positionCaseInsensitive', 'positionUTF8', 'positionCaseInsensitiveUTF8', 'multiSearchAllPositions', 'multiSearchAllPositionsUTF8', 'multiSearchFirstPosition', 'multiSearchFirstIndex', 'multiSearchAny', 'multiSearchAllPositionsCaseInsensitive', 'multiSearchAllPositionsCaseInsensitiveUTF8', 'multiSearchAnyUTF8', 'multiSearchAnyCaseInsensitive', 'multiSearchAnyCaseInsensitiveUTF8', 'multiSearchFirstIndexUTF8', 'multiSearchFirstIndexCaseInsensitive', 'multiSearchFirstIndexCaseInsensitiveUTF8', 'multiSearchFirstPositionUTF8', 'multiSearchFirstPositionCaseInsensitive', 'multiSearchFirstPositionCaseInsensitiveUTF8', 'match', 'multiMatchAny', 'multiMatchAnyIndex', 'multiMatchAllIndices', 'multiFuzzyMatchAny', 'multiFuzzyMatchAnyIndex', 'multiFuzzyMatchAllIndices', 'extract', 'extractAll', 'extractAllGroupsHorizontal', 'extractAllGroupsVertical', 'extractGroups', 'like', 'ilike', 'notLike', 'notILike', 'locate', 'ngramDistance', 'ngramDistanceCaseInsensitive', 'ngramDistanceUTF8', 'ngramDistanceCaseInsensitiveUTF8', 'ngramSearch', 'ngramSearchCaseInsensitive', 'ngramSearchUTF8', 'ngramSearchCaseInsensitiveUTF8', 'countSubstrings', 'countSubstringsCaseInsensitive', 'countSubstringsCaseInsensitiveUTF8', 'countMatches', 'countMatchesCaseInsensitive', 'hasSubsequence', 'hasSubsequenceCaseInsensitive', 'hasSubsequenceUTF8', 'hasSubsequenceCaseInsensitiveUTF8', 'hasToken', 'hasTokenCaseInsensitive', 'hasTokenOrNull', 'hasTokenCaseInsensitiveOrNull', 'hasAllTokens', 'hasAnyTokens', 'regexpExtract', 'replace', 'replaceAll', 'replaceOne', 'replaceRegexpAll', 'replaceRegexpOne', 'regexpQuoteMeta', 'translate', 'translateUTF8', 'splitByChar', 'splitByString', 'splitByRegexp', 'splitByWhitespace', 'splitByNonAlpha', 'alphaTokens', 'extractAllGroups', 'ngrams', 'tokens', 'repeat', 'initcap', 'lpad', 'rpad', 'split_part', 'ltrim', 'trimLeft', 'rtrim', 'trimRight', 'btrim', 'trim', 'equals', 'notEquals', 'less', 'greater', 'lessOrEquals', 'greaterOrEquals', 'in', 'notIn', 'and', 'or', 'xor', 'not', 'if', 'multiIf', 'throwIf', 'map', 'mapFromArrays', 'mapAdd', 'mapSubtract', 'mapPopulateSeries', 'mapContains', 'mapKeys', 'mapValues', 'mapContainsKeyLike', 'mapExtractKeyLike', 'mapApply', 'mapFilter', 'mapUpdate', 'bitAnd', 'bitOr', 'bitXor', 'bitNot', 'bitShiftLeft', 'bitShiftRight', 'bitRotateLeft', 'bitRotateRight', 'bitSlice', 'bitTest', 'bitTestAll', 'bitTestAny', 'bitCount', 'bitHammingDistance', 'bitmapBuild', 'bitmapToArray', 'bitmapSubsetInRange', 'bitmapSubsetLimit', 'subBitmap', 'bitmapContains', 'bitmapHasAny', 'bitmapHasAll', 'bitmapCardinality', 'bitmapMin', 'bitmapMax', 'bitmapTransform', 'bitmapAnd', 'bitmapOr', 'bitmapXor', 'bitmapAndnot', 'bitmapAndCardinality', 'bitmapOrCardinality', 'bitmapXorCardinality', 'bitmapAndnotCardinality', 'protocol', 'domain', 'domainWithoutWWW', 'topLevelDomain', 'firstSignificantSubdomain', 'cutToFirstSignificantSubdomain', 'cutToFirstSignificantSubdomainWithWWW', 'port', 'path', 'pathFull', 'queryString', 'fragment', 'queryStringAndFragment', 'extractURLParameter', 'extractURLParameters', 'extractURLParameterNames', 'URLHierarchy', 'URLPathHierarchy', 'encodeURLComponent', 'decodeURLComponent', 'encodeURLFormComponent', 'decodeURLFormComponent', 'netloc', 'cutWWW', 'cutQueryString', 'cutFragment', 'cutQueryStringAndFragment', 'cutURLParameter', 'IPv4NumToString', 'IPv4StringToNum', 'IPv4StringToNumOrDefault', 'IPv4StringToNumOrNull', 'IPv6NumToString', 'IPv6StringToNum', 'IPv6StringToNumOrDefault', 'IPv6StringToNumOrNull', 'IPv4ToIPv6', 'toIPv4', 'toIPv4OrDefault', 'toIPv4OrNull', 'toIPv4OrZero', 'toIPv6', 'toIPv6OrDefault', 'toIPv6OrNull', 'toIPv6OrZero', 'isIPv4String', 'isIPv6String', 'isIPAddressInRange', 'IPv4CIDRToRange', 'IPv6CIDRToRange', 'cutIPv6', 'tuple', 'tupleElement', 'untuple', 'tupleHammingDistance', 'tupleToNameValuePairs', 'tuplePlus', 'tupleMinus', 'tupleMultiply', 'tupleDivide', 'tupleNegate', 'tupleMultiplyByNumber', 'tupleDivideByNumber', 'dotProduct', 'isFinite', 'isInfinite', 'ifNotFinite', 'isNaN', 'bar', 'transform', 'formatReadableDecimalSize', 'formatReadableSize', 'formatReadableQuantity', 'formatReadableTimeDelta', 'least', 'greatest', 'indexHint', 'extractIPv4Substrings', 'tumble', 'hop', 'tumbleStart', 'tumbleEnd', 'hopStart', 'hopEnd', 'L1Norm', 'L2Norm', 'LinfNorm', 'LpNorm', 'L1Distance', 'L2Distance', 'LinfDistance', 'LpDistance', 'L1Normalize', 'L2Normalize', 'LinfNormalize', 'LpNormalize', 'cosineDistance', 'rank', 'dense_rank', 'row_number', 'first_value', 'last_value', 'nth_value', 'lagInFrame', 'leadInFrame', 'lag', 'lead', 'languageCodeToName', 'aggregate_funnel', 'aggregate_funnel_array', 'aggregate_funnel_cohort', 'aggregate_funnel_trends', 'aggregate_funnel_array_trends', 'aggregate_funnel_cohort_trends', 'aggregate_funnel_json', 'aggregate_funnel_array_json', 'aggregate_funnel_cohort_json', 'aggregate_funnel_trends_json', 'aggregate_funnel_array_trends_json', 'aggregate_funnel_cohort_trends_json', 'aggregate_funnel_test', 'aggregate_funnel_array_trends_test']
+ ['plus', 'minus', 'multiply', 'divide', 'intDiv', 'intDivOrZero', 'modulo', 'moduloOrZero', 'positiveModulo', 'negate', 'abs', 'gcd', 'lcm', 'max2', 'min2', 'multiplyDecimal', 'divideDecimal', 'empty', 'notEmpty', 'length', 'reverse', 'array', 'range', 'arrayConcat', 'arrayElement', 'has', 'hasAll', 'hasAny', 'hasSubstr', 'indexOf', 'arrayCount', 'countEqual', 'arrayEnumerate', 'arrayEnumerateUniq', 'arrayPopBack', 'arrayPopFront', 'arrayPushBack', 'arrayPushFront', 'arrayResize', 'arraySlice', 'arraySort', 'arrayReverseSort', 'arrayUniq', 'arrayJoin', 'arrayDifference', 'arrayDistinct', 'arrayEnumerateDense', 'arrayIntersect', 'arrayReduce', 'arrayReverse', 'arrayFilter', 'arrayFlatten', 'arrayCompact', 'arrayZip', 'arrayAUC', 'arrayMap', 'arrayFill', 'arrayFold', 'arrayWithConstant', 'arraySplit', 'arrayReverseFill', 'arrayReverseSplit', 'arrayRotateLeft', 'arrayRotateRight', 'arrayExists', 'arrayAll', 'arrayFirst', 'arrayLast', 'arrayFirstIndex', 'arrayLastIndex', 'arrayMin', 'arrayMax', 'arraySum', 'arrayAvg', 'arrayCumSum', 'arrayCumSumNonNegative', 'arrayProduct', 'arrayStringConcat', 'generateSeries', 'hex', 'unhex', 'reinterpretAsUInt8', 'reinterpretAsUInt16', 'reinterpretAsUInt32', 'reinterpretAsUInt64', 'reinterpretAsUInt128', 'reinterpretAsUInt256', 'reinterpretAsInt8', 'reinterpretAsInt16', 'reinterpretAsInt32', 'reinterpretAsInt64', 'reinterpretAsInt128', 'reinterpretAsInt256', 'reinterpretAsFloat32', 'reinterpretAsFloat64', 'reinterpretAsUUID', 'accurateCast', 'accurateCastOrNull', 'toInt', 'toIntOrZero', 'toIntOrDefault', '_toInt8', '_toInt16', '_toInt32', '_toInt64', '_toUInt8', '_toUInt64', '_toUInt128', 'toFloat', 'toFloatOrNull', 'toFloat64OrNull', 'toFloatOrZero', 'toFloatOrDefault', 'toDecimal', '_toDate', 'toUUID', 'toUUIDOrDefault', 'toString', 'toNullableString', 'toBool', 'toJSONString', 'parseDateTime', 'parseDateTimeBestEffort', 'dynamicType', 'toTypeName', 'defaultValueOfTypeName', 'cityHash64', 'UUIDv7ToDateTime', 'toDate', 'to_date', 'toDateTime', 'toDateTime64', 'toDateTimeUS', 'isnull', 'isNotNull', 'coalesce', 'ifnull', 'nullif', 'assumeNotNull', 'toNullable', 'timeZoneOf', 'timeZoneOffset', 'toYear', 'toQuarter', 'toMonth', 'toDayOfYear', 'toDayOfMonth', 'toDayOfWeek', 'toHour', 'toMinute', 'toSecond', 'toUnixTimestamp', 'toUnixTimestamp64Milli', 'fromUnixTimestamp64Milli', 'toStartOfInterval', 'toStartOfYear', 'toStartOfISOYear', 'toStartOfQuarter', 'toStartOfMonth', 'toLastDayOfMonth', 'toMonday', 'toStartOfWeek', 'toStartOfDay', 'toLastDayOfWeek', 'toStartOfHour', 'toStartOfMinute', 'toStartOfSecond', 'toStartOfFiveMinutes', 'toStartOfTenMinutes', 'toStartOfFifteenMinutes', 'toTime', 'toISOYear', 'toISOWeek', 'toWeek', 'toYearWeek', 'age', 'dateAdd', 'dateSub', 'date_bin', 'date_add', 'date_subtract', 'date_diff', 'dateDiff', 'timeStampAdd', 'timeStampSub', 'nowInBlock', 'rowNumberInBlock', 'rowNumberInAllBlocks', 'timeSlot', 'toYYYYMM', 'toYYYYMMDD', 'toYYYYMMDDhhmmss', 'addYears', 'addMonths', 'addWeeks', 'addDays', 'addHours', 'addMinutes', 'addSeconds', 'addQuarters', 'subtractYears', 'subtractMonths', 'subtractWeeks', 'subtractDays', 'subtractHours', 'subtractMinutes', 'subtractSeconds', 'subtractQuarters', 'timeSlots', 'formatDateTime', 'dateName', 'monthName', 'fromUnixTimestamp', 'toModifiedJulianDay', 'fromModifiedJulianDay', 'toIntervalSecond', 'toIntervalMinute', 'toIntervalHour', 'toIntervalDay', 'toIntervalWeek', 'toIntervalMonth', 'toIntervalQuarter', 'toIntervalYear', 'now', 'yesterday', 'current_timestamp', 'today', 'current_date', 'date_part', 'date_trunc', 'dateTrunc', 'to_timestamp', 'to_char', 'make_timestamp', 'make_date', 'make_interval', 'make_timestamptz', 'timezone', 'toTimeZone', 'greatCircleDistance', 'geoDistance', 'greatCircleAngle', 'pointInEllipses', 'pointInPolygon', 'geohashEncode', 'geohashDecode', 'geohashesInBox', 'h3IsValid', 'h3GetResolution', 'h3GetBaseCell', 'h3EdgeAngle', 'h3EdgeLengthM', 'h3EdgeLengthKm', 'geoToH3', 'h3ToGeo', 'h3ToGeoBoundary', 'h3kRing', 'h3HexAreaM2', 'h3HexAreaKm2', 'h3IndexesAreNeighbors', 'h3ToChildren', 'h3ToParent', 'h3ToString', 'stringToH3', 'h3IsResClassIII', 'h3IsPentagon', 'h3GetFaces', 'h3CellAreaM2', 'h3CellAreaRads2', 'h3ToCenterChild', 'h3ExactEdgeLengthM', 'h3ExactEdgeLengthKm', 'h3ExactEdgeLengthRads', 'h3NumHexagons', 'h3PointDistM', 'h3PointDistKm', 'h3PointDistRads', 'h3GetRes0Indexes', 'h3GetPentagonIndexes', 'h3Line', 'h3Distance', 'h3HexRing', 'h3GetUnidirectionalEdge', 'h3UnidirectionalEdgeIsValid', 'h3GetOriginIndexFromUnidirectionalEdge', 'h3GetDestinationIndexFromUnidirectionalEdge', 'h3GetIndexesFromUnidirectionalEdge', 'h3GetUnidirectionalEdgesFromHexagon', 'h3GetUnidirectionalEdgeBoundary', 'isValidJSON', 'JSONHas', 'JSONLength', 'JSONArrayLength', 'JSONType', 'JSONExtract', 'JSONExtractUInt', 'JSONExtractInt', 'JSONExtractFloat', 'JSONExtractBool', 'JSONExtractString', 'JSONExtractKeys', 'JSONExtractRaw', 'JSONExtractArrayRaw', 'JSONExtractKeysAndValues', 'JSONExtractKeysAndValuesRaw', 'JSON_VALUE', 'e', 'pi', 'exp', 'log', 'ln', 'exp2', 'log2', 'exp10', 'log10', 'sqrt', 'cbrt', 'erf', 'erfc', 'lgamma', 'tgamma', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'pow', 'power', 'intExp2', 'intExp10', 'cosh', 'acosh', 'sinh', 'asinh', 'atanh', 'atan2', 'hypot', 'log1p', 'sign', 'degrees', 'radians', 'factorial', 'width_bucket', 'floor', 'ceil', 'trunc', 'round', 'roundBankers', 'roundToExp2', 'roundDuration', 'roundAge', 'roundDown', 'rand', 'left', 'right', 'lengthUTF8', 'leftPad', 'rightPad', 'leftPadUTF8', 'rightPadUTF8', 'lower', 'upper', 'lowerUTF8', 'upperUTF8', 'isValidUTF8', 'toValidUTF8', 'format', 'reverseUTF8', 'concat', 'substring', 'substringUTF8', 'appendTrailingCharIfAbsent', 'convertCharset', 'base58Encode', 'base58Decode', 'tryBase58Decode', 'base64Encode', 'base64Decode', 'tryBase64Decode', 'endsWith', 'startsWith', 'encodeXMLComponent', 'decodeXMLComponent', 'extractTextFromHTML', 'ascii', 'concatWithSeparator', 'position', 'positionCaseInsensitive', 'positionUTF8', 'positionCaseInsensitiveUTF8', 'multiSearchAllPositions', 'multiSearchAllPositionsUTF8', 'multiSearchFirstPosition', 'multiSearchFirstIndex', 'multiSearchAny', 'multiSearchAllPositionsCaseInsensitive', 'multiSearchAllPositionsCaseInsensitiveUTF8', 'multiSearchAnyUTF8', 'multiSearchAnyCaseInsensitive', 'multiSearchAnyCaseInsensitiveUTF8', 'multiSearchFirstIndexUTF8', 'multiSearchFirstIndexCaseInsensitive', 'multiSearchFirstIndexCaseInsensitiveUTF8', 'multiSearchFirstPositionUTF8', 'multiSearchFirstPositionCaseInsensitive', 'multiSearchFirstPositionCaseInsensitiveUTF8', 'match', 'multiMatchAny', 'multiMatchAnyIndex', 'multiMatchAllIndices', 'multiFuzzyMatchAny', 'multiFuzzyMatchAnyIndex', 'multiFuzzyMatchAllIndices', 'extract', 'extractAll', 'extractAllGroupsHorizontal', 'extractAllGroupsVertical', 'extractGroups', 'like', 'ilike', 'notLike', 'notILike', 'locate', 'ngramDistance', 'ngramDistanceCaseInsensitive', 'ngramDistanceUTF8', 'ngramDistanceCaseInsensitiveUTF8', 'ngramSearch', 'ngramSearchCaseInsensitive', 'ngramSearchUTF8', 'ngramSearchCaseInsensitiveUTF8', 'countSubstrings', 'countSubstringsCaseInsensitive', 'countSubstringsCaseInsensitiveUTF8', 'countMatches', 'countMatchesCaseInsensitive', 'hasSubsequence', 'hasSubsequenceCaseInsensitive', 'hasSubsequenceUTF8', 'hasSubsequenceCaseInsensitiveUTF8', 'hasToken', 'hasTokenCaseInsensitive', 'hasTokenOrNull', 'hasTokenCaseInsensitiveOrNull', 'hasAllTokens', 'hasAnyTokens', 'regexpExtract', 'replace', 'replaceAll', 'replaceOne', 'replaceRegexpAll', 'replaceRegexpOne', 'regexpQuoteMeta', 'translate', 'translateUTF8', 'splitByChar', 'splitByString', 'splitByRegexp', 'splitByWhitespace', 'splitByNonAlpha', 'alphaTokens', 'extractAllGroups', 'ngrams', 'tokens', 'repeat', 'initcap', 'lpad', 'rpad', 'split_part', 'ltrim', 'trimLeft', 'rtrim', 'trimRight', 'btrim', 'trim', 'equals', 'notEquals', 'less', 'greater', 'lessOrEquals', 'greaterOrEquals', 'in', 'notIn', 'and', 'or', 'xor', 'not', '_caseWithExpression', 'if', 'multiIf', 'throwIf', 'map', 'mapFromArrays', 'mapAdd', 'mapSubtract', 'mapPopulateSeries', 'mapContains', 'mapKeys', 'mapValues', 'mapContainsKeyLike', 'mapExtractKeyLike', 'mapApply', 'mapFilter', 'mapUpdate', 'bitAnd', 'bitOr', 'bitXor', 'bitNot', 'bitShiftLeft', 'bitShiftRight', 'bitRotateLeft', 'bitRotateRight', 'bitSlice', 'bitTest', 'bitTestAll', 'bitTestAny', 'bitCount', 'bitHammingDistance', 'bitmapBuild', 'bitmapToArray', 'bitmapSubsetInRange', 'bitmapSubsetLimit', 'subBitmap', 'bitmapContains', 'bitmapHasAny', 'bitmapHasAll', 'bitmapCardinality', 'bitmapMin', 'bitmapMax', 'bitmapTransform', 'bitmapAnd', 'bitmapOr', 'bitmapXor', 'bitmapAndnot', 'bitmapAndCardinality', 'bitmapOrCardinality', 'bitmapXorCardinality', 'bitmapAndnotCardinality', 'protocol', 'domain', 'domainWithoutWWW', 'topLevelDomain', 'firstSignificantSubdomain', 'cutToFirstSignificantSubdomain', 'cutToFirstSignificantSubdomainWithWWW', 'port', 'path', 'pathFull', 'queryString', 'fragment', 'queryStringAndFragment', 'extractURLParameter', 'extractURLParameters', 'extractURLParameterNames', 'URLHierarchy', 'URLPathHierarchy', 'encodeURLComponent', 'decodeURLComponent', 'encodeURLFormComponent', 'decodeURLFormComponent', 'netloc', 'cutWWW', 'cutQueryString', 'cutFragment', 'cutQueryStringAndFragment', 'cutURLParameter', 'IPv4NumToString', 'IPv4StringToNum', 'IPv4StringToNumOrDefault', 'IPv4StringToNumOrNull', 'IPv6NumToString', 'IPv6StringToNum', 'IPv6StringToNumOrDefault', 'IPv6StringToNumOrNull', 'IPv4ToIPv6', 'toIPv4', 'toIPv4OrDefault', 'toIPv4OrNull', 'toIPv4OrZero', 'toIPv6', 'toIPv6OrDefault', 'toIPv6OrNull', 'toIPv6OrZero', 'isIPv4String', 'isIPv6String', 'isIPAddressInRange', 'IPv4CIDRToRange', 'IPv6CIDRToRange', 'cutIPv6', 'tuple', 'tupleElement', 'untuple', 'tupleHammingDistance', 'tupleToNameValuePairs', 'tuplePlus', 'tupleMinus', 'tupleMultiply', 'tupleDivide', 'tupleNegate', 'tupleMultiplyByNumber', 'tupleDivideByNumber', 'dotProduct', 'isFinite', 'isInfinite', 'ifNotFinite', 'isNaN', 'bar', 'transform', 'formatReadableDecimalSize', 'formatReadableSize', 'formatReadableQuantity', 'formatReadableTimeDelta', 'least', 'greatest', 'indexHint', 'extractIPv4Substrings', 'tumble', 'hop', 'tumbleStart', 'tumbleEnd', 'hopStart', 'hopEnd', 'L1Norm', 'L2Norm', 'LinfNorm', 'LpNorm', 'L1Distance', 'L2Distance', 'LinfDistance', 'LpDistance', 'L1Normalize', 'L2Normalize', 'LinfNormalize', 'LpNormalize', 'cosineDistance', 'rank', 'dense_rank', 'row_number', 'first_value', 'last_value', 'nth_value', 'lagInFrame', 'leadInFrame', 'lag', 'lead', 'languageCodeToName', 'aggregate_funnel', 'aggregate_funnel_array', 'aggregate_funnel_cohort', 'aggregate_funnel_trends', 'aggregate_funnel_array_trends', 'aggregate_funnel_cohort_trends', 'aggregate_funnel_json', 'aggregate_funnel_array_json', 'aggregate_funnel_cohort_json', 'aggregate_funnel_trends_json', 'aggregate_funnel_array_trends_json', 'aggregate_funnel_cohort_trends_json', 'aggregate_funnel_test', 'aggregate_funnel_array_trends_test']
```
These are the aggregated HogQL functions:
diff --git a/pyproject.toml b/pyproject.toml
index 6ccfe32e4fec..149ba380c2cc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -67,8 +67,8 @@ dependencies = [
"grimp~=3.14",
"grpcio~=1.71.0",
"gspread==6.2.1",
- "hogql-parser==1.3.83",
- "hogql-parser-rs==1.3.106", # 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==1.3.84",
+ "hogql-parser-rs==1.3.109", # 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 f5786ec95137..e419c70c3fba 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -5373,7 +5373,7 @@ dependencies = [
[[package]]
name = "hogql_parser_rs"
-version = "1.3.107"
+version = "1.3.109"
dependencies = [
"pyo3",
"serde_json",
diff --git a/rust/hogql/parser/Cargo.toml b/rust/hogql/parser/Cargo.toml
index 359bbbaa3007..efb855114f0c 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; each ships as its own PyPI wheel.
-version = "1.3.107"
+version = "1.3.109"
edition = "2021"
publish = false
diff --git a/rust/hogql/parser/pyproject.toml b/rust/hogql/parser/pyproject.toml
index 889622493fbf..049ef3b6bacf 100644
--- a/rust/hogql/parser/pyproject.toml
+++ b/rust/hogql/parser/pyproject.toml
@@ -9,7 +9,7 @@ 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.
-version = "1.3.107"
+version = "1.3.109"
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/expr.rs b/rust/hogql/parser/src/parse/expr.rs
index e062e680fc07..97deea5fcb1d 100644
--- a/rust/hogql/parser/src/parse/expr.rs
+++ b/rust/hogql/parser/src/parse/expr.rs
@@ -1040,7 +1040,7 @@ impl<'a, E: Emitter + Clone> Parser<'a, E> {
// ====================================================================
/// `CASE [scrutinee] WHEN c1 THEN r1 [WHEN c2 THEN r2 ...] [ELSE r] END`
- /// rewrites to `Call("if"|"multiIf"|"transform", ...)` per the C++
+ /// rewrites to `Call("if"|"multiIf"|"_caseWithExpression", ...)` per the C++
/// visitor's [`VISIT(ColumnExprCase)`] logic.
fn parse_case_expr(&mut self) -> Result<E::Value, ParseError> {
self.expect_kw(Kw::Case, "CASE")?;
@@ -1089,72 +1089,29 @@ impl<'a, E: Emitter + Clone> Parser<'a, E> {
return Err(self.err("CASE expression requires at least one WHEN"));
}
let else_branch = if self.eat_kw(Kw::Else)? {
- Some(self.parse_expr_bp(0)?)
+ self.parse_expr_bp(0)?
} else {
- None
+ self.emit.constant(self.emit.null())
};
self.expect_kw(Kw::End, "END")?;
if let Some(scrut) = scrutinee {
- // `case S when v then r [else d] end` → `transform(S,
- // [whens], [thens], else)`. The cpp visitor builds a flat
- // column list and unconditionally treats the LAST item as
- // the else-position default — so when ELSE is omitted, the
- // final THEN value migrates into the else slot and the
- // `thens` array loses its last element. Mirror that quirk
- // exactly:
- //
- // case S when v then r end → transform(S, [v], [], r)
- // case S when v then r else d end → transform(S, [v], [r], d)
- // case S when v1 then r1 when v2 then r2 end
- // → transform(S, [v1, v2], [r1], r2)
- let mut flat: Vec<E::Value> = Vec::with_capacity(whens.len() * 2 + 2);
+ let mut args: Vec<E::Value> = Vec::with_capacity(whens.len() * 2 + 2);
+ args.push(scrut);
for (w, t) in whens.into_iter().zip(thens) {
- flat.push(w);
- flat.push(t);
- }
- if let Some(d) = else_branch {
- flat.push(d);
- }
- let else_arg = flat
- .pop()
- .unwrap_or_else(|| self.emit.constant(self.emit.null()));
- let mut whens_arr: Vec<E::Value> = Vec::new();
- let mut thens_arr: Vec<E::Value> = Vec::new();
- for (i, col) in flat.into_iter().enumerate() {
- if i % 2 == 0 {
- whens_arr.push(col);
- } else {
- thens_arr.push(col);
- }
+ args.push(w);
+ args.push(t);
}
- return Ok(self.emit.call(
- "transform",
- vec![
- scrut,
- self.emit.array_(whens_arr),
- self.emit.array_(thens_arr),
- else_arg,
- ],
- ));
+ args.push(else_branch);
+ return Ok(self.emit.call("_caseWithExpression", args));
}
- // No scrutinee. Build the flat column list the C++ visitor
- // sees: when/then pairs interleaved, optionally followed by
- // the ELSE value. The visitor dispatches purely on length:
- // 3 items → `if(c, r, d)`
- // anything else → `multiIf(...)`
- // Notably an implicit-NULL else is NOT synthesised here, so
- // `case when c then r end` produces `multiIf(c, r)`, not
- // `if(c, r, null)`.
let mut columns: Vec<E::Value> = Vec::with_capacity(whens.len() * 2 + 1);
for (w, t) in whens.into_iter().zip(thens) {
columns.push(w);
columns.push(t);
}
- if let Some(d) = else_branch {
- columns.push(d);
- }
+ columns.push(else_branch);
if columns.len() == 3 {
Ok(self.emit.call("if", columns))
} else {
diff --git a/uv.lock b/uv.lock
index 37f8830f865e..10c54c3135f2 100644
--- a/uv.lock
+++ b/uv.lock
@@ -3166,28 +3166,28 @@ provides-extras = ["dev"]
[[package]]
name = "hogql-parser"
-version = "1.3.83"
+version = "1.3.84"
source = { registry = "https://pypi.org/simple" }
-sdist = { url = "https://files.pythonhosted.org/packages/11/74/454ad6b88a8413dcfd3d9836882bb07100c7104f34f4344fb007b98823c6/hogql_parser-1.3.83.tar.gz", hash = "sha256:918d01242c520133ef9ecfcb10777c1fad50bbefb33ec6fa4e223dd57bfaa0cd", size = 93004, upload-time = "2026-07-30T13:24:39.648Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/6c/47/8899163a8a02ef242f816e9c9c62b376271591fe06cc4876304c65f2ecd3/hogql_parser-1.3.84.tar.gz", hash = "sha256:bb9caa3d0fcb0f6d7faadfdbf10db8d20f93c64be40a331f1134302994cc6de4", size = 92995, upload-time = "2026-08-17T12:54:36.406Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/42/47/03db0642fb99ec9f1e85117c6a33deca82a5dd02ad1e0c61470c6c6ff75e/hogql_parser-1.3.83-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:35c70d6e32c943ea2a0169ebecd82cf7ec87637991c5a6480cb04e1433613455", size = 659095, upload-time = "2026-07-30T13:24:33.378Z" },
- { url = "https://files.pythonhosted.org/packages/9d/da/5ba6cc064dc1793a27d875eb2cc00c46f633e64f361923bb1150feeca038/hogql_parser-1.3.83-cp313-cp313-macosx_15_0_x86_64.whl", hash = "sha256:81b7f3dd65efdb5dc0e127d076b91163b1deee5caf69bb85d1cd025dec44df58", size = 668701, upload-time = "2026-07-30T13:24:35.006Z" },
- { url = "https://files.pythonhosted.org/packages/b1/ed/97179b82f94e548e577dc3fd78832d8d2ba1bab591051936cf2a15eea24a/hogql_parser-1.3.83-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:bc8d0b44e6bf012e28861fcc5d1dfc5b652c9c67c5a345de2bca281dd2119116", size = 5119661, upload-time = "2026-07-30T13:24:36.542Z" },
- { url = "https://files.pythonhosted.org/packages/b6/de/13b7ad4db2c2fa87fb811b437bb511f128f71a3c6f8461684c8e0a08a165/hogql_parser-1.3.83-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:491fe843ea4d386cd2f067ea77d78ee9431fc0ceedd224ac3b1ffe663ae2c166", size = 5229817, upload-time = "2026-07-30T13:24:38.23Z" },
+ { url = "https://files.pythonhosted.org/packages/c7/ee/733c62d24180d3ce8a08a32ec059d5dce4b61b485ee24275086eca76d590/hogql_parser-1.3.84-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:9c4e050542a38e526ba28360382f241a747144fec0911b3f654ae72fbb3a0a55", size = 658667, upload-time = "2026-08-17T12:54:30.582Z" },
+ { url = "https://files.pythonhosted.org/packages/24/f0/d33bc908c5cf6597726483f05242ae06d113d3de9e20716adbe8020e28b9/hogql_parser-1.3.84-cp313-cp313-macosx_15_0_x86_64.whl", hash = "sha256:4434287edb0d1adb55601466b6a04fe0eb48becf3cf8adbadc6f1e82b1d60546", size = 668172, upload-time = "2026-08-17T12:54:31.924Z" },
+ { url = "https://files.pythonhosted.org/packages/56/25/a5c9d05851c9587546908337fffbccd95abe3b616fd52732078d1ca18f31/hogql_parser-1.3.84-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:4059b614279c4f58f43c74589fc27f0325a3e211044f0b961e49b92e39d1791b", size = 5111187, upload-time = "2026-08-17T12:54:33.328Z" },
+ { url = "https://files.pythonhosted.org/packages/72/07/1f500742a8fea6400d6676ae63204006e60f90dcd5525efbd10ea3dfd2ee/hogql_parser-1.3.84-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:221ec153b9dc5810c7f74729a33b89ceef6142216ce1c7a837f52312ab02c713", size = 5219820, upload-time = "2026-08-17T12:54:34.882Z" },
]
[[package]]
name = "hogql-parser-rs"
-version = "1.3.106"
+version = "1.3.109"
source = { registry = "https://pypi.org/simple" }
-sdist = { url = "https://files.pythonhosted.org/packages/c6/47/6690febe4d1495957c835d00b1f7c01fa625378287ac7ad7b52b86987928/hogql_parser_rs-1.3.106.tar.gz", hash = "sha256:d9fe032470a899644e019211ad7c3bd1170d2d3a23130f3af95d79ab5ee4c86d", size = 287692, upload-time = "2026-07-03T13:55:09.094Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/e0/34/f7a849b757886fa3b16d9ae4f749ef09b9320b6635a880b0e01dfaec096a/hogql_parser_rs-1.3.109.tar.gz", hash = "sha256:7d62b420d6ce3b4d1c64b860c4f8f4e0f9162f64815a5e3cf9e1c7ff764e2bd6", size = 296225, upload-time = "2026-08-17T12:42:52.242Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/d9/80/4f1ebb5af335af91dee119b097564c47c355dedfa8a561b575810a2b13e4/hogql_parser_rs-1.3.106-cp312-abi3-macosx_10_12_x86_64.whl", hash = "sha256:9e0c5f58cbe20f4c048c281d02d7a352cc3ac96dccdd3d6f495a15024db988c4", size = 700491, upload-time = "2026-07-03T13:55:00.532Z" },
- { url = "https://files.pythonhosted.org/packages/f3/09/d980bdd3d945efa9e142986987a35cd223583fab245b61e77fad0d5542e0/hogql_parser_rs-1.3.106-cp312-abi3-macosx_11_0_arm64.whl", hash = "sha256:f4b68566d58ee146be561b08d7deace4274485c3ccbfd0ebb60cdf6dd943a605", size = 662023, upload-time = "2026-07-03T13:55:02.134Z" },
- { url = "https://files.pythonhosted.org/packages/4a/6a/6bc32709cdf00075f32e84211ddbae1462f8ca3812b66363f33a20436d0f/hogql_parser_rs-1.3.106-cp312-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:46d2e37972147cd285241855b3fb48967515c2bf1440f3b8e5778f0e1bc10824", size = 2410045, upload-time = "2026-07-03T13:55:03.424Z" },
- { url = "https://files.pythonhosted.org/packages/25/32/9aadfa655cebef10e69804d68bf60c49d01702d17613978e57bf9dab48a2/hogql_parser_rs-1.3.106-cp312-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:ba1d29683334b4d7b90c046b4603b85ab020e11b1ee80e72a5e54aead3601a99", size = 2664065, upload-time = "2026-07-03T13:55:04.78Z" },
- { url = "https://files.pythonhosted.org/packages/aa/48/c848fef7e84251dd02bcce78df71d3b56f476e6c65f7378498a96803051b/hogql_parser_rs-1.3.106-cp312-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:5a581160747ab1784d39ee795491daae752c9d0bb26a1ddaa2a90905c7afe65e", size = 2582693, upload-time = "2026-07-03T13:55:06.164Z" },
- { url = "https://files.pythonhosted.org/packages/d5/2b/5f6b7a11aeb0a5e2922d9f40fe1722f271e816f8e857b32c7ea3a25e3c09/hogql_parser_rs-1.3.106-cp312-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:cfa70f607c40373e2eae216cb89ae4fb3b4900a67c7132305f610c2ea4cbe70b", size = 2629564, upload-time = "2026-07-03T13:55:07.586Z" },
+ { url = "https://files.pythonhosted.org/packages/30/3c/de648cbb3a4cc2c5f61aca8fcc1a79e699cfda2e68dabf78f2bfcdce28b3/hogql_parser_rs-1.3.109-cp312-abi3-macosx_10_12_x86_64.whl", hash = "sha256:e4a357f589522745e4ef088f4a0785c3888ab425dec6f1faa394aa3127d642c0", size = 719888, upload-time = "2026-08-17T12:42:42.296Z" },
+ { url = "https://files.pythonhosted.org/packages/0b/ab/8f054879065e2dffa66355d38d977fc6448ef4aa073193fbbc561c197964/hogql_parser_rs-1.3.109-cp312-abi3-macosx_11_0_arm64.whl", hash = "sha256:89b7e5422fcc08c2aa4beeceead1af133f9bedbd903fcdeb766ea9f1399db411", size = 667954, upload-time = "2026-08-17T12:42:43.955Z" },
+ { url = "https://files.pythonhosted.org/packages/02/93/460ebba7b35aa88855838722db634141c30f0f36b54d40a6b3a9f1e75dea/hogql_parser_rs-1.3.109-cp312-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:a0d4150a9e7aa4debeb830eab12d42cebba8fddd35f16bba0d710d95a955b2e6", size = 2448067, upload-time = "2026-08-17T12:42:45.463Z" },
+ { url = "https://files.pythonhosted.org/packages/55/b1/92bcebeaab0b5d6f8cd30532b5ea22c03fbf51f9ab347c86265f039599b3/hogql_parser_rs-1.3.109-cp312-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:cb7475e7cd44bd360580b1b5830e2a29f5b51dfb944dc909170e1a5ce15744b6", size = 2719778, upload-time = "2026-08-17T12:42:47.087Z" },
+ { url = "https://files.pythonhosted.org/packages/cd/78/3f4988c9d6dfaa58e0a74287d2ed1a79c2313831779bc155e7d9a1ee63b7/hogql_parser_rs-1.3.109-cp312-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:1f31adc75b77233b43fcb8b8b05e1c2c7595c727713a8988493f6a8c9e617b85", size = 2620064, upload-time = "2026-08-17T12:42:48.833Z" },
+ { url = "https://files.pythonhosted.org/packages/a3/54/49faa43a6929b0b3c8a7b46d8cbb5ad5dfa51d0247bbfa652f7bf4e1e349/hogql_parser_rs-1.3.109-cp312-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:9a083ca52277ca62209f0fe6c9701efa10cff6814789aa239f86fa2b8b27f76e", size = 2677434, upload-time = "2026-08-17T12:42:50.571Z" },
]
[[package]]
@@ -5920,8 +5920,8 @@ requires-dist = [
{ name = "grimp", specifier = "~=3.14" },
{ name = "grpcio", specifier = "~=1.71.0" },
{ name = "gspread", specifier = "==6.2.1" },
- { name = "hogql-parser", specifier = "==1.3.83" },
- { name = "hogql-parser-rs", specifier = "==1.3.106" },
+ { name = "hogql-parser", specifier = "==1.3.84" },
+ { name = "hogql-parser-rs", specifier = "==1.3.109" },
{ 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" },