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(api): Support Hogql modifiers (#106758)

Tomás Farías Santana64538b6c90df
diff --git a/products/batch_exports/backend/api/batch_export.py b/products/batch_exports/backend/api/batch_export.py
index f734095e1ca7..dc905dfdce9b 100644
--- a/products/batch_exports/backend/api/batch_export.py
+++ b/products/batch_exports/backend/api/batch_export.py
@@ -53,11 +53,16 @@ from posthog.utils import relative_date_parse, str_to_bool
from products.access_control.backend.facade.api import get_restricted_properties_with_group_type_index_for_team
from products.batch_exports.backend.api.destination_tests import get_destination_test
-from products.batch_exports.backend.api.utils import check_hogql_batch_exports_enabled
+from products.batch_exports.backend.api.utils import (
+ HOGQL_MODIFIERS_HELP_TEXT,
+ HogQLModifiersField,
+ check_hogql_batch_exports_enabled,
+)
from products.batch_exports.backend.hogql_source import (
DATA_INTERVAL_START_PLACEHOLDER,
UnsupportedHogQLQueryError,
find_interval_placeholders,
+ load_hogql_modifiers,
parse_hogql_select_for_batch_export,
serialize_batch_export_query,
validate_hogql_query_for_batch_export,
@@ -865,6 +870,11 @@ class BatchExportRequestSerializer(serializers.Serializer):
allow_null=True,
help_text=HOGQL_QUERY_HELP_TEXT,
)
+ hogql_modifiers = HogQLModifiersField(
+ required=False,
+ allow_null=True,
+ help_text=HOGQL_MODIFIERS_HELP_TEXT,
+ )
filters = serializers.JSONField(
required=False,
allow_null=True,
@@ -1214,6 +1224,11 @@ class BatchExportSerializer(serializers.ModelSerializer):
allow_null=True,
help_text=HOGQL_QUERY_HELP_TEXT,
)
+ hogql_modifiers = HogQLModifiersField(
+ required=False,
+ allow_null=True,
+ help_text=HOGQL_MODIFIERS_HELP_TEXT,
+ )
timezone = serializers.ChoiceField(
choices=TIMEZONES,
required=False,
@@ -1252,6 +1267,7 @@ class BatchExportSerializer(serializers.ModelSerializer):
"end_at",
"latest_runs",
"hogql_query",
+ "hogql_modifiers",
"schema",
"filters",
"timezone",
@@ -1329,6 +1345,11 @@ class BatchExportSerializer(serializers.ModelSerializer):
self._validate_hogql(attrs)
return
+ if attrs.get("hogql_modifiers") is not None:
+ raise serializers.ValidationError(
+ {"hogql_modifiers": "'hogql_modifiers' are only supported when 'model' is 'hogql'"}
+ )
+
if (hogql_query := attrs.get("hogql_query")) is not None:
# For events model, we need the resolved AST.
attrs["hogql_query"] = self._validate_events_hogql_query(hogql_query)
@@ -1739,10 +1760,11 @@ class BatchExportSerializer(serializers.ModelSerializer):
team_id = self.context["team_id"]
model = validated_data.get("model") or BatchExport.Model.EVENTS
hogql_query = validated_data.pop("hogql_query", None)
+ hogql_modifiers = validated_data.pop("hogql_modifiers", None)
source = None
if model == BatchExport.Model.HOGQL:
- source = BatchExportSource(team_id=team_id, hogql_query=hogql_query)
+ source = BatchExportSource(team_id=team_id, hogql_query=hogql_query, hogql_modifiers=hogql_modifiers)
elif hogql_query is not None:
# TODO: Migrate batch exports using a HogQL query to HogQL model.
validated_data["schema"] = self.serialize_hogql_query_to_batch_export_schema(hogql_query)
@@ -1804,7 +1826,7 @@ class BatchExportSerializer(serializers.ModelSerializer):
def _validate_hogql(self, attrs: dict[str, typing.Any]) -> None:
"""Validate the source of a batch export with the 'hogql' model.
- On update, a query missing from the request keeps the one stored in the source.
+ On update, a query or modifiers missing from the request keep the ones stored in the source.
"""
if attrs.get("filters"):
raise serializers.ValidationError({"filters": "'filters' are not supported when 'model' is 'hogql'"})
@@ -1817,9 +1839,16 @@ class BatchExportSerializer(serializers.ModelSerializer):
if not hogql_query:
raise serializers.ValidationError({"hogql_query": "'hogql_query' is required when 'model' is 'hogql'"})
+ try:
+ modifiers = load_hogql_modifiers(
+ attrs.get("hogql_modifiers", source.hogql_modifiers if source is not None else None)
+ )
+ except UnsupportedHogQLQueryError as e:
+ raise serializers.ValidationError({"hogql_modifiers": str(e)}) from e
+
user = self.context["request"].user
try:
- validate_hogql_query_for_batch_export(hogql_query, team, user=user)
+ validate_hogql_query_for_batch_export(hogql_query, team, user=user, modifiers=modifiers)
except UnsupportedHogQLQueryError as e:
raise serializers.ValidationError({"hogql_query": str(e)}) from e
@@ -1885,6 +1914,8 @@ class BatchExportSerializer(serializers.ModelSerializer):
destination_data = validated_data.pop("destination", None)
hogql_query_provided = "hogql_query" in validated_data
hogql_query = validated_data.pop("hogql_query", None)
+ hogql_modifiers_provided = "hogql_modifiers" in validated_data
+ hogql_modifiers = validated_data.pop("hogql_modifiers", None)
user = self.context["request"].user
if not isinstance(user, User):
@@ -1905,9 +1936,12 @@ class BatchExportSerializer(serializers.ModelSerializer):
batch_export.destination.integration = integration
if batch_export.model == BatchExport.Model.HOGQL:
- if hogql_query is not None:
+ if hogql_query is not None or hogql_modifiers_provided:
source = batch_export.source or BatchExportSource(team_id=batch_export.team_id)
- source.hogql_query = hogql_query
+ if hogql_query is not None:
+ source.hogql_query = hogql_query
+ if hogql_modifiers_provided:
+ source.hogql_modifiers = hogql_modifiers
source.save()
batch_export.source = source
elif hogql_query is not None:
diff --git a/products/batch_exports/backend/api/file_download.py b/products/batch_exports/backend/api/file_download.py
index 6bf820b1f29c..a6c125459c86 100644
--- a/products/batch_exports/backend/api/file_download.py
+++ b/products/batch_exports/backend/api/file_download.py
@@ -19,6 +19,8 @@ from rest_framework import mixins, response, serializers, status, viewsets
from rest_framework.exceptions import APIException, NotAuthenticated, NotFound, ValidationError
from rest_framework.throttling import BaseThrottle
+from posthog.schema import HogQLQueryModifiers
+
from posthog.hogql.errors import ExposedHogQLError
from posthog.hogql.query import execute_hogql_query
@@ -32,10 +34,15 @@ from posthog.models import Team, User
from posthog.rate_limit import BatchExportsCountRowsBurstRateThrottle, BatchExportsCountRowsSustainedRateThrottle
from posthog.temporal.common.client import sync_connect
-from products.batch_exports.backend.api.utils import check_hogql_batch_exports_enabled
+from products.batch_exports.backend.api.utils import (
+ HOGQL_MODIFIERS_HELP_TEXT,
+ HogQLModifiersField,
+ check_hogql_batch_exports_enabled,
+)
from products.batch_exports.backend.hogql_source import (
UnsupportedHogQLQueryError,
find_interval_placeholders,
+ load_hogql_modifiers,
parse_hogql_select_for_batch_export,
validate_hogql_query_for_batch_export,
)
@@ -194,6 +201,7 @@ class FileDownloadHogQLRequestSerializer(serializers.Serializer):
file = FileDownloadDestinationFileConfigSerializer()
model = serializers.ChoiceField(choices=FileDownloadHogQLModel.choices)
hogql_query = serializers.CharField(help_text=HOGQL_QUERY_HELP_TEXT)
+ hogql_modifiers = HogQLModifiersField(required=False, help_text=HOGQL_MODIFIERS_HELP_TEXT)
data_interval_start = serializers.DateTimeField(
default_timezone=dt.UTC, required=False, help_text=DATA_INTERVAL_START_HELP_TEXT
)
@@ -210,6 +218,7 @@ class FileDownloadCountRowsRequestSerializer(serializers.Serializer):
help_text="Model to count rows for. Only 'hogql' is supported.",
)
hogql_query = serializers.CharField(help_text=HOGQL_QUERY_HELP_TEXT)
+ hogql_modifiers = HogQLModifiersField(required=False, help_text=HOGQL_MODIFIERS_HELP_TEXT)
data_interval_start = serializers.DateTimeField(
default_timezone=dt.UTC, required=False, help_text=DATA_INTERVAL_START_HELP_TEXT
)
@@ -251,13 +260,14 @@ def count_rows_for_hogql_batch_export(
user: User,
data_interval_start: dt.datetime | None = None,
data_interval_end: dt.datetime | None = None,
+ modifiers: HogQLQueryModifiers | None = None,
) -> int:
"""Count the rows a HogQL query would produce.
Raises:
UnsupportedHogQLQueryError: If the query cannot power a batch export.
"""
- validate_hogql_query_for_batch_export(hogql_query, team, user=user)
+ validate_hogql_query_for_batch_export(hogql_query, team, user=user, modifiers=modifiers)
record_batch_model = HogQLQueryRecordBatchModel(team_id=team.pk, hogql_query=hogql_query, user_id=user.pk)
query_settings = get_user_hogql_batch_export_query_settings()
@@ -272,6 +282,7 @@ def count_rows_for_hogql_batch_export(
user=user,
query_type="HogQLBatchExportCountRowsQuery",
settings=query_settings,
+ modifiers=modifiers,
)
return query_response.results[0][0] if query_response.results else 0
@@ -288,6 +299,7 @@ class FileDownloadBatchExportOnDemandSerializer(serializers.Serializer):
# Only specific to hogql
hogql_query = serializers.CharField(required=False, help_text=HOGQL_QUERY_HELP_TEXT)
+ hogql_modifiers = HogQLModifiersField(required=False, help_text=HOGQL_MODIFIERS_HELP_TEXT)
data_interval_start = serializers.DateTimeField(
default_timezone=dt.UTC, required=False, help_text=DATA_INTERVAL_START_HELP_TEXT
@@ -303,6 +315,9 @@ class FileDownloadBatchExportOnDemandSerializer(serializers.Serializer):
if data.get("hogql_query") is not None:
raise ValidationError("'hogql_query' is only supported when 'model' is 'hogql'")
+ if data.get("hogql_modifiers") is not None:
+ raise ValidationError("'hogql_modifiers' are only supported when 'model' is 'hogql'")
+
validate_file_download_interval(data.get("data_interval_start"), data.get("data_interval_end"))
return data
@@ -323,7 +338,12 @@ class FileDownloadBatchExportOnDemandSerializer(serializers.Serializer):
)
try:
- validate_hogql_query_for_batch_export(hogql_query, team, user=self.context["request"].user)
+ validate_hogql_query_for_batch_export(
+ hogql_query,
+ team,
+ user=self.context["request"].user,
+ modifiers=load_hogql_modifiers(data.get("hogql_modifiers")),
+ )
except UnsupportedHogQLQueryError as e:
raise ValidationError({"hogql_query": str(e)}) from e
@@ -340,7 +360,11 @@ class FileDownloadBatchExportOnDemandSerializer(serializers.Serializer):
source = None
if model == "hogql":
- source = BatchExportSource(team_id=team_id, hogql_query=validated_data.pop("hogql_query"))
+ source = BatchExportSource(
+ team_id=team_id,
+ hogql_query=validated_data.pop("hogql_query"),
+ hogql_modifiers=validated_data.pop("hogql_modifiers", None),
+ )
data_interval_start = validated_data.pop("data_interval_start", None)
data_interval_end = validated_data.pop("data_interval_end", None)
else:
@@ -543,6 +567,7 @@ class FileDownloadBatchExportOnDemandViewSet(
user_id=instance.batch_export_on_demand.last_modified_by_id
if instance.batch_export_on_demand.model == "hogql"
else None,
+ hogql_modifiers=source.hogql_modifiers if source is not None else None,
),
compression=instance.batch_export_on_demand.destination.config.get("compression", None),
format=instance.batch_export_on_demand.destination.config.get("format", "Parquet"),
@@ -731,6 +756,7 @@ class FileDownloadBatchExportOnDemandViewSet(
user=request.user,
data_interval_start=request.validated_data.get("data_interval_start"),
data_interval_end=request.validated_data.get("data_interval_end"),
+ modifiers=load_hogql_modifiers(request.validated_data.get("hogql_modifiers")),
)
except UnsupportedHogQLQueryError as e:
raise ValidationError({"hogql_query": str(e)}) from e
diff --git a/products/batch_exports/backend/api/utils.py b/products/batch_exports/backend/api/utils.py
index 11efd1177e9b..56a8d588a7d0 100644
--- a/products/batch_exports/backend/api/utils.py
+++ b/products/batch_exports/backend/api/utils.py
@@ -1,8 +1,22 @@
+import typing
+
+import pydantic
import posthoganalytics
+from drf_spectacular.utils import extend_schema_field
+from rest_framework import serializers
from rest_framework.exceptions import PermissionDenied
+from posthog.schema import HogQLQueryModifiers
+
from posthog.models import Team
+HOGQL_MODIFIERS_HELP_TEXT = (
+ "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. "
+ "Each modifier set here overrides the project modifier with the same name, and the project "
+ "modifiers apply to all others. For example, set convertToProjectTimezone to false to export "
+ "timestamps in UTC instead of the project timezone."
+)
+
def check_hogql_batch_exports_enabled(team: Team) -> None:
"""Raise if HogQL-powered batch exports are not enabled for the team."""
@@ -19,3 +33,20 @@ def check_hogql_batch_exports_enabled(team: Team) -> None:
send_feature_flag_events=False,
):
raise PermissionDenied("HogQL batch exports are not enabled for this team.")
+
+
+@extend_schema_field(HogQLQueryModifiers) # type: ignore[arg-type]
+class HogQLModifiersField(serializers.JSONField):
+ """HogQL modifiers, validated against `HogQLQueryModifiers` and stored as a plain dict."""
+
+ def to_internal_value(self, data: typing.Any) -> dict[str, typing.Any]:
+ value = super().to_internal_value(data)
+ try:
+ modifiers = HogQLQueryModifiers.model_validate(value)
+ except pydantic.ValidationError as e:
+ messages = []
+ for error in e.errors():
+ location = ".".join(str(part) for part in error["loc"])
+ messages.append(f"{location}: {error['msg']}" if location else error["msg"])
+ raise serializers.ValidationError(messages) from e
+ return modifiers.model_dump(mode="json", exclude_none=True)
diff --git a/products/batch_exports/backend/tests/api/test_create.py b/products/batch_exports/backend/tests/api/test_create.py
index 45e97a6a5adc..bece3c9ede49 100644
--- a/products/batch_exports/backend/tests/api/test_create.py
+++ b/products/batch_exports/backend/tests/api/test_create.py
@@ -603,15 +603,24 @@ def test_create_batch_export_with_hogql_model(
):
client.force_login(user)
other_user = create_user("[email protected]", "Test User", organization)
+ hogql_modifiers = {"convertToProjectTimezone": False}
response = create_batch_export(
- client, team.pk, {**hogql_batch_export_data, "last_modified_by": other_user.pk, "user_id": other_user.pk}
+ client,
+ team.pk,
+ {
+ **hogql_batch_export_data,
+ "hogql_modifiers": hogql_modifiers,
+ "last_modified_by": other_user.pk,
+ "user_id": other_user.pk,
+ },
)
assert response.status_code == status.HTTP_201_CREATED, response.json()
data = response.json()
assert data["model"] == "hogql"
assert data["hogql_query"] == hogql_batch_export_data["hogql_query"]
+ assert data["hogql_modifiers"] == hogql_modifiers
assert data["schema"] is None
batch_export = BatchExport.objects.select_related("source").get(id=data["id"])
@@ -619,6 +628,7 @@ def test_create_batch_export_with_hogql_model(
assert batch_export.source is not None
assert batch_export.source.team_id == team.pk
assert batch_export.source.hogql_query == hogql_batch_export_data["hogql_query"]
+ assert batch_export.source.hogql_modifiers == hogql_modifiers
listed = list_batch_exports_ok(client, team.pk)
assert [export["hogql_query"] for export in listed["results"]] == [hogql_batch_export_data["hogql_query"]]
@@ -632,7 +642,7 @@ def test_create_batch_export_with_hogql_model(
"schema": None,
"hogql_query": hogql_batch_export_data["hogql_query"],
"user_id": user.pk,
- "hogql_modifiers": None,
+ "hogql_modifiers": hogql_modifiers,
}
@@ -706,6 +716,16 @@ def test_create_batch_export_with_hogql_model_allows_query_without_placeholders(
"filters",
"'filters' are not supported when 'model' is 'hogql'",
),
+ (
+ {"hogql_modifiers": {"notAModifier": True}},
+ "hogql_modifiers",
+ "notAModifier: Extra inputs are not permitted",
+ ),
+ (
+ {"model": "events", "hogql_modifiers": {"convertToProjectTimezone": False}},
+ "hogql_modifiers",
+ "'hogql_modifiers' are only supported when 'model' is 'hogql'",
+ ),
],
ids=[
"unknown-placeholder",
@@ -713,6 +733,8 @@ def test_create_batch_export_with_hogql_model_allows_query_without_placeholders(
"missing-hogql-query",
"unaliased-column",
"filters",
+ "unknown-modifier",
+ "modifiers-with-events-model",
],
)
@pytest.mark.usefixtures("hogql_batch_exports_enabled")
diff --git a/products/batch_exports/backend/tests/api/test_update.py b/products/batch_exports/backend/tests/api/test_update.py
index 6134130776bd..ed2a1cd9fd5b 100644
--- a/products/batch_exports/backend/tests/api/test_update.py
+++ b/products/batch_exports/backend/tests/api/test_update.py
@@ -846,6 +846,22 @@ def test_patch_hogql_model_batch_export(
"hogql_modifiers": None,
}
+ # Modifiers can change without the query, and null removes them.
+ for hogql_modifiers in ({"convertToProjectTimezone": False}, None):
+ response = patch_batch_export(client, team.pk, batch_export["id"], {"hogql_modifiers": hogql_modifiers})
+ assert response.status_code == status.HTTP_200_OK, response.json()
+
+ updated = get_batch_export_ok(client, team.pk, batch_export["id"])
+ assert updated["hogql_query"] == new_hogql_query
+ assert updated["hogql_modifiers"] == hogql_modifiers
+ assert BatchExport.objects.get(id=batch_export["id"]).source_id == source_id
+
+ schedule = describe_schedule(temporal, batch_export["id"])
+ decoded_payload = async_to_sync(encryption_codec.decode)(schedule.schedule.action.args)
+ args = json.loads(decoded_payload[0].data)
+ assert args["batch_export_model"]["hogql_query"] == new_hogql_query
+ assert args["batch_export_model"]["hogql_modifiers"] == hogql_modifiers
+
@pytest.mark.usefixtures("hogql_batch_exports_enabled")
@pytest.mark.parametrize("access_level,include_query", [("viewer", False), ("none", False), ("none", True)])
diff --git a/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py b/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py
index ac04b0d7cb51..74afa6a67538 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py
@@ -741,6 +741,11 @@ class TestFileDownloadHogQL:
"'data_interval_start' and 'data_interval_end' are required",
id="events-model-missing-intervals",
),
+ pytest.param(
+ {"model": "events", "hogql_query": None, "hogql_modifiers": {"convertToProjectTimezone": False}},
+ "'hogql_modifiers' are only supported when 'model' is 'hogql'",
+ id="modifiers-with-events-model",
+ ),
],
)
@pytest.mark.usefixtures("enable_hogql_flag")
@@ -817,6 +822,7 @@ class TestFileDownloadHogQL:
"file": {"format": "Parquet"},
"model": "hogql",
"hogql_query": hogql_query,
+ "hogql_modifiers": {"convertToProjectTimezone": False},
"last_modified_by": user.pk + 1,
"last_modified_by_id": user.pk + 1,
"user_id": user.pk + 1,
@@ -842,6 +848,7 @@ class TestFileDownloadHogQL:
assert on_demand.last_modified_by_id == user.pk
assert on_demand.source is not None
assert on_demand.source.hogql_query == hogql_query
+ assert on_demand.source.hogql_modifiers == {"convertToProjectTimezone": False}
assert on_demand.source.team_id == team.pk
assert "include_events" not in on_demand.destination.config
@@ -850,6 +857,7 @@ class TestFileDownloadHogQL:
assert batch_export_model.name == "hogql"
assert batch_export_model.hogql_query == hogql_query
assert batch_export_model.user_id == user.pk
+ assert batch_export_model.hogql_modifiers == {"convertToProjectTimezone": False}
assert mock_start_file_download_export.call_args.kwargs["max_size_mb"] == DEFAULT_MAX_SIZE_MB
assert mock_start_file_download_export.call_args.kwargs["data_interval_start"] == run.data_interval_start
assert mock_start_file_download_export.call_args.kwargs["data_interval_end"] == run.data_interval_end
@@ -1112,6 +1120,15 @@ class TestFileDownloadHogQL:
"'data_interval_end' is required",
id="missing-placeholder-bounds",
),
+ pytest.param(
+ {
+ "model": "hogql",
+ "hogql_query": "SELECT event AS event FROM events",
+ "hogql_modifiers": {"notAModifier": True},
+ },
+ "Extra inputs are not permitted",
+ id="unknown-modifier",
+ ),
],
)
@pytest.mark.usefixtures("enable_hogql_flag")
diff --git a/products/batch_exports/frontend/generated/api.schemas.ts b/products/batch_exports/frontend/generated/api.schemas.ts
index 7c07dda6a429..31bf195e78d8 100644
--- a/products/batch_exports/frontend/generated/api.schemas.ts
+++ b/products/batch_exports/frontend/generated/api.schemas.ts
@@ -619,6 +619,256 @@ export interface BatchExportRunApi {
backfill?: string | null
}
+export type BounceRatePageViewModeApi = (typeof BounceRatePageViewModeApi)[keyof typeof BounceRatePageViewModeApi]
+
+export const BounceRatePageViewModeApi = {
+ CountPageviews: 'count_pageviews',
+ UniqUrls: 'uniq_urls',
+ UniqPageScreenAutocaptures: 'uniq_page_screen_autocaptures',
+} as const
+
+export type FilterLogicalOperatorApi = (typeof FilterLogicalOperatorApi)[keyof typeof FilterLogicalOperatorApi]
+
+export const FilterLogicalOperatorApi = {
+ And: 'AND',
+ Or: 'OR',
+} as const
+
+export type CustomBotFieldApi = (typeof CustomBotFieldApi)[keyof typeof CustomBotFieldApi]
+
+export const CustomBotFieldApi = {
+ RawUserAgent: '$raw_user_agent',
+ Ip: '$ip',
+ Lib: '$lib',
+ Host: '$host',
+ Pathname: '$pathname',
+ CurrentUrl: '$current_url',
+ Browser: '$browser',
+ Os: '$os',
+ BrowserLanguage: '$browser_language',
+ ScreenWidth: '$screen_width',
+ ScreenHeight: '$screen_height',
+ GeoipCountryCode: '$geoip_country_code',
+ Referrer: '$referrer',
+ ReferringDomain: '$referring_domain',
+} as const
+
+export type CustomBotMatcherApi = (typeof CustomBotMatcherApi)[keyof typeof CustomBotMatcherApi]
+
+export const CustomBotMatcherApi = {
+ Contains: 'contains',
+ Regex: 'regex',
+ Exact: 'exact',
+ Cidr: 'cidr',
+} as const
+
+export interface CustomBotConditionApi {
+ id: string
+ /** The event property this condition reads. */
+ key: CustomBotFieldApi
+ matcher: CustomBotMatcherApi
+ /** Matched against the property named by `key`. */
+ pattern: string
+}
+
+export interface CustomBotRuleApi {
+ /** Reported by `$virt_traffic_category`. Defaults to `custom`. */
+ category?: string | null
+ /** Whether every condition must match (AND) or any one of them (OR). */
+ combiner: FilterLogicalOperatorApi
+ id: string
+ items: CustomBotConditionApi[]
+ /** Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches. */
+ name: string
+}
+
+export type CustomChannelFieldApi = (typeof CustomChannelFieldApi)[keyof typeof CustomChannelFieldApi]
+
+export const CustomChannelFieldApi = {
+ UtmSource: 'utm_source',
+ UtmMedium: 'utm_medium',
+ UtmCampaign: 'utm_campaign',
+ ReferringDomain: 'referring_domain',
+ Url: 'url',
+ Pathname: 'pathname',
+ Hostname: 'hostname',
+} as const
+
+export type CustomChannelOperatorApi = (typeof CustomChannelOperatorApi)[keyof typeof CustomChannelOperatorApi]
+
+export const CustomChannelOperatorApi = {
+ Exact: 'exact',
+ IsNot: 'is_not',
+ IsSet: 'is_set',
+ IsNotSet: 'is_not_set',
+ Icontains: 'icontains',
+ NotIcontains: 'not_icontains',
+ Regex: 'regex',
+ NotRegex: 'not_regex',
+} as const
+
+export interface CustomChannelConditionApi {
+ id: string
+ key: CustomChannelFieldApi
+ op: CustomChannelOperatorApi
+ value?: string | string[] | null
+}
+
+export interface CustomChannelRuleApi {
+ channel_type: string
+ combiner: FilterLogicalOperatorApi
+ id: string
+ items: CustomChannelConditionApi[]
+}
+
+export interface DataWarehouseEventsModifierApi {
+ distinct_id_field: string
+ id_field: string
+ table_name: string
+ timestamp_field: string
+}
+
+export type InCohortViaApi = (typeof InCohortViaApi)[keyof typeof InCohortViaApi]
+
+export const InCohortViaApi = {
+ Auto: 'auto',
+ Leftjoin: 'leftjoin',
+ Subquery: 'subquery',
+ LeftjoinConjoined: 'leftjoin_conjoined',
+} as const
+
+export type InlineCohortCalculationApi = (typeof InlineCohortCalculationApi)[keyof typeof InlineCohortCalculationApi]
+
+export const InlineCohortCalculationApi = {
+ Off: 'off',
+ Auto: 'auto',
+ Always: 'always',
+} as const
+
+export type MaterializationModeApi = (typeof MaterializationModeApi)[keyof typeof MaterializationModeApi]
+
+export const MaterializationModeApi = {
+ Auto: 'auto',
+ LegacyNullAsString: 'legacy_null_as_string',
+ LegacyNullAsNull: 'legacy_null_as_null',
+ Disabled: 'disabled',
+} as const
+
+export type MaterializedColumnsOptimizationModeApi =
+ (typeof MaterializedColumnsOptimizationModeApi)[keyof typeof MaterializedColumnsOptimizationModeApi]
+
+export const MaterializedColumnsOptimizationModeApi = {
+ Disabled: 'disabled',
+ Optimized: 'optimized',
+} as const
+
+export type ParserModeApi = (typeof ParserModeApi)[keyof typeof ParserModeApi]
+
+export const ParserModeApi = {
+ CppOnly: 'cpp_only',
+ CppWithRustShadow: 'cpp_with_rust_shadow',
+ CppWithRustPyShadow: 'cpp_with_rust_py_shadow',
+ RustWithCppShadow: 'rust_with_cpp_shadow',
+ RustOnly: 'rust_only',
+ RustPyOnly: 'rust_py_only',
+ RustPyWithCppShadow: 'rust_py_with_cpp_shadow',
+} as const
+
+export type PersonsArgMaxVersionApi = (typeof PersonsArgMaxVersionApi)[keyof typeof PersonsArgMaxVersionApi]
+
+export const PersonsArgMaxVersionApi = {
+ Auto: 'auto',
+ V1: 'v1',
+ V2: 'v2',
+} as const
+
+export type PersonsJoinModeApi = (typeof PersonsJoinModeApi)[keyof typeof PersonsJoinModeApi]
+
+export const PersonsJoinModeApi = {
+ Inner: 'inner',
+ Left: 'left',
+} as const
+
+export type PersonsOnEventsModeApi = (typeof PersonsOnEventsModeApi)[keyof typeof PersonsOnEventsModeApi]
+
+export const PersonsOnEventsModeApi = {
+ Disabled: 'disabled',
+ PersonIdNoOverridePropertiesOnEvents: 'person_id_no_override_properties_on_events',
+ PersonIdOverridePropertiesOnEvents: 'person_id_override_properties_on_events',
+ PersonIdOverridePropertiesJoined: 'person_id_override_properties_joined',
+} as const
+
+export type PropertyGroupsModeApi = (typeof PropertyGroupsModeApi)[keyof typeof PropertyGroupsModeApi]
+
+export const PropertyGroupsModeApi = {
+ Enabled: 'enabled',
+ Disabled: 'disabled',
+ Optimized: 'optimized',
+} as const
+
+export type SessionTableVersionApi = (typeof SessionTableVersionApi)[keyof typeof SessionTableVersionApi]
+
+export const SessionTableVersionApi = {
+ Auto: 'auto',
+ V1: 'v1',
+ V2: 'v2',
+ V3: 'v3',
+} as const
+
+export type SessionsV2JoinModeApi = (typeof SessionsV2JoinModeApi)[keyof typeof SessionsV2JoinModeApi]
+
+export const SessionsV2JoinModeApi = {
+ String: 'string',
+ Uuid: 'uuid',
+} as const
+
+export interface HogQLQueryModifiersApi {
+ bounceRateDurationSeconds?: number | null
+ bounceRatePageViewMode?: BounceRatePageViewModeApi | null
+ convertToProjectTimezone?: boolean | null
+ /** Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients. */
+ cookielessTrafficIsRegular?: boolean | null
+ customBotDefinitions?: CustomBotRuleApi[] | null
+ customChannelTypeRules?: CustomChannelRuleApi[] | null
+ dataWarehouseEventsModifiers?: DataWarehouseEventsModifierApi[] | null
+ debug?: boolean | null
+ /** If these are provided, the query will fail if these skip indexes are not used */
+ forceClickhouseDataSkippingIndexes?: string[] | null
+ formatCsvAllowDoubleQuotes?: boolean | null
+ inCohortVia?: InCohortViaApi | null
+ inlineCohortCalculation?: InlineCohortCalculationApi | null
+ materializationMode?: MaterializationModeApi | null
+ materializedColumnsOptimizationMode?: MaterializedColumnsOptimizationModeApi | null
+ /** Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap */
+ mergeFederatedAggregateJoins?: boolean | null
+ optimizeJoinedFilters?: boolean | null
+ optimizeProjections?: boolean | null
+ /** 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
+ personsOnEventsMode?: PersonsOnEventsModeApi | null
+ propertyGroupsMode?: PropertyGroupsModeApi | null
+ pushDownPredicates?: boolean | null
+ s3TableUseInvalidColumns?: boolean | null
+ /** Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter. */
+ sessionIdPushdown?: boolean | null
+ /** Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`). */
+ sessionPropertyPreAggregation?: boolean | null
+ sessionTableVersion?: SessionTableVersionApi | null
+ sessionsV2JoinMode?: SessionsV2JoinModeApi | null
+ timings?: boolean | null
+ /** Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types */
+ typeAwareCastSimplification?: boolean | null
+ useMaterializedViews?: boolean | null
+ usePreaggregatedIntermediateResults?: boolean | null
+ /** Try to automatically convert HogQL queries to use preaggregated tables at the AST level * */
+ usePreaggregatedTableTransforms?: boolean | null
+ useWebAnalyticsPreAggregatedTables?: boolean | null
+ /** Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients. */
+ webAnalyticsFirstPageviewFilters?: boolean | null
+}
+
/**
* Serializer for a BatchExport model.
*/
@@ -673,6 +923,8 @@ export interface BatchExportApi {
* @nullable
*/
hogql_query?: string | null
+ /** HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone. */
+ hogql_modifiers?: HogQLQueryModifiersApi | null
/** A schema of custom fields to select when exporting data. */
readonly schema: unknown
filters?: unknown
@@ -1480,6 +1732,8 @@ export interface BatchExportRequestApi {
* @nullable
*/
hogql_query?: string | null
+ /** HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone. */
+ hogql_modifiers?: HogQLQueryModifiersApi | null
/** Optional list of property filters to restrict which events are exported. Each filter is a serialized HogQL property filter object with a 'type' of one of: 'event', 'hogql', 'person' (e.g. {"key": "$browser", "operator": "exact", "type": "event", "value": ["Firefox"]}). */
filters?: unknown
/**
@@ -1644,6 +1898,8 @@ export interface PatchedBatchExportRequestApi {
* @nullable
*/
hogql_query?: string | null
+ /** HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone. */
+ hogql_modifiers?: HogQLQueryModifiersApi | null
/** Optional list of property filters to restrict which events are exported. Each filter is a serialized HogQL property filter object with a 'type' of one of: 'event', 'hogql', 'person' (e.g. {"key": "$browser", "operator": "exact", "type": "event", "value": ["Firefox"]}). */
filters?: unknown
/**
@@ -1795,6 +2051,8 @@ export interface FileDownloadHogQLRequestApi {
model: FileDownloadHogQLRequestApiModel
/** HogQL SELECT query whose results are exported. This model is in closed beta and is enabled per team; when it is not enabled, the request fails with a permission error that names HogQL batch exports. Contact PostHog support to request access. The query may reference the {data_interval_start} and {data_interval_end} placeholders. Provide a value for each placeholder the query references; missing referenced bounds are rejected, not inferred. When both bounds are supplied, they must span at most seven days. Neither supplied bound may be in the future. Without placeholders, the query runs unchanged, even if bounds are supplied. Every column in the SELECT clause must be a field or have an alias. It is recommended to limit the query with a WHERE clause, for example bounding timestamp on the events table, both to avoid exporting more rows than expected and because user queries run under stricter resource limits than the other models. */
hogql_query: string
+ /** HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone. */
+ hogql_modifiers?: HogQLQueryModifiersApi
/** Start of the export interval. Required for the events, persons, and sessions models. For HogQL, required only when the query references {data_interval_start}. A supplied start must not be in the future. When both bounds are supplied, the interval must span at most seven days. */
data_interval_start?: string
/** End of the export interval. Required for the events, persons, and sessions models. For HogQL, required only when the query references {data_interval_end}. A supplied end must not be in the future or precede a supplied start. Bounds replace HogQL placeholders; they do not add filters to the query. */
@@ -1894,6 +2152,8 @@ export interface FileDownloadCountRowsRequestApi {
model: FileDownloadHogQLModelEnumApi
/** HogQL SELECT query whose results are exported. This model is in closed beta and is enabled per team; when it is not enabled, the request fails with a permission error that names HogQL batch exports. Contact PostHog support to request access. The query may reference the {data_interval_start} and {data_interval_end} placeholders. Provide a value for each placeholder the query references; missing referenced bounds are rejected, not inferred. When both bounds are supplied, they must span at most seven days. Neither supplied bound may be in the future. Without placeholders, the query runs unchanged, even if bounds are supplied. Every column in the SELECT clause must be a field or have an alias. It is recommended to limit the query with a WHERE clause, for example bounding timestamp on the events table, both to avoid exporting more rows than expected and because user queries run under stricter resource limits than the other models. */
hogql_query: string
+ /** HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone. */
+ hogql_modifiers?: HogQLQueryModifiersApi
/** Start of the export interval. Required for the events, persons, and sessions models. For HogQL, required only when the query references {data_interval_start}. A supplied start must not be in the future. When both bounds are supplied, the interval must span at most seven days. */
data_interval_start?: string
/** End of the export interval. Required for the events, persons, and sessions models. For HogQL, required only when the query references {data_interval_end}. A supplied end must not be in the future or precede a supplied start. Bounds replace HogQL placeholders; they do not add filters to the query. */
diff --git a/products/batch_exports/frontend/generated/api.zod.ts b/products/batch_exports/frontend/generated/api.zod.ts
index 22ed1c98c70c..c9da39d47ac0 100644
--- a/products/batch_exports/frontend/generated/api.zod.ts
+++ b/products/batch_exports/frontend/generated/api.zod.ts
@@ -449,6 +449,229 @@ export const BatchExportsCreateBody = /* @__PURE__ */ zod
.describe(
"HogQL SELECT query. With model 'hogql', its results are the data exported by every run. The query may reference the {data_interval_start} and {data_interval_end} placeholders, replaced with each run's data interval bounds, for example: WHERE timestamp >= {data_interval_start} AND timestamp < {data_interval_end}. Without them every run exports all rows the query returns. With model 'events', it defines a custom schema of columns to export instead. Required when model is 'hogql'."
),
+ hogql_modifiers: zod
+ .union([
+ zod.object({
+ bounceRateDurationSeconds: zod.union([zod.number(), zod.null()]).optional(),
+ bounceRatePageViewMode: zod
+ .union([
+ zod.enum(['count_pageviews', 'uniq_urls', 'uniq_page_screen_autocaptures']),
+ zod.null(),
+ ])
+ .optional(),
+ convertToProjectTimezone: zod.union([zod.boolean(), zod.null()]).optional(),
+ cookielessTrafficIsRegular: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients.'
+ ),
+ customBotDefinitions: zod
+ .union([
+ zod.array(
+ zod.object({
+ category: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe('Reported by `$virt_traffic_category`. Defaults to `custom`.'),
+ combiner: zod
+ .enum(['AND', 'OR'])
+ .describe('Whether every condition must match (AND) or any one of them (OR).'),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod
+ .enum([
+ '$raw_user_agent',
+ '$ip',
+ '$lib',
+ '$host',
+ '$pathname',
+ '$current_url',
+ '$browser',
+ '$os',
+ '$browser_language',
+ '$screen_width',
+ '$screen_height',
+ '$geoip_country_code',
+ '$referrer',
+ '$referring_domain',
+ ])
+ .describe('The event property this condition reads.'),
+ matcher: zod.enum(['contains', 'regex', 'exact', 'cidr']),
+ pattern: zod
+ .string()
+ .describe('Matched against the property named by `key`.'),
+ })
+ ),
+ name: zod
+ .string()
+ .describe(
+ 'Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.'
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ customChannelTypeRules: zod
+ .union([
+ zod.array(
+ zod.object({
+ channel_type: zod.string(),
+ combiner: zod.enum(['AND', 'OR']),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod.enum([
+ 'utm_source',
+ 'utm_medium',
+ 'utm_campaign',
+ 'referring_domain',
+ 'url',
+ 'pathname',
+ 'hostname',
+ ]),
+ op: zod.enum([
+ 'exact',
+ 'is_not',
+ 'is_set',
+ 'is_not_set',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ dataWarehouseEventsModifiers: zod
+ .union([
+ zod.array(
+ zod.object({
+ distinct_id_field: zod.string(),
+ id_field: zod.string(),
+ table_name: zod.string(),
+ timestamp_field: zod.string(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ debug: zod.union([zod.boolean(), zod.null()]).optional(),
+ forceClickhouseDataSkippingIndexes: zod
+ .union([zod.array(zod.string()), zod.null()])
+ .optional()
+ .describe('If these are provided, the query will fail if these skip indexes are not used'),
+ formatCsvAllowDoubleQuotes: zod.union([zod.boolean(), zod.null()]).optional(),
+ inCohortVia: zod
+ .union([zod.enum(['auto', 'leftjoin', 'subquery', 'leftjoin_conjoined']), zod.null()])
+ .optional(),
+ inlineCohortCalculation: zod.union([zod.enum(['off', 'auto', 'always']), zod.null()]).optional(),
+ materializationMode: zod
+ .union([
+ zod.enum(['auto', 'legacy_null_as_string', 'legacy_null_as_null', 'disabled']),
+ zod.null(),
+ ])
+ .optional(),
+ materializedColumnsOptimizationMode: zod
+ .union([zod.enum(['disabled', 'optimized']), zod.null()])
+ .optional(),
+ mergeFederatedAggregateJoins: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap'
+ ),
+ optimizeJoinedFilters: zod.union([zod.boolean(), zod.null()]).optional(),
+ optimizeProjections: zod.union([zod.boolean(), zod.null()]).optional(),
+ parserMode: zod
+ .union([
+ zod.enum([
+ 'cpp_only',
+ 'cpp_with_rust_shadow',
+ 'cpp_with_rust_py_shadow',
+ 'rust_with_cpp_shadow',
+ 'rust_only',
+ 'rust_py_only',
+ 'rust_py_with_cpp_shadow',
+ ]),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ '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.'
+ ),
+ personsArgMaxVersion: zod.union([zod.enum(['auto', 'v1', 'v2']), zod.null()]).optional(),
+ personsJoinMode: zod.union([zod.enum(['inner', 'left']), zod.null()]).optional(),
+ personsOnEventsMode: zod
+ .union([
+ zod.enum([
+ 'disabled',
+ 'person_id_no_override_properties_on_events',
+ 'person_id_override_properties_on_events',
+ 'person_id_override_properties_joined',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ propertyGroupsMode: zod
+ .union([zod.enum(['enabled', 'disabled', 'optimized']), zod.null()])
+ .optional(),
+ pushDownPredicates: zod.union([zod.boolean(), zod.null()]).optional(),
+ s3TableUseInvalidColumns: zod.union([zod.boolean(), zod.null()]).optional(),
+ sessionIdPushdown: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter.'
+ ),
+ sessionPropertyPreAggregation: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown\/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`).'
+ ),
+ sessionTableVersion: zod.union([zod.enum(['auto', 'v1', 'v2', 'v3']), zod.null()]).optional(),
+ sessionsV2JoinMode: zod.union([zod.enum(['string', 'uuid']), zod.null()]).optional(),
+ timings: zod.union([zod.boolean(), zod.null()]).optional(),
+ typeAwareCastSimplification: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types'
+ ),
+ useMaterializedViews: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedIntermediateResults: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedTableTransforms: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Try to automatically convert HogQL queries to use preaggregated tables at the AST level \*'
+ ),
+ useWebAnalyticsPreAggregatedTables: zod.union([zod.boolean(), zod.null()]).optional(),
+ webAnalyticsFirstPageviewFilters: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_\*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ ),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone."
+ ),
filters: zod
.unknown()
.optional()
@@ -1165,6 +1388,229 @@ export const BatchExportsUpdateBody = /* @__PURE__ */ zod
.describe(
"HogQL SELECT query. With model 'hogql', its results are the data exported by every run. The query may reference the {data_interval_start} and {data_interval_end} placeholders, replaced with each run's data interval bounds, for example: WHERE timestamp >= {data_interval_start} AND timestamp < {data_interval_end}. Without them every run exports all rows the query returns. With model 'events', it defines a custom schema of columns to export instead. Required when model is 'hogql'."
),
+ hogql_modifiers: zod
+ .union([
+ zod.object({
+ bounceRateDurationSeconds: zod.union([zod.number(), zod.null()]).optional(),
+ bounceRatePageViewMode: zod
+ .union([
+ zod.enum(['count_pageviews', 'uniq_urls', 'uniq_page_screen_autocaptures']),
+ zod.null(),
+ ])
+ .optional(),
+ convertToProjectTimezone: zod.union([zod.boolean(), zod.null()]).optional(),
+ cookielessTrafficIsRegular: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients.'
+ ),
+ customBotDefinitions: zod
+ .union([
+ zod.array(
+ zod.object({
+ category: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe('Reported by `$virt_traffic_category`. Defaults to `custom`.'),
+ combiner: zod
+ .enum(['AND', 'OR'])
+ .describe('Whether every condition must match (AND) or any one of them (OR).'),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod
+ .enum([
+ '$raw_user_agent',
+ '$ip',
+ '$lib',
+ '$host',
+ '$pathname',
+ '$current_url',
+ '$browser',
+ '$os',
+ '$browser_language',
+ '$screen_width',
+ '$screen_height',
+ '$geoip_country_code',
+ '$referrer',
+ '$referring_domain',
+ ])
+ .describe('The event property this condition reads.'),
+ matcher: zod.enum(['contains', 'regex', 'exact', 'cidr']),
+ pattern: zod
+ .string()
+ .describe('Matched against the property named by `key`.'),
+ })
+ ),
+ name: zod
+ .string()
+ .describe(
+ 'Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.'
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ customChannelTypeRules: zod
+ .union([
+ zod.array(
+ zod.object({
+ channel_type: zod.string(),
+ combiner: zod.enum(['AND', 'OR']),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod.enum([
+ 'utm_source',
+ 'utm_medium',
+ 'utm_campaign',
+ 'referring_domain',
+ 'url',
+ 'pathname',
+ 'hostname',
+ ]),
+ op: zod.enum([
+ 'exact',
+ 'is_not',
+ 'is_set',
+ 'is_not_set',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ dataWarehouseEventsModifiers: zod
+ .union([
+ zod.array(
+ zod.object({
+ distinct_id_field: zod.string(),
+ id_field: zod.string(),
+ table_name: zod.string(),
+ timestamp_field: zod.string(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ debug: zod.union([zod.boolean(), zod.null()]).optional(),
+ forceClickhouseDataSkippingIndexes: zod
+ .union([zod.array(zod.string()), zod.null()])
+ .optional()
+ .describe('If these are provided, the query will fail if these skip indexes are not used'),
+ formatCsvAllowDoubleQuotes: zod.union([zod.boolean(), zod.null()]).optional(),
+ inCohortVia: zod
+ .union([zod.enum(['auto', 'leftjoin', 'subquery', 'leftjoin_conjoined']), zod.null()])
+ .optional(),
+ inlineCohortCalculation: zod.union([zod.enum(['off', 'auto', 'always']), zod.null()]).optional(),
+ materializationMode: zod
+ .union([
+ zod.enum(['auto', 'legacy_null_as_string', 'legacy_null_as_null', 'disabled']),
+ zod.null(),
+ ])
+ .optional(),
+ materializedColumnsOptimizationMode: zod
+ .union([zod.enum(['disabled', 'optimized']), zod.null()])
+ .optional(),
+ mergeFederatedAggregateJoins: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap'
+ ),
+ optimizeJoinedFilters: zod.union([zod.boolean(), zod.null()]).optional(),
+ optimizeProjections: zod.union([zod.boolean(), zod.null()]).optional(),
+ parserMode: zod
+ .union([
+ zod.enum([
+ 'cpp_only',
+ 'cpp_with_rust_shadow',
+ 'cpp_with_rust_py_shadow',
+ 'rust_with_cpp_shadow',
+ 'rust_only',
+ 'rust_py_only',
+ 'rust_py_with_cpp_shadow',
+ ]),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ '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.'
+ ),
+ personsArgMaxVersion: zod.union([zod.enum(['auto', 'v1', 'v2']), zod.null()]).optional(),
+ personsJoinMode: zod.union([zod.enum(['inner', 'left']), zod.null()]).optional(),
+ personsOnEventsMode: zod
+ .union([
+ zod.enum([
+ 'disabled',
+ 'person_id_no_override_properties_on_events',
+ 'person_id_override_properties_on_events',
+ 'person_id_override_properties_joined',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ propertyGroupsMode: zod
+ .union([zod.enum(['enabled', 'disabled', 'optimized']), zod.null()])
+ .optional(),
+ pushDownPredicates: zod.union([zod.boolean(), zod.null()]).optional(),
+ s3TableUseInvalidColumns: zod.union([zod.boolean(), zod.null()]).optional(),
+ sessionIdPushdown: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter.'
+ ),
+ sessionPropertyPreAggregation: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown\/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`).'
+ ),
+ sessionTableVersion: zod.union([zod.enum(['auto', 'v1', 'v2', 'v3']), zod.null()]).optional(),
+ sessionsV2JoinMode: zod.union([zod.enum(['string', 'uuid']), zod.null()]).optional(),
+ timings: zod.union([zod.boolean(), zod.null()]).optional(),
+ typeAwareCastSimplification: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types'
+ ),
+ useMaterializedViews: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedIntermediateResults: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedTableTransforms: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Try to automatically convert HogQL queries to use preaggregated tables at the AST level \*'
+ ),
+ useWebAnalyticsPreAggregatedTables: zod.union([zod.boolean(), zod.null()]).optional(),
+ webAnalyticsFirstPageviewFilters: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_\*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ ),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone."
+ ),
filters: zod
.unknown()
.optional()
@@ -1640,6 +2086,229 @@ export const BatchExportsPartialUpdateBody = /* @__PURE__ */ zod
.describe(
"HogQL SELECT query. With model 'hogql', its results are the data exported by every run. The query may reference the {data_interval_start} and {data_interval_end} placeholders, replaced with each run's data interval bounds, for example: WHERE timestamp >= {data_interval_start} AND timestamp < {data_interval_end}. Without them every run exports all rows the query returns. With model 'events', it defines a custom schema of columns to export instead. Required when model is 'hogql'."
),
+ hogql_modifiers: zod
+ .union([
+ zod.object({
+ bounceRateDurationSeconds: zod.union([zod.number(), zod.null()]).optional(),
+ bounceRatePageViewMode: zod
+ .union([
+ zod.enum(['count_pageviews', 'uniq_urls', 'uniq_page_screen_autocaptures']),
+ zod.null(),
+ ])
+ .optional(),
+ convertToProjectTimezone: zod.union([zod.boolean(), zod.null()]).optional(),
+ cookielessTrafficIsRegular: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients.'
+ ),
+ customBotDefinitions: zod
+ .union([
+ zod.array(
+ zod.object({
+ category: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe('Reported by `$virt_traffic_category`. Defaults to `custom`.'),
+ combiner: zod
+ .enum(['AND', 'OR'])
+ .describe('Whether every condition must match (AND) or any one of them (OR).'),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod
+ .enum([
+ '$raw_user_agent',
+ '$ip',
+ '$lib',
+ '$host',
+ '$pathname',
+ '$current_url',
+ '$browser',
+ '$os',
+ '$browser_language',
+ '$screen_width',
+ '$screen_height',
+ '$geoip_country_code',
+ '$referrer',
+ '$referring_domain',
+ ])
+ .describe('The event property this condition reads.'),
+ matcher: zod.enum(['contains', 'regex', 'exact', 'cidr']),
+ pattern: zod
+ .string()
+ .describe('Matched against the property named by `key`.'),
+ })
+ ),
+ name: zod
+ .string()
+ .describe(
+ 'Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.'
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ customChannelTypeRules: zod
+ .union([
+ zod.array(
+ zod.object({
+ channel_type: zod.string(),
+ combiner: zod.enum(['AND', 'OR']),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod.enum([
+ 'utm_source',
+ 'utm_medium',
+ 'utm_campaign',
+ 'referring_domain',
+ 'url',
+ 'pathname',
+ 'hostname',
+ ]),
+ op: zod.enum([
+ 'exact',
+ 'is_not',
+ 'is_set',
+ 'is_not_set',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ dataWarehouseEventsModifiers: zod
+ .union([
+ zod.array(
+ zod.object({
+ distinct_id_field: zod.string(),
+ id_field: zod.string(),
+ table_name: zod.string(),
+ timestamp_field: zod.string(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ debug: zod.union([zod.boolean(), zod.null()]).optional(),
+ forceClickhouseDataSkippingIndexes: zod
+ .union([zod.array(zod.string()), zod.null()])
+ .optional()
+ .describe('If these are provided, the query will fail if these skip indexes are not used'),
+ formatCsvAllowDoubleQuotes: zod.union([zod.boolean(), zod.null()]).optional(),
+ inCohortVia: zod
+ .union([zod.enum(['auto', 'leftjoin', 'subquery', 'leftjoin_conjoined']), zod.null()])
+ .optional(),
+ inlineCohortCalculation: zod.union([zod.enum(['off', 'auto', 'always']), zod.null()]).optional(),
+ materializationMode: zod
+ .union([
+ zod.enum(['auto', 'legacy_null_as_string', 'legacy_null_as_null', 'disabled']),
+ zod.null(),
+ ])
+ .optional(),
+ materializedColumnsOptimizationMode: zod
+ .union([zod.enum(['disabled', 'optimized']), zod.null()])
+ .optional(),
+ mergeFederatedAggregateJoins: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap'
+ ),
+ optimizeJoinedFilters: zod.union([zod.boolean(), zod.null()]).optional(),
+ optimizeProjections: zod.union([zod.boolean(), zod.null()]).optional(),
+ parserMode: zod
+ .union([
+ zod.enum([
+ 'cpp_only',
+ 'cpp_with_rust_shadow',
+ 'cpp_with_rust_py_shadow',
+ 'rust_with_cpp_shadow',
+ 'rust_only',
+ 'rust_py_only',
+ 'rust_py_with_cpp_shadow',
+ ]),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ '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.'
+ ),
+ personsArgMaxVersion: zod.union([zod.enum(['auto', 'v1', 'v2']), zod.null()]).optional(),
+ personsJoinMode: zod.union([zod.enum(['inner', 'left']), zod.null()]).optional(),
+ personsOnEventsMode: zod
+ .union([
+ zod.enum([
+ 'disabled',
+ 'person_id_no_override_properties_on_events',
+ 'person_id_override_properties_on_events',
+ 'person_id_override_properties_joined',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ propertyGroupsMode: zod
+ .union([zod.enum(['enabled', 'disabled', 'optimized']), zod.null()])
+ .optional(),
+ pushDownPredicates: zod.union([zod.boolean(), zod.null()]).optional(),
+ s3TableUseInvalidColumns: zod.union([zod.boolean(), zod.null()]).optional(),
+ sessionIdPushdown: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter.'
+ ),
+ sessionPropertyPreAggregation: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown\/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`).'
+ ),
+ sessionTableVersion: zod.union([zod.enum(['auto', 'v1', 'v2', 'v3']), zod.null()]).optional(),
+ sessionsV2JoinMode: zod.union([zod.enum(['string', 'uuid']), zod.null()]).optional(),
+ timings: zod.union([zod.boolean(), zod.null()]).optional(),
+ typeAwareCastSimplification: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types'
+ ),
+ useMaterializedViews: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedIntermediateResults: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedTableTransforms: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Try to automatically convert HogQL queries to use preaggregated tables at the AST level \*'
+ ),
+ useWebAnalyticsPreAggregatedTables: zod.union([zod.boolean(), zod.null()]).optional(),
+ webAnalyticsFirstPageviewFilters: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_\*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ ),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone."
+ ),
filters: zod
.unknown()
.optional()
@@ -2107,6 +2776,229 @@ export const BatchExportsRunTestStepCreateBody = /* @__PURE__ */ zod
.describe(
"HogQL SELECT query. With model 'hogql', its results are the data exported by every run. The query may reference the {data_interval_start} and {data_interval_end} placeholders, replaced with each run's data interval bounds, for example: WHERE timestamp >= {data_interval_start} AND timestamp < {data_interval_end}. Without them every run exports all rows the query returns. With model 'events', it defines a custom schema of columns to export instead. Required when model is 'hogql'."
),
+ hogql_modifiers: zod
+ .union([
+ zod.object({
+ bounceRateDurationSeconds: zod.union([zod.number(), zod.null()]).optional(),
+ bounceRatePageViewMode: zod
+ .union([
+ zod.enum(['count_pageviews', 'uniq_urls', 'uniq_page_screen_autocaptures']),
+ zod.null(),
+ ])
+ .optional(),
+ convertToProjectTimezone: zod.union([zod.boolean(), zod.null()]).optional(),
+ cookielessTrafficIsRegular: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients.'
+ ),
+ customBotDefinitions: zod
+ .union([
+ zod.array(
+ zod.object({
+ category: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe('Reported by `$virt_traffic_category`. Defaults to `custom`.'),
+ combiner: zod
+ .enum(['AND', 'OR'])
+ .describe('Whether every condition must match (AND) or any one of them (OR).'),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod
+ .enum([
+ '$raw_user_agent',
+ '$ip',
+ '$lib',
+ '$host',
+ '$pathname',
+ '$current_url',
+ '$browser',
+ '$os',
+ '$browser_language',
+ '$screen_width',
+ '$screen_height',
+ '$geoip_country_code',
+ '$referrer',
+ '$referring_domain',
+ ])
+ .describe('The event property this condition reads.'),
+ matcher: zod.enum(['contains', 'regex', 'exact', 'cidr']),
+ pattern: zod
+ .string()
+ .describe('Matched against the property named by `key`.'),
+ })
+ ),
+ name: zod
+ .string()
+ .describe(
+ 'Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.'
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ customChannelTypeRules: zod
+ .union([
+ zod.array(
+ zod.object({
+ channel_type: zod.string(),
+ combiner: zod.enum(['AND', 'OR']),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod.enum([
+ 'utm_source',
+ 'utm_medium',
+ 'utm_campaign',
+ 'referring_domain',
+ 'url',
+ 'pathname',
+ 'hostname',
+ ]),
+ op: zod.enum([
+ 'exact',
+ 'is_not',
+ 'is_set',
+ 'is_not_set',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ dataWarehouseEventsModifiers: zod
+ .union([
+ zod.array(
+ zod.object({
+ distinct_id_field: zod.string(),
+ id_field: zod.string(),
+ table_name: zod.string(),
+ timestamp_field: zod.string(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ debug: zod.union([zod.boolean(), zod.null()]).optional(),
+ forceClickhouseDataSkippingIndexes: zod
+ .union([zod.array(zod.string()), zod.null()])
+ .optional()
+ .describe('If these are provided, the query will fail if these skip indexes are not used'),
+ formatCsvAllowDoubleQuotes: zod.union([zod.boolean(), zod.null()]).optional(),
+ inCohortVia: zod
+ .union([zod.enum(['auto', 'leftjoin', 'subquery', 'leftjoin_conjoined']), zod.null()])
+ .optional(),
+ inlineCohortCalculation: zod.union([zod.enum(['off', 'auto', 'always']), zod.null()]).optional(),
+ materializationMode: zod
+ .union([
+ zod.enum(['auto', 'legacy_null_as_string', 'legacy_null_as_null', 'disabled']),
+ zod.null(),
+ ])
+ .optional(),
+ materializedColumnsOptimizationMode: zod
+ .union([zod.enum(['disabled', 'optimized']), zod.null()])
+ .optional(),
+ mergeFederatedAggregateJoins: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap'
+ ),
+ optimizeJoinedFilters: zod.union([zod.boolean(), zod.null()]).optional(),
+ optimizeProjections: zod.union([zod.boolean(), zod.null()]).optional(),
+ parserMode: zod
+ .union([
+ zod.enum([
+ 'cpp_only',
+ 'cpp_with_rust_shadow',
+ 'cpp_with_rust_py_shadow',
+ 'rust_with_cpp_shadow',
+ 'rust_only',
+ 'rust_py_only',
+ 'rust_py_with_cpp_shadow',
+ ]),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ '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.'
+ ),
+ personsArgMaxVersion: zod.union([zod.enum(['auto', 'v1', 'v2']), zod.null()]).optional(),
+ personsJoinMode: zod.union([zod.enum(['inner', 'left']), zod.null()]).optional(),
+ personsOnEventsMode: zod
+ .union([
+ zod.enum([
+ 'disabled',
+ 'person_id_no_override_properties_on_events',
+ 'person_id_override_properties_on_events',
+ 'person_id_override_properties_joined',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ propertyGroupsMode: zod
+ .union([zod.enum(['enabled', 'disabled', 'optimized']), zod.null()])
+ .optional(),
+ pushDownPredicates: zod.union([zod.boolean(), zod.null()]).optional(),
+ s3TableUseInvalidColumns: zod.union([zod.boolean(), zod.null()]).optional(),
+ sessionIdPushdown: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter.'
+ ),
+ sessionPropertyPreAggregation: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown\/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`).'
+ ),
+ sessionTableVersion: zod.union([zod.enum(['auto', 'v1', 'v2', 'v3']), zod.null()]).optional(),
+ sessionsV2JoinMode: zod.union([zod.enum(['string', 'uuid']), zod.null()]).optional(),
+ timings: zod.union([zod.boolean(), zod.null()]).optional(),
+ typeAwareCastSimplification: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types'
+ ),
+ useMaterializedViews: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedIntermediateResults: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedTableTransforms: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Try to automatically convert HogQL queries to use preaggregated tables at the AST level \*'
+ ),
+ useWebAnalyticsPreAggregatedTables: zod.union([zod.boolean(), zod.null()]).optional(),
+ webAnalyticsFirstPageviewFilters: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_\*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ ),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone."
+ ),
filters: zod.unknown().optional(),
timezone: zod
.union([zod.string(), zod.null()])
@@ -2593,6 +3485,229 @@ export const BatchExportsRunTestStepNewCreateBody = /* @__PURE__ */ zod
.describe(
"HogQL SELECT query. With model 'hogql', its results are the data exported by every run. The query may reference the {data_interval_start} and {data_interval_end} placeholders, replaced with each run's data interval bounds, for example: WHERE timestamp >= {data_interval_start} AND timestamp < {data_interval_end}. Without them every run exports all rows the query returns. With model 'events', it defines a custom schema of columns to export instead. Required when model is 'hogql'."
),
+ hogql_modifiers: zod
+ .union([
+ zod.object({
+ bounceRateDurationSeconds: zod.union([zod.number(), zod.null()]).optional(),
+ bounceRatePageViewMode: zod
+ .union([
+ zod.enum(['count_pageviews', 'uniq_urls', 'uniq_page_screen_autocaptures']),
+ zod.null(),
+ ])
+ .optional(),
+ convertToProjectTimezone: zod.union([zod.boolean(), zod.null()]).optional(),
+ cookielessTrafficIsRegular: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients.'
+ ),
+ customBotDefinitions: zod
+ .union([
+ zod.array(
+ zod.object({
+ category: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe('Reported by `$virt_traffic_category`. Defaults to `custom`.'),
+ combiner: zod
+ .enum(['AND', 'OR'])
+ .describe('Whether every condition must match (AND) or any one of them (OR).'),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod
+ .enum([
+ '$raw_user_agent',
+ '$ip',
+ '$lib',
+ '$host',
+ '$pathname',
+ '$current_url',
+ '$browser',
+ '$os',
+ '$browser_language',
+ '$screen_width',
+ '$screen_height',
+ '$geoip_country_code',
+ '$referrer',
+ '$referring_domain',
+ ])
+ .describe('The event property this condition reads.'),
+ matcher: zod.enum(['contains', 'regex', 'exact', 'cidr']),
+ pattern: zod
+ .string()
+ .describe('Matched against the property named by `key`.'),
+ })
+ ),
+ name: zod
+ .string()
+ .describe(
+ 'Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.'
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ customChannelTypeRules: zod
+ .union([
+ zod.array(
+ zod.object({
+ channel_type: zod.string(),
+ combiner: zod.enum(['AND', 'OR']),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod.enum([
+ 'utm_source',
+ 'utm_medium',
+ 'utm_campaign',
+ 'referring_domain',
+ 'url',
+ 'pathname',
+ 'hostname',
+ ]),
+ op: zod.enum([
+ 'exact',
+ 'is_not',
+ 'is_set',
+ 'is_not_set',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ dataWarehouseEventsModifiers: zod
+ .union([
+ zod.array(
+ zod.object({
+ distinct_id_field: zod.string(),
+ id_field: zod.string(),
+ table_name: zod.string(),
+ timestamp_field: zod.string(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ debug: zod.union([zod.boolean(), zod.null()]).optional(),
+ forceClickhouseDataSkippingIndexes: zod
+ .union([zod.array(zod.string()), zod.null()])
+ .optional()
+ .describe('If these are provided, the query will fail if these skip indexes are not used'),
+ formatCsvAllowDoubleQuotes: zod.union([zod.boolean(), zod.null()]).optional(),
+ inCohortVia: zod
+ .union([zod.enum(['auto', 'leftjoin', 'subquery', 'leftjoin_conjoined']), zod.null()])
+ .optional(),
+ inlineCohortCalculation: zod.union([zod.enum(['off', 'auto', 'always']), zod.null()]).optional(),
+ materializationMode: zod
+ .union([
+ zod.enum(['auto', 'legacy_null_as_string', 'legacy_null_as_null', 'disabled']),
+ zod.null(),
+ ])
+ .optional(),
+ materializedColumnsOptimizationMode: zod
+ .union([zod.enum(['disabled', 'optimized']), zod.null()])
+ .optional(),
+ mergeFederatedAggregateJoins: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap'
+ ),
+ optimizeJoinedFilters: zod.union([zod.boolean(), zod.null()]).optional(),
+ optimizeProjections: zod.union([zod.boolean(), zod.null()]).optional(),
+ parserMode: zod
+ .union([
+ zod.enum([
+ 'cpp_only',
+ 'cpp_with_rust_shadow',
+ 'cpp_with_rust_py_shadow',
+ 'rust_with_cpp_shadow',
+ 'rust_only',
+ 'rust_py_only',
+ 'rust_py_with_cpp_shadow',
+ ]),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ '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.'
+ ),
+ personsArgMaxVersion: zod.union([zod.enum(['auto', 'v1', 'v2']), zod.null()]).optional(),
+ personsJoinMode: zod.union([zod.enum(['inner', 'left']), zod.null()]).optional(),
+ personsOnEventsMode: zod
+ .union([
+ zod.enum([
+ 'disabled',
+ 'person_id_no_override_properties_on_events',
+ 'person_id_override_properties_on_events',
+ 'person_id_override_properties_joined',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ propertyGroupsMode: zod
+ .union([zod.enum(['enabled', 'disabled', 'optimized']), zod.null()])
+ .optional(),
+ pushDownPredicates: zod.union([zod.boolean(), zod.null()]).optional(),
+ s3TableUseInvalidColumns: zod.union([zod.boolean(), zod.null()]).optional(),
+ sessionIdPushdown: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter.'
+ ),
+ sessionPropertyPreAggregation: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown\/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`).'
+ ),
+ sessionTableVersion: zod.union([zod.enum(['auto', 'v1', 'v2', 'v3']), zod.null()]).optional(),
+ sessionsV2JoinMode: zod.union([zod.enum(['string', 'uuid']), zod.null()]).optional(),
+ timings: zod.union([zod.boolean(), zod.null()]).optional(),
+ typeAwareCastSimplification: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types'
+ ),
+ useMaterializedViews: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedIntermediateResults: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedTableTransforms: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Try to automatically convert HogQL queries to use preaggregated tables at the AST level \*'
+ ),
+ useWebAnalyticsPreAggregatedTables: zod.union([zod.boolean(), zod.null()]).optional(),
+ webAnalyticsFirstPageviewFilters: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_\*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ ),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone."
+ ),
filters: zod.unknown().optional(),
timezone: zod
.union([zod.string(), zod.null()])
@@ -2790,6 +3905,226 @@ export const FileDownloadBatchExportsCreateBody = /* @__PURE__ */ zod.union([
.describe(
'HogQL SELECT query whose results are exported. This model is in closed beta and is enabled per team; when it is not enabled, the request fails with a permission error that names HogQL batch exports. Contact PostHog support to request access. The query may reference the {data_interval_start} and {data_interval_end} placeholders. Provide a value for each placeholder the query references; missing referenced bounds are rejected, not inferred. When both bounds are supplied, they must span at most seven days. Neither supplied bound may be in the future. Without placeholders, the query runs unchanged, even if bounds are supplied. Every column in the SELECT clause must be a field or have an alias. It is recommended to limit the query with a WHERE clause, for example bounding timestamp on the events table, both to avoid exporting more rows than expected and because user queries run under stricter resource limits than the other models.'
),
+ hogql_modifiers: zod
+ .object({
+ bounceRateDurationSeconds: zod.union([zod.number(), zod.null()]).optional(),
+ bounceRatePageViewMode: zod
+ .union([
+ zod.enum(['count_pageviews', 'uniq_urls', 'uniq_page_screen_autocaptures']),
+ zod.null(),
+ ])
+ .optional(),
+ convertToProjectTimezone: zod.union([zod.boolean(), zod.null()]).optional(),
+ cookielessTrafficIsRegular: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients.'
+ ),
+ customBotDefinitions: zod
+ .union([
+ zod.array(
+ zod.object({
+ category: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe('Reported by `$virt_traffic_category`. Defaults to `custom`.'),
+ combiner: zod
+ .enum(['AND', 'OR'])
+ .describe('Whether every condition must match (AND) or any one of them (OR).'),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod
+ .enum([
+ '$raw_user_agent',
+ '$ip',
+ '$lib',
+ '$host',
+ '$pathname',
+ '$current_url',
+ '$browser',
+ '$os',
+ '$browser_language',
+ '$screen_width',
+ '$screen_height',
+ '$geoip_country_code',
+ '$referrer',
+ '$referring_domain',
+ ])
+ .describe('The event property this condition reads.'),
+ matcher: zod.enum(['contains', 'regex', 'exact', 'cidr']),
+ pattern: zod
+ .string()
+ .describe('Matched against the property named by `key`.'),
+ })
+ ),
+ name: zod
+ .string()
+ .describe(
+ 'Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.'
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ customChannelTypeRules: zod
+ .union([
+ zod.array(
+ zod.object({
+ channel_type: zod.string(),
+ combiner: zod.enum(['AND', 'OR']),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod.enum([
+ 'utm_source',
+ 'utm_medium',
+ 'utm_campaign',
+ 'referring_domain',
+ 'url',
+ 'pathname',
+ 'hostname',
+ ]),
+ op: zod.enum([
+ 'exact',
+ 'is_not',
+ 'is_set',
+ 'is_not_set',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ dataWarehouseEventsModifiers: zod
+ .union([
+ zod.array(
+ zod.object({
+ distinct_id_field: zod.string(),
+ id_field: zod.string(),
+ table_name: zod.string(),
+ timestamp_field: zod.string(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ debug: zod.union([zod.boolean(), zod.null()]).optional(),
+ forceClickhouseDataSkippingIndexes: zod
+ .union([zod.array(zod.string()), zod.null()])
+ .optional()
+ .describe('If these are provided, the query will fail if these skip indexes are not used'),
+ formatCsvAllowDoubleQuotes: zod.union([zod.boolean(), zod.null()]).optional(),
+ inCohortVia: zod
+ .union([zod.enum(['auto', 'leftjoin', 'subquery', 'leftjoin_conjoined']), zod.null()])
+ .optional(),
+ inlineCohortCalculation: zod.union([zod.enum(['off', 'auto', 'always']), zod.null()]).optional(),
+ materializationMode: zod
+ .union([
+ zod.enum(['auto', 'legacy_null_as_string', 'legacy_null_as_null', 'disabled']),
+ zod.null(),
+ ])
+ .optional(),
+ materializedColumnsOptimizationMode: zod
+ .union([zod.enum(['disabled', 'optimized']), zod.null()])
+ .optional(),
+ mergeFederatedAggregateJoins: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap'
+ ),
+ optimizeJoinedFilters: zod.union([zod.boolean(), zod.null()]).optional(),
+ optimizeProjections: zod.union([zod.boolean(), zod.null()]).optional(),
+ parserMode: zod
+ .union([
+ zod.enum([
+ 'cpp_only',
+ 'cpp_with_rust_shadow',
+ 'cpp_with_rust_py_shadow',
+ 'rust_with_cpp_shadow',
+ 'rust_only',
+ 'rust_py_only',
+ 'rust_py_with_cpp_shadow',
+ ]),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ '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.'
+ ),
+ personsArgMaxVersion: zod.union([zod.enum(['auto', 'v1', 'v2']), zod.null()]).optional(),
+ personsJoinMode: zod.union([zod.enum(['inner', 'left']), zod.null()]).optional(),
+ personsOnEventsMode: zod
+ .union([
+ zod.enum([
+ 'disabled',
+ 'person_id_no_override_properties_on_events',
+ 'person_id_override_properties_on_events',
+ 'person_id_override_properties_joined',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ propertyGroupsMode: zod
+ .union([zod.enum(['enabled', 'disabled', 'optimized']), zod.null()])
+ .optional(),
+ pushDownPredicates: zod.union([zod.boolean(), zod.null()]).optional(),
+ s3TableUseInvalidColumns: zod.union([zod.boolean(), zod.null()]).optional(),
+ sessionIdPushdown: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter.'
+ ),
+ sessionPropertyPreAggregation: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown\/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`).'
+ ),
+ sessionTableVersion: zod.union([zod.enum(['auto', 'v1', 'v2', 'v3']), zod.null()]).optional(),
+ sessionsV2JoinMode: zod.union([zod.enum(['string', 'uuid']), zod.null()]).optional(),
+ timings: zod.union([zod.boolean(), zod.null()]).optional(),
+ typeAwareCastSimplification: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types'
+ ),
+ useMaterializedViews: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedIntermediateResults: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedTableTransforms: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Try to automatically convert HogQL queries to use preaggregated tables at the AST level \*'
+ ),
+ useWebAnalyticsPreAggregatedTables: zod.union([zod.boolean(), zod.null()]).optional(),
+ webAnalyticsFirstPageviewFilters: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_\*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ ),
+ })
+ .optional()
+ .describe(
+ "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone."
+ ),
data_interval_start: zod.iso
.datetime({ offset: true })
.optional()
@@ -2820,6 +4155,216 @@ export const FileDownloadBatchExportsCountRowsCreateBody = /* @__PURE__ */ zod
.describe(
'HogQL SELECT query whose results are exported. This model is in closed beta and is enabled per team; when it is not enabled, the request fails with a permission error that names HogQL batch exports. Contact PostHog support to request access. The query may reference the {data_interval_start} and {data_interval_end} placeholders. Provide a value for each placeholder the query references; missing referenced bounds are rejected, not inferred. When both bounds are supplied, they must span at most seven days. Neither supplied bound may be in the future. Without placeholders, the query runs unchanged, even if bounds are supplied. Every column in the SELECT clause must be a field or have an alias. It is recommended to limit the query with a WHERE clause, for example bounding timestamp on the events table, both to avoid exporting more rows than expected and because user queries run under stricter resource limits than the other models.'
),
+ hogql_modifiers: zod
+ .object({
+ bounceRateDurationSeconds: zod.union([zod.number(), zod.null()]).optional(),
+ bounceRatePageViewMode: zod
+ .union([zod.enum(['count_pageviews', 'uniq_urls', 'uniq_page_screen_autocaptures']), zod.null()])
+ .optional(),
+ convertToProjectTimezone: zod.union([zod.boolean(), zod.null()]).optional(),
+ cookielessTrafficIsRegular: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients.'
+ ),
+ customBotDefinitions: zod
+ .union([
+ zod.array(
+ zod.object({
+ category: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe('Reported by `$virt_traffic_category`. Defaults to `custom`.'),
+ combiner: zod
+ .enum(['AND', 'OR'])
+ .describe('Whether every condition must match (AND) or any one of them (OR).'),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod
+ .enum([
+ '$raw_user_agent',
+ '$ip',
+ '$lib',
+ '$host',
+ '$pathname',
+ '$current_url',
+ '$browser',
+ '$os',
+ '$browser_language',
+ '$screen_width',
+ '$screen_height',
+ '$geoip_country_code',
+ '$referrer',
+ '$referring_domain',
+ ])
+ .describe('The event property this condition reads.'),
+ matcher: zod.enum(['contains', 'regex', 'exact', 'cidr']),
+ pattern: zod.string().describe('Matched against the property named by `key`.'),
+ })
+ ),
+ name: zod
+ .string()
+ .describe(
+ 'Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.'
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ customChannelTypeRules: zod
+ .union([
+ zod.array(
+ zod.object({
+ channel_type: zod.string(),
+ combiner: zod.enum(['AND', 'OR']),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod.enum([
+ 'utm_source',
+ 'utm_medium',
+ 'utm_campaign',
+ 'referring_domain',
+ 'url',
+ 'pathname',
+ 'hostname',
+ ]),
+ op: zod.enum([
+ 'exact',
+ 'is_not',
+ 'is_set',
+ 'is_not_set',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ dataWarehouseEventsModifiers: zod
+ .union([
+ zod.array(
+ zod.object({
+ distinct_id_field: zod.string(),
+ id_field: zod.string(),
+ table_name: zod.string(),
+ timestamp_field: zod.string(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ debug: zod.union([zod.boolean(), zod.null()]).optional(),
+ forceClickhouseDataSkippingIndexes: zod
+ .union([zod.array(zod.string()), zod.null()])
+ .optional()
+ .describe('If these are provided, the query will fail if these skip indexes are not used'),
+ formatCsvAllowDoubleQuotes: zod.union([zod.boolean(), zod.null()]).optional(),
+ inCohortVia: zod
+ .union([zod.enum(['auto', 'leftjoin', 'subquery', 'leftjoin_conjoined']), zod.null()])
+ .optional(),
+ inlineCohortCalculation: zod.union([zod.enum(['off', 'auto', 'always']), zod.null()]).optional(),
+ materializationMode: zod
+ .union([zod.enum(['auto', 'legacy_null_as_string', 'legacy_null_as_null', 'disabled']), zod.null()])
+ .optional(),
+ materializedColumnsOptimizationMode: zod
+ .union([zod.enum(['disabled', 'optimized']), zod.null()])
+ .optional(),
+ mergeFederatedAggregateJoins: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap'
+ ),
+ optimizeJoinedFilters: zod.union([zod.boolean(), zod.null()]).optional(),
+ optimizeProjections: zod.union([zod.boolean(), zod.null()]).optional(),
+ parserMode: zod
+ .union([
+ zod.enum([
+ 'cpp_only',
+ 'cpp_with_rust_shadow',
+ 'cpp_with_rust_py_shadow',
+ 'rust_with_cpp_shadow',
+ 'rust_only',
+ 'rust_py_only',
+ 'rust_py_with_cpp_shadow',
+ ]),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ '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.'
+ ),
+ personsArgMaxVersion: zod.union([zod.enum(['auto', 'v1', 'v2']), zod.null()]).optional(),
+ personsJoinMode: zod.union([zod.enum(['inner', 'left']), zod.null()]).optional(),
+ personsOnEventsMode: zod
+ .union([
+ zod.enum([
+ 'disabled',
+ 'person_id_no_override_properties_on_events',
+ 'person_id_override_properties_on_events',
+ 'person_id_override_properties_joined',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ propertyGroupsMode: zod.union([zod.enum(['enabled', 'disabled', 'optimized']), zod.null()]).optional(),
+ pushDownPredicates: zod.union([zod.boolean(), zod.null()]).optional(),
+ s3TableUseInvalidColumns: zod.union([zod.boolean(), zod.null()]).optional(),
+ sessionIdPushdown: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter.'
+ ),
+ sessionPropertyPreAggregation: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown\/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`).'
+ ),
+ sessionTableVersion: zod.union([zod.enum(['auto', 'v1', 'v2', 'v3']), zod.null()]).optional(),
+ sessionsV2JoinMode: zod.union([zod.enum(['string', 'uuid']), zod.null()]).optional(),
+ timings: zod.union([zod.boolean(), zod.null()]).optional(),
+ typeAwareCastSimplification: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types'
+ ),
+ useMaterializedViews: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedIntermediateResults: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedTableTransforms: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Try to automatically convert HogQL queries to use preaggregated tables at the AST level \*'
+ ),
+ useWebAnalyticsPreAggregatedTables: zod.union([zod.boolean(), zod.null()]).optional(),
+ webAnalyticsFirstPageviewFilters: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_\*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ ),
+ })
+ .optional()
+ .describe(
+ "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone."
+ ),
data_interval_start: zod.iso
.datetime({ offset: true })
.optional()
diff --git a/products/batch_exports/mcp/tools.yaml b/products/batch_exports/mcp/tools.yaml
index a8ffb8ee263b..5a01c7fb8adb 100644
--- a/products/batch_exports/mcp/tools.yaml
+++ b/products/batch_exports/mcp/tools.yaml
@@ -20,12 +20,13 @@ tools:
idempotent: false
title: Create batch export
description: >
- Create a new batch export. Typed destination config schemas are available for Databricks, AzureBlob,
- BigQuery, Postgres, AwsS3, S3Compatible and Snowflake destinations. All of those except Snowflake require a
- team-scoped Integration for credentials (use integrations-list to find one). Other destination types are
- permitted by the API but typically must be created via the PostHog UI because their credentials are stored
- in the destination config. Always specify the model field (events, persons, sessions, or hogql). Omitting it
- defaults to events. For the hogql model, provide hogql_query.
+ Create a new batch export. This tool supports typed destination configs for Databricks, AzureBlob, BigQuery,
+ Postgres, AwsS3, S3Compatible, Snowflake, and Redshift. All require a team-scoped integration for
+ credentials. Use integrations-list to find one and pass its ID as destination.integration_id. Always specify
+ the model field (events, persons, sessions, or hogql). Omitting it defaults to events. For the hogql model,
+ provide hogql_query. Optionally provide hogql_modifiers, which override the project HogQL modifiers with the
+ same names for this export only, for example {"convertToProjectTimezone": false} to export timestamps in
+ UTC.
exclude_params:
- id
- team_id
@@ -62,7 +63,7 @@ tools:
title: Get batch export
description: >
Get a batch export by ID. Returns full non-sensitive configuration including destination type and config,
- linked Integration id (for Databricks and AzureBlob), schedule, model, and the 10 most recent runs.
+ linked integration ID when present, schedule, model, and the 10 most recent runs.
batch-export-update:
operation: batch_exports_partial_update
enabled: true
@@ -74,10 +75,11 @@ tools:
idempotent: true
title: Update batch export
description: >
- Partially update a batch export. Top-level fields (name, paused, interval, schema, filters) work for any
- destination type. Destination config updates are only typed for Databricks and AzureBlob destinations. Do
- not change the model field on an existing export — the destination table schema is created on the first run,
- so switching models causes errors unless the table name is also changed.
+ Partially update a batch export. Top-level fields (name, paused, interval, timezone, offset_day,
+ offset_hour) work for any destination type. For the hogql model, hogql_query and hogql_modifiers can also
+ change; send hogql_modifiers as null to remove them. Typed destination config updates are available for
+ Databricks, AzureBlob, BigQuery, Postgres, AwsS3, S3Compatible, Snowflake, and Redshift. The destination
+ type cannot be changed. Do not change the model field on an existing batch export.
exclude_params:
- id
- team_id
@@ -205,9 +207,9 @@ tools:
contact PostHog support to request access. Counting runs the full query on ClickHouse, so it can take a
while and can fail with a timeout for heavy unbounded queries. If the user wishes to estimate the size of an
export, use it before file-download-batch-exports-create to check a hogql_query returns the amount of data
- the user expects, and tighten its WHERE clause when the count is much larger than expected. Running count
- queries is potentially as expensive as running the actual export query, so consider whether this is worth
- it.
+ the user expects, and tighten its WHERE clause when the count is much larger than expected. Pass the same
+ hogql_modifiers as the export, so that the count resolves the query the same way. Running count queries is
+ potentially as expensive as running the actual export query, so consider whether this is worth it.
file-download-batch-exports-create:
operation: file_download_batch_exports_create
enabled: true
@@ -223,14 +225,16 @@ tools:
results of a HogQL query. For events, persons and sessions, provide data_interval_start and
data_interval_end as ISO 8601 datetimes; the interval must be at most one week, and for events, include and
exclude filter event names. The hogql model is in closed beta and is enabled per team: it takes a
- hogql_query instead of a data interval, and returns a permission error naming HogQL batch exports when the
- team does not have it enabled, in which case tell the user they can contact PostHog support to request
- access. Limit hogql_query with a WHERE clause to export only the data the user asked for, because user
- queries run under stricter resource limits than the other models. The export splits into files of about 1024
- MiB by default, and a file can go a little over; set file.max_size_mb to change that size, or to null to
- write a single file of any size. Use file-download-batch-exports-retrieve with the returned id to poll until
- status is Completed, then follow the downloading-batch-export-files skill to download the files through the
- existing REST download endpoint.
+ hogql_query, which can reference the {data_interval_start} and {data_interval_end} placeholders filled from
+ data_interval_start and data_interval_end, and optional hogql_modifiers, which override the project HogQL
+ modifiers with the same names. It returns a permission error naming HogQL batch exports when the team does
+ not have it enabled, in which case tell the user they can contact PostHog support to request access. Limit
+ hogql_query with a WHERE clause to export only the data the user asked for, because user queries run under
+ stricter resource limits than the other models. The export splits into files of about 1024 MiB by default,
+ and a file can go a little over; set file.max_size_mb to change that size, or to null to write a single file
+ of any size. Use file-download-batch-exports-retrieve with the returned id to poll until status is
+ Completed, then follow the downloading-batch-export-files skill to download the files through the existing
+ REST download endpoint.
file-download-batch-exports-download-retrieve:
operation: file_download_batch_exports_download_retrieve
enabled: false
diff --git a/products/batch_exports/skills/downloading-batch-export-files/SKILL.md b/products/batch_exports/skills/downloading-batch-export-files/SKILL.md
index c32dc9f5b9e6..80c05d1d3546 100644
--- a/products/batch_exports/skills/downloading-batch-export-files/SKILL.md
+++ b/products/batch_exports/skills/downloading-batch-export-files/SKILL.md
@@ -155,6 +155,7 @@ posthog-persons-<run_id>-<part>.parquet
- The maximum export interval is one week. Split longer user requests into separate export runs or ask which week to export.
- The `hogql` model is in closed beta and is enabled per team. A permission error that says HogQL batch exports are not enabled means the team does not have the beta. Report that instead of retrying with a different query, and tell the user they can contact PostHog support to request access.
- The `hogql` model runs under stricter resource limits than the other models, because user queries are less predictable. If an export fails on memory, execution time, or bytes read, suggest narrowing the query with a WHERE clause instead of retrying it unchanged.
+- The `hogql` model accepts an optional `hogql_modifiers` object. Each modifier in it overrides the project HogQL modifier with the same name for this export only, and the project modifiers apply to all others. By default, `timestamp` columns come out in the project timezone, so pass `{"convertToProjectTimezone": false}` when the user wants UTC timestamps. Pass the same `hogql_modifiers` to `posthog:file-download-batch-exports-count-rows-create`, so that the count matches the export.
- A run can briefly report `Running` after completion while file records are being created. Poll again instead of failing immediately.
- Download URLs are temporary. If a URL expires, call the REST download endpoint again for a fresh redirect.
- Do not send the signed URL to unrelated services unless the user explicitly asks; it grants temporary access to the exported file.
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 9632e721959e..5fd335a63ac1 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -1390,7 +1390,7 @@
"feature_flag": "autoresearch"
},
"batch-export-create": {
- "description": "Create a new batch export. Typed destination config schemas are available for Databricks, AzureBlob, BigQuery, Postgres, AwsS3, S3Compatible and Snowflake destinations. All of those except Snowflake require a team-scoped Integration for credentials (use integrations-list to find one). Other destination types are permitted by the API but typically must be created via the PostHog UI because their credentials are stored in the destination config. Always specify the model field (events, persons, sessions, or hogql). Omitting it defaults to events. For the hogql model, provide hogql_query.",
+ "description": "Create a new batch export. This tool supports typed destination configs for Databricks, AzureBlob, BigQuery, Postgres, AwsS3, S3Compatible, Snowflake, and Redshift. All require a team-scoped integration for credentials. Use integrations-list to find one and pass its ID as destination.integration_id. Always specify the model field (events, persons, sessions, or hogql). Omitting it defaults to events. For the hogql model, provide hogql_query. Optionally provide hogql_modifiers, which override the project HogQL modifiers with the same names for this export only, for example {\"convertToProjectTimezone\": false} to export timestamps in UTC.",
"category": "Data pipelines",
"feature": "batch_exports",
"summary": "Create batch export",
@@ -1418,7 +1418,7 @@
}
},
"batch-export-get": {
- "description": "Get a batch export by ID. Returns full non-sensitive configuration including destination type and config, linked Integration id (for Databricks and AzureBlob), schedule, model, and the 10 most recent runs.",
+ "description": "Get a batch export by ID. Returns full non-sensitive configuration including destination type and config, linked integration ID when present, schedule, model, and the 10 most recent runs.",
"category": "Data pipelines",
"feature": "batch_exports",
"summary": "Get batch export",
@@ -1432,7 +1432,7 @@
}
},
"batch-export-update": {
- "description": "Partially update a batch export. Top-level fields (name, paused, interval, schema, filters) work for any destination type. Destination config updates are only typed for Databricks and AzureBlob destinations. Do not change the model field on an existing export — the destination table schema is created on the first run, so switching models causes errors unless the table name is also changed.",
+ "description": "Partially update a batch export. Top-level fields (name, paused, interval, timezone, offset_day, offset_hour) work for any destination type. For the hogql model, hogql_query and hogql_modifiers can also change; send hogql_modifiers as null to remove them. Typed destination config updates are available for Databricks, AzureBlob, BigQuery, Postgres, AwsS3, S3Compatible, Snowflake, and Redshift. The destination type cannot be changed. Do not change the model field on an existing batch export.",
"category": "Data pipelines",
"feature": "batch_exports",
"summary": "Update batch export",
@@ -6346,7 +6346,7 @@
}
},
"file-download-batch-exports-count-rows-create": {
- "description": "Count the rows a HogQL file download export would produce if started now, without starting an export. Only the hogql model is supported; it is in closed beta and enabled per team, and this returns a permission error naming HogQL batch exports when the team does not have it enabled, in which case tell the user they can contact PostHog support to request access. Counting runs the full query on ClickHouse, so it can take a while and can fail with a timeout for heavy unbounded queries. If the user wishes to estimate the size of an export, use it before file-download-batch-exports-create to check a hogql_query returns the amount of data the user expects, and tighten its WHERE clause when the count is much larger than expected. Running count queries is potentially as expensive as running the actual export query, so consider whether this is worth it.",
+ "description": "Count the rows a HogQL file download export would produce if started now, without starting an export. Only the hogql model is supported; it is in closed beta and enabled per team, and this returns a permission error naming HogQL batch exports when the team does not have it enabled, in which case tell the user they can contact PostHog support to request access. Counting runs the full query on ClickHouse, so it can take a while and can fail with a timeout for heavy unbounded queries. If the user wishes to estimate the size of an export, use it before file-download-batch-exports-create to check a hogql_query returns the amount of data the user expects, and tighten its WHERE clause when the count is much larger than expected. Pass the same hogql_modifiers as the export, so that the count resolves the query the same way. Running count queries is potentially as expensive as running the actual export query, so consider whether this is worth it.",
"category": "Data pipelines",
"feature": "batch_exports",
"summary": "Count rows a HogQL file download export would produce",
@@ -6360,7 +6360,7 @@
}
},
"file-download-batch-exports-create": {
- "description": "Start an on-demand batch export that prepares downloadable files for events, persons, sessions, or the results of a HogQL query. For events, persons and sessions, provide data_interval_start and data_interval_end as ISO 8601 datetimes; the interval must be at most one week, and for events, include and exclude filter event names. The hogql model is in closed beta and is enabled per team: it takes a hogql_query instead of a data interval, and returns a permission error naming HogQL batch exports when the team does not have it enabled, in which case tell the user they can contact PostHog support to request access. Limit hogql_query with a WHERE clause to export only the data the user asked for, because user queries run under stricter resource limits than the other models. The export splits into files of about 1024 MiB by default, and a file can go a little over; set file.max_size_mb to change that size, or to null to write a single file of any size. Use file-download-batch-exports-retrieve with the returned id to poll until status is Completed, then follow the downloading-batch-export-files skill to download the files through the existing REST download endpoint.",
+ "description": "Start an on-demand batch export that prepares downloadable files for events, persons, sessions, or the results of a HogQL query. For events, persons and sessions, provide data_interval_start and data_interval_end as ISO 8601 datetimes; the interval must be at most one week, and for events, include and exclude filter event names. The hogql model is in closed beta and is enabled per team: it takes a hogql_query, which can reference the {data_interval_start} and {data_interval_end} placeholders filled from data_interval_start and data_interval_end, and optional hogql_modifiers, which override the project HogQL modifiers with the same names. It returns a permission error naming HogQL batch exports when the team does not have it enabled, in which case tell the user they can contact PostHog support to request access. Limit hogql_query with a WHERE clause to export only the data the user asked for, because user queries run under stricter resource limits than the other models. The export splits into files of about 1024 MiB by default, and a file can go a little over; set file.max_size_mb to change that size, or to null to write a single file of any size. Use file-download-batch-exports-retrieve with the returned id to poll until status is Completed, then follow the downloading-batch-export-files skill to download the files through the existing REST download endpoint.",
"category": "Data pipelines",
"feature": "batch_exports",
"summary": "Start file download export",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index c9a5ce8bb0e0..13821b82a84e 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -1405,7 +1405,7 @@
"feature_flag": "autoresearch"
},
"batch-export-create": {
- "description": "Create a new batch export. Typed destination config schemas are available for Databricks, AzureBlob, BigQuery, Postgres, AwsS3, S3Compatible and Snowflake destinations. All of those except Snowflake require a team-scoped Integration for credentials (use integrations-list to find one). Other destination types are permitted by the API but typically must be created via the PostHog UI because their credentials are stored in the destination config. Always specify the model field (events, persons, sessions, or hogql). Omitting it defaults to events. For the hogql model, provide hogql_query.",
+ "description": "Create a new batch export. This tool supports typed destination configs for Databricks, AzureBlob, BigQuery, Postgres, AwsS3, S3Compatible, Snowflake, and Redshift. All require a team-scoped integration for credentials. Use integrations-list to find one and pass its ID as destination.integration_id. Always specify the model field (events, persons, sessions, or hogql). Omitting it defaults to events. For the hogql model, provide hogql_query. Optionally provide hogql_modifiers, which override the project HogQL modifiers with the same names for this export only, for example {\"convertToProjectTimezone\": false} to export timestamps in UTC.",
"category": "Data pipelines",
"feature": "batch_exports",
"summary": "Create batch export",
@@ -1433,7 +1433,7 @@
}
},
"batch-export-get": {
- "description": "Get a batch export by ID. Returns full non-sensitive configuration including destination type and config, linked Integration id (for Databricks and AzureBlob), schedule, model, and the 10 most recent runs.",
+ "description": "Get a batch export by ID. Returns full non-sensitive configuration including destination type and config, linked integration ID when present, schedule, model, and the 10 most recent runs.",
"category": "Data pipelines",
"feature": "batch_exports",
"summary": "Get batch export",
@@ -1447,7 +1447,7 @@
}
},
"batch-export-update": {
- "description": "Partially update a batch export. Top-level fields (name, paused, interval, schema, filters) work for any destination type. Destination config updates are only typed for Databricks and AzureBlob destinations. Do not change the model field on an existing export — the destination table schema is created on the first run, so switching models causes errors unless the table name is also changed.",
+ "description": "Partially update a batch export. Top-level fields (name, paused, interval, timezone, offset_day, offset_hour) work for any destination type. For the hogql model, hogql_query and hogql_modifiers can also change; send hogql_modifiers as null to remove them. Typed destination config updates are available for Databricks, AzureBlob, BigQuery, Postgres, AwsS3, S3Compatible, Snowflake, and Redshift. The destination type cannot be changed. Do not change the model field on an existing batch export.",
"category": "Data pipelines",
"feature": "batch_exports",
"summary": "Update batch export",
@@ -6515,7 +6515,7 @@
}
},
"file-download-batch-exports-count-rows-create": {
- "description": "Count the rows a HogQL file download export would produce if started now, without starting an export. Only the hogql model is supported; it is in closed beta and enabled per team, and this returns a permission error naming HogQL batch exports when the team does not have it enabled, in which case tell the user they can contact PostHog support to request access. Counting runs the full query on ClickHouse, so it can take a while and can fail with a timeout for heavy unbounded queries. If the user wishes to estimate the size of an export, use it before file-download-batch-exports-create to check a hogql_query returns the amount of data the user expects, and tighten its WHERE clause when the count is much larger than expected. Running count queries is potentially as expensive as running the actual export query, so consider whether this is worth it.",
+ "description": "Count the rows a HogQL file download export would produce if started now, without starting an export. Only the hogql model is supported; it is in closed beta and enabled per team, and this returns a permission error naming HogQL batch exports when the team does not have it enabled, in which case tell the user they can contact PostHog support to request access. Counting runs the full query on ClickHouse, so it can take a while and can fail with a timeout for heavy unbounded queries. If the user wishes to estimate the size of an export, use it before file-download-batch-exports-create to check a hogql_query returns the amount of data the user expects, and tighten its WHERE clause when the count is much larger than expected. Pass the same hogql_modifiers as the export, so that the count resolves the query the same way. Running count queries is potentially as expensive as running the actual export query, so consider whether this is worth it.",
"category": "Data pipelines",
"feature": "batch_exports",
"summary": "Count rows a HogQL file download export would produce",
@@ -6529,7 +6529,7 @@
}
},
"file-download-batch-exports-create": {
- "description": "Start an on-demand batch export that prepares downloadable files for events, persons, sessions, or the results of a HogQL query. For events, persons and sessions, provide data_interval_start and data_interval_end as ISO 8601 datetimes; the interval must be at most one week, and for events, include and exclude filter event names. The hogql model is in closed beta and is enabled per team: it takes a hogql_query instead of a data interval, and returns a permission error naming HogQL batch exports when the team does not have it enabled, in which case tell the user they can contact PostHog support to request access. Limit hogql_query with a WHERE clause to export only the data the user asked for, because user queries run under stricter resource limits than the other models. The export splits into files of about 1024 MiB by default, and a file can go a little over; set file.max_size_mb to change that size, or to null to write a single file of any size. Use file-download-batch-exports-retrieve with the returned id to poll until status is Completed, then follow the downloading-batch-export-files skill to download the files through the existing REST download endpoint.",
+ "description": "Start an on-demand batch export that prepares downloadable files for events, persons, sessions, or the results of a HogQL query. For events, persons and sessions, provide data_interval_start and data_interval_end as ISO 8601 datetimes; the interval must be at most one week, and for events, include and exclude filter event names. The hogql model is in closed beta and is enabled per team: it takes a hogql_query, which can reference the {data_interval_start} and {data_interval_end} placeholders filled from data_interval_start and data_interval_end, and optional hogql_modifiers, which override the project HogQL modifiers with the same names. It returns a permission error naming HogQL batch exports when the team does not have it enabled, in which case tell the user they can contact PostHog support to request access. Limit hogql_query with a WHERE clause to export only the data the user asked for, because user queries run under stricter resource limits than the other models. The export splits into files of about 1024 MiB by default, and a file can go a little over; set file.max_size_mb to change that size, or to null to write a single file of any size. Use file-download-batch-exports-retrieve with the returned id to poll until status is Completed, then follow the downloading-batch-export-files skill to download the files through the existing REST download endpoint.",
"category": "Data pipelines",
"feature": "batch_exports",
"summary": "Start file download export",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 52bedd99c3a9..0cdbaa5f2e82 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -14304,6 +14304,8 @@ export namespace Schemas {
* @nullable
*/
hogql_query?: string | null;
+ /** HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone. */
+ hogql_modifiers?: HogQLQueryModifiers | null;
/** A schema of custom fields to select when exporting data. */
readonly schema: unknown;
filters?: unknown;
@@ -15151,6 +15153,8 @@ export namespace Schemas {
* @nullable
*/
hogql_query?: string | null;
+ /** HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone. */
+ hogql_modifiers?: HogQLQueryModifiers | null;
/** Optional list of property filters to restrict which events are exported. Each filter is a serialized HogQL property filter object with a 'type' of one of: 'event', 'hogql', 'person' (e.g. {"key": "$browser", "operator": "exact", "type": "event", "value": ["Firefox"]}). */
filters?: unknown;
/**
@@ -23419,6 +23423,8 @@ export namespace Schemas {
model: FileDownloadHogQLRequestModel;
/** HogQL SELECT query whose results are exported. This model is in closed beta and is enabled per team; when it is not enabled, the request fails with a permission error that names HogQL batch exports. Contact PostHog support to request access. The query may reference the {data_interval_start} and {data_interval_end} placeholders. Provide a value for each placeholder the query references; missing referenced bounds are rejected, not inferred. When both bounds are supplied, they must span at most seven days. Neither supplied bound may be in the future. Without placeholders, the query runs unchanged, even if bounds are supplied. Every column in the SELECT clause must be a field or have an alias. It is recommended to limit the query with a WHERE clause, for example bounding timestamp on the events table, both to avoid exporting more rows than expected and because user queries run under stricter resource limits than the other models. */
hogql_query: string;
+ /** HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone. */
+ hogql_modifiers?: HogQLQueryModifiers;
/** Start of the export interval. Required for the events, persons, and sessions models. For HogQL, required only when the query references {data_interval_start}. A supplied start must not be in the future. When both bounds are supplied, the interval must span at most seven days. */
data_interval_start?: string;
/** End of the export interval. Required for the events, persons, and sessions models. For HogQL, required only when the query references {data_interval_end}. A supplied end must not be in the future or precede a supplied start. Bounds replace HogQL placeholders; they do not add filters to the query. */
@@ -47661,6 +47667,8 @@ export namespace Schemas {
model: FileDownloadHogQLModelEnum;
/** HogQL SELECT query whose results are exported. This model is in closed beta and is enabled per team; when it is not enabled, the request fails with a permission error that names HogQL batch exports. Contact PostHog support to request access. The query may reference the {data_interval_start} and {data_interval_end} placeholders. Provide a value for each placeholder the query references; missing referenced bounds are rejected, not inferred. When both bounds are supplied, they must span at most seven days. Neither supplied bound may be in the future. Without placeholders, the query runs unchanged, even if bounds are supplied. Every column in the SELECT clause must be a field or have an alias. It is recommended to limit the query with a WHERE clause, for example bounding timestamp on the events table, both to avoid exporting more rows than expected and because user queries run under stricter resource limits than the other models. */
hogql_query: string;
+ /** HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone. */
+ hogql_modifiers?: HogQLQueryModifiers;
/** Start of the export interval. Required for the events, persons, and sessions models. For HogQL, required only when the query references {data_interval_start}. A supplied start must not be in the future. When both bounds are supplied, the interval must span at most seven days. */
data_interval_start?: string;
/** End of the export interval. Required for the events, persons, and sessions models. For HogQL, required only when the query references {data_interval_end}. A supplied end must not be in the future or precede a supplied start. Bounds replace HogQL placeholders; they do not add filters to the query. */
@@ -71667,6 +71675,8 @@ export namespace Schemas {
* @nullable
*/
hogql_query?: string | null;
+ /** HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone. */
+ hogql_modifiers?: HogQLQueryModifiers | null;
/** Optional list of property filters to restrict which events are exported. Each filter is a serialized HogQL property filter object with a 'type' of one of: 'event', 'hogql', 'person' (e.g. {"key": "$browser", "operator": "exact", "type": "event", "value": ["Firefox"]}). */
filters?: unknown;
/**
diff --git a/services/mcp/src/generated/batch_exports/api.ts b/services/mcp/src/generated/batch_exports/api.ts
index 3fdbd34e0216..eb5572134efa 100644
--- a/services/mcp/src/generated/batch_exports/api.ts
+++ b/services/mcp/src/generated/batch_exports/api.ts
@@ -461,6 +461,229 @@ export const BatchExportsCreateBody = () => zod
.describe(
"HogQL SELECT query. With model 'hogql', its results are the data exported by every run. The query may reference the {data_interval_start} and {data_interval_end} placeholders, replaced with each run's data interval bounds, for example: WHERE timestamp >= {data_interval_start} AND timestamp < {data_interval_end}. Without them every run exports all rows the query returns. With model 'events', it defines a custom schema of columns to export instead. Required when model is 'hogql'."
),
+ hogql_modifiers: zod
+ .union([
+ zod.object({
+ bounceRateDurationSeconds: zod.union([zod.number(), zod.null()]).optional(),
+ bounceRatePageViewMode: zod
+ .union([
+ zod.enum(['count_pageviews', 'uniq_urls', 'uniq_page_screen_autocaptures']),
+ zod.null(),
+ ])
+ .optional(),
+ convertToProjectTimezone: zod.union([zod.boolean(), zod.null()]).optional(),
+ cookielessTrafficIsRegular: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients.'
+ ),
+ customBotDefinitions: zod
+ .union([
+ zod.array(
+ zod.object({
+ category: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe('Reported by `$virt_traffic_category`. Defaults to `custom`.'),
+ combiner: zod
+ .enum(['AND', 'OR'])
+ .describe('Whether every condition must match (AND) or any one of them (OR).'),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod
+ .enum([
+ '$raw_user_agent',
+ '$ip',
+ '$lib',
+ '$host',
+ '$pathname',
+ '$current_url',
+ '$browser',
+ '$os',
+ '$browser_language',
+ '$screen_width',
+ '$screen_height',
+ '$geoip_country_code',
+ '$referrer',
+ '$referring_domain',
+ ])
+ .describe('The event property this condition reads.'),
+ matcher: zod.enum(['contains', 'regex', 'exact', 'cidr']),
+ pattern: zod
+ .string()
+ .describe('Matched against the property named by `key`.'),
+ })
+ ),
+ name: zod
+ .string()
+ .describe(
+ 'Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.'
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ customChannelTypeRules: zod
+ .union([
+ zod.array(
+ zod.object({
+ channel_type: zod.string(),
+ combiner: zod.enum(['AND', 'OR']),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod.enum([
+ 'utm_source',
+ 'utm_medium',
+ 'utm_campaign',
+ 'referring_domain',
+ 'url',
+ 'pathname',
+ 'hostname',
+ ]),
+ op: zod.enum([
+ 'exact',
+ 'is_not',
+ 'is_set',
+ 'is_not_set',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ dataWarehouseEventsModifiers: zod
+ .union([
+ zod.array(
+ zod.object({
+ distinct_id_field: zod.string(),
+ id_field: zod.string(),
+ table_name: zod.string(),
+ timestamp_field: zod.string(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ debug: zod.union([zod.boolean(), zod.null()]).optional(),
+ forceClickhouseDataSkippingIndexes: zod
+ .union([zod.array(zod.string()), zod.null()])
+ .optional()
+ .describe('If these are provided, the query will fail if these skip indexes are not used'),
+ formatCsvAllowDoubleQuotes: zod.union([zod.boolean(), zod.null()]).optional(),
+ inCohortVia: zod
+ .union([zod.enum(['auto', 'leftjoin', 'subquery', 'leftjoin_conjoined']), zod.null()])
+ .optional(),
+ inlineCohortCalculation: zod.union([zod.enum(['off', 'auto', 'always']), zod.null()]).optional(),
+ materializationMode: zod
+ .union([
+ zod.enum(['auto', 'legacy_null_as_string', 'legacy_null_as_null', 'disabled']),
+ zod.null(),
+ ])
+ .optional(),
+ materializedColumnsOptimizationMode: zod
+ .union([zod.enum(['disabled', 'optimized']), zod.null()])
+ .optional(),
+ mergeFederatedAggregateJoins: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap'
+ ),
+ optimizeJoinedFilters: zod.union([zod.boolean(), zod.null()]).optional(),
+ optimizeProjections: zod.union([zod.boolean(), zod.null()]).optional(),
+ parserMode: zod
+ .union([
+ zod.enum([
+ 'cpp_only',
+ 'cpp_with_rust_shadow',
+ 'cpp_with_rust_py_shadow',
+ 'rust_with_cpp_shadow',
+ 'rust_only',
+ 'rust_py_only',
+ 'rust_py_with_cpp_shadow',
+ ]),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ '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.'
+ ),
+ personsArgMaxVersion: zod.union([zod.enum(['auto', 'v1', 'v2']), zod.null()]).optional(),
+ personsJoinMode: zod.union([zod.enum(['inner', 'left']), zod.null()]).optional(),
+ personsOnEventsMode: zod
+ .union([
+ zod.enum([
+ 'disabled',
+ 'person_id_no_override_properties_on_events',
+ 'person_id_override_properties_on_events',
+ 'person_id_override_properties_joined',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ propertyGroupsMode: zod
+ .union([zod.enum(['enabled', 'disabled', 'optimized']), zod.null()])
+ .optional(),
+ pushDownPredicates: zod.union([zod.boolean(), zod.null()]).optional(),
+ s3TableUseInvalidColumns: zod.union([zod.boolean(), zod.null()]).optional(),
+ sessionIdPushdown: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter.'
+ ),
+ sessionPropertyPreAggregation: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown\/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`).'
+ ),
+ sessionTableVersion: zod.union([zod.enum(['auto', 'v1', 'v2', 'v3']), zod.null()]).optional(),
+ sessionsV2JoinMode: zod.union([zod.enum(['string', 'uuid']), zod.null()]).optional(),
+ timings: zod.union([zod.boolean(), zod.null()]).optional(),
+ typeAwareCastSimplification: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types'
+ ),
+ useMaterializedViews: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedIntermediateResults: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedTableTransforms: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Try to automatically convert HogQL queries to use preaggregated tables at the AST level \*'
+ ),
+ useWebAnalyticsPreAggregatedTables: zod.union([zod.boolean(), zod.null()]).optional(),
+ webAnalyticsFirstPageviewFilters: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_\*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ ),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone."
+ ),
timezone: zod
.string()
.nullish()
@@ -940,6 +1163,229 @@ export const BatchExportsPartialUpdateBody = () => zod
.describe(
"HogQL SELECT query. With model 'hogql', its results are the data exported by every run. The query may reference the {data_interval_start} and {data_interval_end} placeholders, replaced with each run's data interval bounds, for example: WHERE timestamp >= {data_interval_start} AND timestamp < {data_interval_end}. Without them every run exports all rows the query returns. With model 'events', it defines a custom schema of columns to export instead. Required when model is 'hogql'."
),
+ hogql_modifiers: zod
+ .union([
+ zod.object({
+ bounceRateDurationSeconds: zod.union([zod.number(), zod.null()]).optional(),
+ bounceRatePageViewMode: zod
+ .union([
+ zod.enum(['count_pageviews', 'uniq_urls', 'uniq_page_screen_autocaptures']),
+ zod.null(),
+ ])
+ .optional(),
+ convertToProjectTimezone: zod.union([zod.boolean(), zod.null()]).optional(),
+ cookielessTrafficIsRegular: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients.'
+ ),
+ customBotDefinitions: zod
+ .union([
+ zod.array(
+ zod.object({
+ category: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe('Reported by `$virt_traffic_category`. Defaults to `custom`.'),
+ combiner: zod
+ .enum(['AND', 'OR'])
+ .describe('Whether every condition must match (AND) or any one of them (OR).'),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod
+ .enum([
+ '$raw_user_agent',
+ '$ip',
+ '$lib',
+ '$host',
+ '$pathname',
+ '$current_url',
+ '$browser',
+ '$os',
+ '$browser_language',
+ '$screen_width',
+ '$screen_height',
+ '$geoip_country_code',
+ '$referrer',
+ '$referring_domain',
+ ])
+ .describe('The event property this condition reads.'),
+ matcher: zod.enum(['contains', 'regex', 'exact', 'cidr']),
+ pattern: zod
+ .string()
+ .describe('Matched against the property named by `key`.'),
+ })
+ ),
+ name: zod
+ .string()
+ .describe(
+ 'Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.'
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ customChannelTypeRules: zod
+ .union([
+ zod.array(
+ zod.object({
+ channel_type: zod.string(),
+ combiner: zod.enum(['AND', 'OR']),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod.enum([
+ 'utm_source',
+ 'utm_medium',
+ 'utm_campaign',
+ 'referring_domain',
+ 'url',
+ 'pathname',
+ 'hostname',
+ ]),
+ op: zod.enum([
+ 'exact',
+ 'is_not',
+ 'is_set',
+ 'is_not_set',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ dataWarehouseEventsModifiers: zod
+ .union([
+ zod.array(
+ zod.object({
+ distinct_id_field: zod.string(),
+ id_field: zod.string(),
+ table_name: zod.string(),
+ timestamp_field: zod.string(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ debug: zod.union([zod.boolean(), zod.null()]).optional(),
+ forceClickhouseDataSkippingIndexes: zod
+ .union([zod.array(zod.string()), zod.null()])
+ .optional()
+ .describe('If these are provided, the query will fail if these skip indexes are not used'),
+ formatCsvAllowDoubleQuotes: zod.union([zod.boolean(), zod.null()]).optional(),
+ inCohortVia: zod
+ .union([zod.enum(['auto', 'leftjoin', 'subquery', 'leftjoin_conjoined']), zod.null()])
+ .optional(),
+ inlineCohortCalculation: zod.union([zod.enum(['off', 'auto', 'always']), zod.null()]).optional(),
+ materializationMode: zod
+ .union([
+ zod.enum(['auto', 'legacy_null_as_string', 'legacy_null_as_null', 'disabled']),
+ zod.null(),
+ ])
+ .optional(),
+ materializedColumnsOptimizationMode: zod
+ .union([zod.enum(['disabled', 'optimized']), zod.null()])
+ .optional(),
+ mergeFederatedAggregateJoins: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap'
+ ),
+ optimizeJoinedFilters: zod.union([zod.boolean(), zod.null()]).optional(),
+ optimizeProjections: zod.union([zod.boolean(), zod.null()]).optional(),
+ parserMode: zod
+ .union([
+ zod.enum([
+ 'cpp_only',
+ 'cpp_with_rust_shadow',
+ 'cpp_with_rust_py_shadow',
+ 'rust_with_cpp_shadow',
+ 'rust_only',
+ 'rust_py_only',
+ 'rust_py_with_cpp_shadow',
+ ]),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ '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.'
+ ),
+ personsArgMaxVersion: zod.union([zod.enum(['auto', 'v1', 'v2']), zod.null()]).optional(),
+ personsJoinMode: zod.union([zod.enum(['inner', 'left']), zod.null()]).optional(),
+ personsOnEventsMode: zod
+ .union([
+ zod.enum([
+ 'disabled',
+ 'person_id_no_override_properties_on_events',
+ 'person_id_override_properties_on_events',
+ 'person_id_override_properties_joined',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ propertyGroupsMode: zod
+ .union([zod.enum(['enabled', 'disabled', 'optimized']), zod.null()])
+ .optional(),
+ pushDownPredicates: zod.union([zod.boolean(), zod.null()]).optional(),
+ s3TableUseInvalidColumns: zod.union([zod.boolean(), zod.null()]).optional(),
+ sessionIdPushdown: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter.'
+ ),
+ sessionPropertyPreAggregation: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown\/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`).'
+ ),
+ sessionTableVersion: zod.union([zod.enum(['auto', 'v1', 'v2', 'v3']), zod.null()]).optional(),
+ sessionsV2JoinMode: zod.union([zod.enum(['string', 'uuid']), zod.null()]).optional(),
+ timings: zod.union([zod.boolean(), zod.null()]).optional(),
+ typeAwareCastSimplification: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types'
+ ),
+ useMaterializedViews: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedIntermediateResults: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedTableTransforms: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Try to automatically convert HogQL queries to use preaggregated tables at the AST level \*'
+ ),
+ useWebAnalyticsPreAggregatedTables: zod.union([zod.boolean(), zod.null()]).optional(),
+ webAnalyticsFirstPageviewFilters: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_\*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ ),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone."
+ ),
timezone: zod
.string()
.nullish()
@@ -1151,6 +1597,226 @@ export const FileDownloadBatchExportsCreateBody = () => zod.union([
.describe(
'HogQL SELECT query whose results are exported. This model is in closed beta and is enabled per team; when it is not enabled, the request fails with a permission error that names HogQL batch exports. Contact PostHog support to request access. The query may reference the {data_interval_start} and {data_interval_end} placeholders. Provide a value for each placeholder the query references; missing referenced bounds are rejected, not inferred. When both bounds are supplied, they must span at most seven days. Neither supplied bound may be in the future. Without placeholders, the query runs unchanged, even if bounds are supplied. Every column in the SELECT clause must be a field or have an alias. It is recommended to limit the query with a WHERE clause, for example bounding timestamp on the events table, both to avoid exporting more rows than expected and because user queries run under stricter resource limits than the other models.'
),
+ hogql_modifiers: zod
+ .object({
+ bounceRateDurationSeconds: zod.union([zod.number(), zod.null()]).optional(),
+ bounceRatePageViewMode: zod
+ .union([
+ zod.enum(['count_pageviews', 'uniq_urls', 'uniq_page_screen_autocaptures']),
+ zod.null(),
+ ])
+ .optional(),
+ convertToProjectTimezone: zod.union([zod.boolean(), zod.null()]).optional(),
+ cookielessTrafficIsRegular: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients.'
+ ),
+ customBotDefinitions: zod
+ .union([
+ zod.array(
+ zod.object({
+ category: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe('Reported by `$virt_traffic_category`. Defaults to `custom`.'),
+ combiner: zod
+ .enum(['AND', 'OR'])
+ .describe('Whether every condition must match (AND) or any one of them (OR).'),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod
+ .enum([
+ '$raw_user_agent',
+ '$ip',
+ '$lib',
+ '$host',
+ '$pathname',
+ '$current_url',
+ '$browser',
+ '$os',
+ '$browser_language',
+ '$screen_width',
+ '$screen_height',
+ '$geoip_country_code',
+ '$referrer',
+ '$referring_domain',
+ ])
+ .describe('The event property this condition reads.'),
+ matcher: zod.enum(['contains', 'regex', 'exact', 'cidr']),
+ pattern: zod
+ .string()
+ .describe('Matched against the property named by `key`.'),
+ })
+ ),
+ name: zod
+ .string()
+ .describe(
+ 'Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.'
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ customChannelTypeRules: zod
+ .union([
+ zod.array(
+ zod.object({
+ channel_type: zod.string(),
+ combiner: zod.enum(['AND', 'OR']),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod.enum([
+ 'utm_source',
+ 'utm_medium',
+ 'utm_campaign',
+ 'referring_domain',
+ 'url',
+ 'pathname',
+ 'hostname',
+ ]),
+ op: zod.enum([
+ 'exact',
+ 'is_not',
+ 'is_set',
+ 'is_not_set',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ dataWarehouseEventsModifiers: zod
+ .union([
+ zod.array(
+ zod.object({
+ distinct_id_field: zod.string(),
+ id_field: zod.string(),
+ table_name: zod.string(),
+ timestamp_field: zod.string(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ debug: zod.union([zod.boolean(), zod.null()]).optional(),
+ forceClickhouseDataSkippingIndexes: zod
+ .union([zod.array(zod.string()), zod.null()])
+ .optional()
+ .describe('If these are provided, the query will fail if these skip indexes are not used'),
+ formatCsvAllowDoubleQuotes: zod.union([zod.boolean(), zod.null()]).optional(),
+ inCohortVia: zod
+ .union([zod.enum(['auto', 'leftjoin', 'subquery', 'leftjoin_conjoined']), zod.null()])
+ .optional(),
+ inlineCohortCalculation: zod.union([zod.enum(['off', 'auto', 'always']), zod.null()]).optional(),
+ materializationMode: zod
+ .union([
+ zod.enum(['auto', 'legacy_null_as_string', 'legacy_null_as_null', 'disabled']),
+ zod.null(),
+ ])
+ .optional(),
+ materializedColumnsOptimizationMode: zod
+ .union([zod.enum(['disabled', 'optimized']), zod.null()])
+ .optional(),
+ mergeFederatedAggregateJoins: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap'
+ ),
+ optimizeJoinedFilters: zod.union([zod.boolean(), zod.null()]).optional(),
+ optimizeProjections: zod.union([zod.boolean(), zod.null()]).optional(),
+ parserMode: zod
+ .union([
+ zod.enum([
+ 'cpp_only',
+ 'cpp_with_rust_shadow',
+ 'cpp_with_rust_py_shadow',
+ 'rust_with_cpp_shadow',
+ 'rust_only',
+ 'rust_py_only',
+ 'rust_py_with_cpp_shadow',
+ ]),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ '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.'
+ ),
+ personsArgMaxVersion: zod.union([zod.enum(['auto', 'v1', 'v2']), zod.null()]).optional(),
+ personsJoinMode: zod.union([zod.enum(['inner', 'left']), zod.null()]).optional(),
+ personsOnEventsMode: zod
+ .union([
+ zod.enum([
+ 'disabled',
+ 'person_id_no_override_properties_on_events',
+ 'person_id_override_properties_on_events',
+ 'person_id_override_properties_joined',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ propertyGroupsMode: zod
+ .union([zod.enum(['enabled', 'disabled', 'optimized']), zod.null()])
+ .optional(),
+ pushDownPredicates: zod.union([zod.boolean(), zod.null()]).optional(),
+ s3TableUseInvalidColumns: zod.union([zod.boolean(), zod.null()]).optional(),
+ sessionIdPushdown: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter.'
+ ),
+ sessionPropertyPreAggregation: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown\/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`).'
+ ),
+ sessionTableVersion: zod.union([zod.enum(['auto', 'v1', 'v2', 'v3']), zod.null()]).optional(),
+ sessionsV2JoinMode: zod.union([zod.enum(['string', 'uuid']), zod.null()]).optional(),
+ timings: zod.union([zod.boolean(), zod.null()]).optional(),
+ typeAwareCastSimplification: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types'
+ ),
+ useMaterializedViews: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedIntermediateResults: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedTableTransforms: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Try to automatically convert HogQL queries to use preaggregated tables at the AST level \*'
+ ),
+ useWebAnalyticsPreAggregatedTables: zod.union([zod.boolean(), zod.null()]).optional(),
+ webAnalyticsFirstPageviewFilters: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_\*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ ),
+ })
+ .optional()
+ .describe(
+ "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone."
+ ),
data_interval_start: zod.iso
.datetime({ offset: true })
.optional()
@@ -1217,6 +1883,216 @@ export const FileDownloadBatchExportsCountRowsCreateBody = () => zod
.describe(
'HogQL SELECT query whose results are exported. This model is in closed beta and is enabled per team; when it is not enabled, the request fails with a permission error that names HogQL batch exports. Contact PostHog support to request access. The query may reference the {data_interval_start} and {data_interval_end} placeholders. Provide a value for each placeholder the query references; missing referenced bounds are rejected, not inferred. When both bounds are supplied, they must span at most seven days. Neither supplied bound may be in the future. Without placeholders, the query runs unchanged, even if bounds are supplied. Every column in the SELECT clause must be a field or have an alias. It is recommended to limit the query with a WHERE clause, for example bounding timestamp on the events table, both to avoid exporting more rows than expected and because user queries run under stricter resource limits than the other models.'
),
+ hogql_modifiers: zod
+ .object({
+ bounceRateDurationSeconds: zod.union([zod.number(), zod.null()]).optional(),
+ bounceRatePageViewMode: zod
+ .union([zod.enum(['count_pageviews', 'uniq_urls', 'uniq_page_screen_autocaptures']), zod.null()])
+ .optional(),
+ convertToProjectTimezone: zod.union([zod.boolean(), zod.null()]).optional(),
+ cookielessTrafficIsRegular: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients.'
+ ),
+ customBotDefinitions: zod
+ .union([
+ zod.array(
+ zod.object({
+ category: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe('Reported by `$virt_traffic_category`. Defaults to `custom`.'),
+ combiner: zod
+ .enum(['AND', 'OR'])
+ .describe('Whether every condition must match (AND) or any one of them (OR).'),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod
+ .enum([
+ '$raw_user_agent',
+ '$ip',
+ '$lib',
+ '$host',
+ '$pathname',
+ '$current_url',
+ '$browser',
+ '$os',
+ '$browser_language',
+ '$screen_width',
+ '$screen_height',
+ '$geoip_country_code',
+ '$referrer',
+ '$referring_domain',
+ ])
+ .describe('The event property this condition reads.'),
+ matcher: zod.enum(['contains', 'regex', 'exact', 'cidr']),
+ pattern: zod.string().describe('Matched against the property named by `key`.'),
+ })
+ ),
+ name: zod
+ .string()
+ .describe(
+ 'Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.'
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ customChannelTypeRules: zod
+ .union([
+ zod.array(
+ zod.object({
+ channel_type: zod.string(),
+ combiner: zod.enum(['AND', 'OR']),
+ id: zod.string(),
+ items: zod.array(
+ zod.object({
+ id: zod.string(),
+ key: zod.enum([
+ 'utm_source',
+ 'utm_medium',
+ 'utm_campaign',
+ 'referring_domain',
+ 'url',
+ 'pathname',
+ 'hostname',
+ ]),
+ op: zod.enum([
+ 'exact',
+ 'is_not',
+ 'is_set',
+ 'is_not_set',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ dataWarehouseEventsModifiers: zod
+ .union([
+ zod.array(
+ zod.object({
+ distinct_id_field: zod.string(),
+ id_field: zod.string(),
+ table_name: zod.string(),
+ timestamp_field: zod.string(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ debug: zod.union([zod.boolean(), zod.null()]).optional(),
+ forceClickhouseDataSkippingIndexes: zod
+ .union([zod.array(zod.string()), zod.null()])
+ .optional()
+ .describe('If these are provided, the query will fail if these skip indexes are not used'),
+ formatCsvAllowDoubleQuotes: zod.union([zod.boolean(), zod.null()]).optional(),
+ inCohortVia: zod
+ .union([zod.enum(['auto', 'leftjoin', 'subquery', 'leftjoin_conjoined']), zod.null()])
+ .optional(),
+ inlineCohortCalculation: zod.union([zod.enum(['off', 'auto', 'always']), zod.null()]).optional(),
+ materializationMode: zod
+ .union([zod.enum(['auto', 'legacy_null_as_string', 'legacy_null_as_null', 'disabled']), zod.null()])
+ .optional(),
+ materializedColumnsOptimizationMode: zod
+ .union([zod.enum(['disabled', 'optimized']), zod.null()])
+ .optional(),
+ mergeFederatedAggregateJoins: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap'
+ ),
+ optimizeJoinedFilters: zod.union([zod.boolean(), zod.null()]).optional(),
+ optimizeProjections: zod.union([zod.boolean(), zod.null()]).optional(),
+ parserMode: zod
+ .union([
+ zod.enum([
+ 'cpp_only',
+ 'cpp_with_rust_shadow',
+ 'cpp_with_rust_py_shadow',
+ 'rust_with_cpp_shadow',
+ 'rust_only',
+ 'rust_py_only',
+ 'rust_py_with_cpp_shadow',
+ ]),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ '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.'
+ ),
+ personsArgMaxVersion: zod.union([zod.enum(['auto', 'v1', 'v2']), zod.null()]).optional(),
+ personsJoinMode: zod.union([zod.enum(['inner', 'left']), zod.null()]).optional(),
+ personsOnEventsMode: zod
+ .union([
+ zod.enum([
+ 'disabled',
+ 'person_id_no_override_properties_on_events',
+ 'person_id_override_properties_on_events',
+ 'person_id_override_properties_joined',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ propertyGroupsMode: zod.union([zod.enum(['enabled', 'disabled', 'optimized']), zod.null()]).optional(),
+ pushDownPredicates: zod.union([zod.boolean(), zod.null()]).optional(),
+ s3TableUseInvalidColumns: zod.union([zod.boolean(), zod.null()]).optional(),
+ sessionIdPushdown: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter.'
+ ),
+ sessionPropertyPreAggregation: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown\/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`).'
+ ),
+ sessionTableVersion: zod.union([zod.enum(['auto', 'v1', 'v2', 'v3']), zod.null()]).optional(),
+ sessionsV2JoinMode: zod.union([zod.enum(['string', 'uuid']), zod.null()]).optional(),
+ timings: zod.union([zod.boolean(), zod.null()]).optional(),
+ typeAwareCastSimplification: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types'
+ ),
+ useMaterializedViews: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedIntermediateResults: zod.union([zod.boolean(), zod.null()]).optional(),
+ usePreaggregatedTableTransforms: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ 'Try to automatically convert HogQL queries to use preaggregated tables at the AST level \*'
+ ),
+ useWebAnalyticsPreAggregatedTables: zod.union([zod.boolean(), zod.null()]).optional(),
+ webAnalyticsFirstPageviewFilters: zod
+ .union([zod.boolean(), zod.null()])
+ .optional()
+ .describe(
+ "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_\*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ ),
+ })
+ .optional()
+ .describe(
+ "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone."
+ ),
data_interval_start: zod.iso
.datetime({ offset: true })
.optional()
diff --git a/services/mcp/src/tools/generated/batch_exports.ts b/services/mcp/src/tools/generated/batch_exports.ts
index c724301559f7..6166efa3527c 100644
--- a/services/mcp/src/tools/generated/batch_exports.ts
+++ b/services/mcp/src/tools/generated/batch_exports.ts
@@ -35,6 +35,9 @@ const batchExportCreate = (): ToolBase<ReturnType<typeof BatchExportCreateSchema
if (params.hogql_query !== undefined) {
body['hogql_query'] = params.hogql_query
}
+ if (params.hogql_modifiers !== undefined) {
+ body['hogql_modifiers'] = params.hogql_modifiers
+ }
if (params.timezone !== undefined) {
body['timezone'] = params.timezone
}
@@ -119,6 +122,9 @@ const batchExportUpdate = (): ToolBase<ReturnType<typeof BatchExportUpdateSchema
if (params.hogql_query !== undefined) {
body['hogql_query'] = params.hogql_query
}
+ if (params.hogql_modifiers !== undefined) {
+ body['hogql_modifiers'] = params.hogql_modifiers
+ }
if (params.timezone !== undefined) {
body['timezone'] = params.timezone
}
@@ -226,6 +232,9 @@ const fileDownloadBatchExportsCountRowsCreate = (): ToolBase<
if (params.hogql_query !== undefined) {
body['hogql_query'] = params.hogql_query
}
+ if (params.hogql_modifiers !== undefined) {
+ body['hogql_modifiers'] = params.hogql_modifiers
+ }
if (params.data_interval_start !== undefined) {
body['data_interval_start'] = params.data_interval_start
}
@@ -276,6 +285,9 @@ const fileDownloadBatchExportsCreate = (): ToolBase<
if ('hogql_query' in params && params.hogql_query !== undefined) {
body['hogql_query'] = params.hogql_query
}
+ if ('hogql_modifiers' in params && params.hogql_modifiers !== undefined) {
+ body['hogql_modifiers'] = params.hogql_modifiers
+ }
const result = await context.api.request<unknown>({
method: 'POST',
path: `/api/projects/${encodeURIComponent(String(projectId))}/file_download_batch_exports/`,
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json
index dd2b20273441..70d05643f517 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json
@@ -538,6 +538,562 @@
],
"description": "Destination configuration. Required integration_id is enforced per destination type."
},
+ "hogql_modifiers": {
+ "anyOf": [
+ {
+ "properties": {
+ "bounceRateDurationSeconds": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "bounceRatePageViewMode": {
+ "anyOf": [
+ {
+ "enum": ["count_pageviews", "uniq_urls", "uniq_page_screen_autocaptures"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "convertToProjectTimezone": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "cookielessTrafficIsRegular": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients."
+ },
+ "customBotDefinitions": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "category": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Reported by `$virt_traffic_category`. Defaults to `custom`."
+ },
+ "combiner": {
+ "description": "Whether every condition must match (AND) or any one of them (OR).",
+ "enum": ["AND", "OR"],
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "items": {
+ "items": {
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "key": {
+ "description": "The event property this condition reads.",
+ "enum": [
+ "$raw_user_agent",
+ "$ip",
+ "$lib",
+ "$host",
+ "$pathname",
+ "$current_url",
+ "$browser",
+ "$os",
+ "$browser_language",
+ "$screen_width",
+ "$screen_height",
+ "$geoip_country_code",
+ "$referrer",
+ "$referring_domain"
+ ],
+ "type": "string"
+ },
+ "matcher": {
+ "enum": ["contains", "regex", "exact", "cidr"],
+ "type": "string"
+ },
+ "pattern": {
+ "description": "Matched against the property named by `key`.",
+ "type": "string"
+ }
+ },
+ "required": ["id", "key", "matcher", "pattern"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "name": {
+ "description": "Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.",
+ "type": "string"
+ }
+ },
+ "required": ["combiner", "id", "items", "name"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "customChannelTypeRules": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "channel_type": {
+ "type": "string"
+ },
+ "combiner": {
+ "enum": ["AND", "OR"],
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "items": {
+ "items": {
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "key": {
+ "enum": [
+ "utm_source",
+ "utm_medium",
+ "utm_campaign",
+ "referring_domain",
+ "url",
+ "pathname",
+ "hostname"
+ ],
+ "type": "string"
+ },
+ "op": {
+ "enum": [
+ "exact",
+ "is_not",
+ "is_set",
+ "is_not_set",
+ "icontains",
+ "not_icontains",
+ "regex",
+ "not_regex"
+ ],
+ "type": "string"
+ },
+ "value": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": ["id", "key", "op"],
+ "type": "object"
+ },
+ "type": "array"
+ }
+ },
+ "required": ["channel_type", "combiner", "id", "items"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "dataWarehouseEventsModifiers": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "distinct_id_field": {
+ "type": "string"
+ },
+ "id_field": {
+ "type": "string"
+ },
+ "table_name": {
+ "type": "string"
+ },
+ "timestamp_field": {
+ "type": "string"
+ }
+ },
+ "required": ["distinct_id_field", "id_field", "table_name", "timestamp_field"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "debug": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "forceClickhouseDataSkippingIndexes": {
+ "anyOf": [
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "If these are provided, the query will fail if these skip indexes are not used"
+ },
+ "formatCsvAllowDoubleQuotes": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "inCohortVia": {
+ "anyOf": [
+ {
+ "enum": ["auto", "leftjoin", "subquery", "leftjoin_conjoined"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "inlineCohortCalculation": {
+ "anyOf": [
+ {
+ "enum": ["off", "auto", "always"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "materializationMode": {
+ "anyOf": [
+ {
+ "enum": ["auto", "legacy_null_as_string", "legacy_null_as_null", "disabled"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "materializedColumnsOptimizationMode": {
+ "anyOf": [
+ {
+ "enum": ["disabled", "optimized"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "mergeFederatedAggregateJoins": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap"
+ },
+ "optimizeJoinedFilters": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "optimizeProjections": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "parserMode": {
+ "anyOf": [
+ {
+ "enum": [
+ "cpp_only",
+ "cpp_with_rust_shadow",
+ "cpp_with_rust_py_shadow",
+ "rust_with_cpp_shadow",
+ "rust_only",
+ "rust_py_only",
+ "rust_py_with_cpp_shadow"
+ ],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "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."
+ },
+ "personsArgMaxVersion": {
+ "anyOf": [
+ {
+ "enum": ["auto", "v1", "v2"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "personsJoinMode": {
+ "anyOf": [
+ {
+ "enum": ["inner", "left"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "personsOnEventsMode": {
+ "anyOf": [
+ {
+ "enum": [
+ "disabled",
+ "person_id_no_override_properties_on_events",
+ "person_id_override_properties_on_events",
+ "person_id_override_properties_joined"
+ ],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "propertyGroupsMode": {
+ "anyOf": [
+ {
+ "enum": ["enabled", "disabled", "optimized"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "pushDownPredicates": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "s3TableUseInvalidColumns": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "sessionIdPushdown": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter."
+ },
+ "sessionPropertyPreAggregation": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`)."
+ },
+ "sessionsV2JoinMode": {
+ "anyOf": [
+ {
+ "enum": ["string", "uuid"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "sessionTableVersion": {
+ "anyOf": [
+ {
+ "enum": ["auto", "v1", "v2", "v3"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "timings": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "typeAwareCastSimplification": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types"
+ },
+ "useMaterializedViews": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "usePreaggregatedIntermediateResults": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "usePreaggregatedTableTransforms": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Try to automatically convert HogQL queries to use preaggregated tables at the AST level *"
+ },
+ "useWebAnalyticsPreAggregatedTables": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "webAnalyticsFirstPageviewFilters": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ }
+ },
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone."
+ },
"hogql_query": {
"anyOf": [
{
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json
index f6264d7263d2..b41340116f80 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json
@@ -537,6 +537,562 @@
],
"description": "Destination configuration. Required integration_id is enforced per destination type."
},
+ "hogql_modifiers": {
+ "anyOf": [
+ {
+ "properties": {
+ "bounceRateDurationSeconds": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "bounceRatePageViewMode": {
+ "anyOf": [
+ {
+ "enum": ["count_pageviews", "uniq_urls", "uniq_page_screen_autocaptures"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "convertToProjectTimezone": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "cookielessTrafficIsRegular": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients."
+ },
+ "customBotDefinitions": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "category": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Reported by `$virt_traffic_category`. Defaults to `custom`."
+ },
+ "combiner": {
+ "description": "Whether every condition must match (AND) or any one of them (OR).",
+ "enum": ["AND", "OR"],
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "items": {
+ "items": {
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "key": {
+ "description": "The event property this condition reads.",
+ "enum": [
+ "$raw_user_agent",
+ "$ip",
+ "$lib",
+ "$host",
+ "$pathname",
+ "$current_url",
+ "$browser",
+ "$os",
+ "$browser_language",
+ "$screen_width",
+ "$screen_height",
+ "$geoip_country_code",
+ "$referrer",
+ "$referring_domain"
+ ],
+ "type": "string"
+ },
+ "matcher": {
+ "enum": ["contains", "regex", "exact", "cidr"],
+ "type": "string"
+ },
+ "pattern": {
+ "description": "Matched against the property named by `key`.",
+ "type": "string"
+ }
+ },
+ "required": ["id", "key", "matcher", "pattern"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "name": {
+ "description": "Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.",
+ "type": "string"
+ }
+ },
+ "required": ["combiner", "id", "items", "name"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "customChannelTypeRules": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "channel_type": {
+ "type": "string"
+ },
+ "combiner": {
+ "enum": ["AND", "OR"],
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "items": {
+ "items": {
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "key": {
+ "enum": [
+ "utm_source",
+ "utm_medium",
+ "utm_campaign",
+ "referring_domain",
+ "url",
+ "pathname",
+ "hostname"
+ ],
+ "type": "string"
+ },
+ "op": {
+ "enum": [
+ "exact",
+ "is_not",
+ "is_set",
+ "is_not_set",
+ "icontains",
+ "not_icontains",
+ "regex",
+ "not_regex"
+ ],
+ "type": "string"
+ },
+ "value": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": ["id", "key", "op"],
+ "type": "object"
+ },
+ "type": "array"
+ }
+ },
+ "required": ["channel_type", "combiner", "id", "items"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "dataWarehouseEventsModifiers": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "distinct_id_field": {
+ "type": "string"
+ },
+ "id_field": {
+ "type": "string"
+ },
+ "table_name": {
+ "type": "string"
+ },
+ "timestamp_field": {
+ "type": "string"
+ }
+ },
+ "required": ["distinct_id_field", "id_field", "table_name", "timestamp_field"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "debug": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "forceClickhouseDataSkippingIndexes": {
+ "anyOf": [
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "If these are provided, the query will fail if these skip indexes are not used"
+ },
+ "formatCsvAllowDoubleQuotes": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "inCohortVia": {
+ "anyOf": [
+ {
+ "enum": ["auto", "leftjoin", "subquery", "leftjoin_conjoined"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "inlineCohortCalculation": {
+ "anyOf": [
+ {
+ "enum": ["off", "auto", "always"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "materializationMode": {
+ "anyOf": [
+ {
+ "enum": ["auto", "legacy_null_as_string", "legacy_null_as_null", "disabled"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "materializedColumnsOptimizationMode": {
+ "anyOf": [
+ {
+ "enum": ["disabled", "optimized"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "mergeFederatedAggregateJoins": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap"
+ },
+ "optimizeJoinedFilters": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "optimizeProjections": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "parserMode": {
+ "anyOf": [
+ {
+ "enum": [
+ "cpp_only",
+ "cpp_with_rust_shadow",
+ "cpp_with_rust_py_shadow",
+ "rust_with_cpp_shadow",
+ "rust_only",
+ "rust_py_only",
+ "rust_py_with_cpp_shadow"
+ ],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "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."
+ },
+ "personsArgMaxVersion": {
+ "anyOf": [
+ {
+ "enum": ["auto", "v1", "v2"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "personsJoinMode": {
+ "anyOf": [
+ {
+ "enum": ["inner", "left"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "personsOnEventsMode": {
+ "anyOf": [
+ {
+ "enum": [
+ "disabled",
+ "person_id_no_override_properties_on_events",
+ "person_id_override_properties_on_events",
+ "person_id_override_properties_joined"
+ ],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "propertyGroupsMode": {
+ "anyOf": [
+ {
+ "enum": ["enabled", "disabled", "optimized"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "pushDownPredicates": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "s3TableUseInvalidColumns": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "sessionIdPushdown": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter."
+ },
+ "sessionPropertyPreAggregation": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`)."
+ },
+ "sessionsV2JoinMode": {
+ "anyOf": [
+ {
+ "enum": ["string", "uuid"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "sessionTableVersion": {
+ "anyOf": [
+ {
+ "enum": ["auto", "v1", "v2", "v3"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "timings": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "typeAwareCastSimplification": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types"
+ },
+ "useMaterializedViews": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "usePreaggregatedIntermediateResults": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "usePreaggregatedTableTransforms": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Try to automatically convert HogQL queries to use preaggregated tables at the AST level *"
+ },
+ "useWebAnalyticsPreAggregatedTables": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "webAnalyticsFirstPageviewFilters": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ }
+ },
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone."
+ },
"hogql_query": {
"anyOf": [
{
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/file-download-batch-exports-count-rows-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/file-download-batch-exports-count-rows-create.json
index 5699f9e6233a..cdf89261024d 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/file-download-batch-exports-count-rows-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/file-download-batch-exports-count-rows-create.json
@@ -14,6 +14,555 @@
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
"type": "string"
},
+ "hogql_modifiers": {
+ "description": "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone.",
+ "properties": {
+ "bounceRateDurationSeconds": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "bounceRatePageViewMode": {
+ "anyOf": [
+ {
+ "enum": ["count_pageviews", "uniq_urls", "uniq_page_screen_autocaptures"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "convertToProjectTimezone": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "cookielessTrafficIsRegular": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients."
+ },
+ "customBotDefinitions": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "category": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Reported by `$virt_traffic_category`. Defaults to `custom`."
+ },
+ "combiner": {
+ "description": "Whether every condition must match (AND) or any one of them (OR).",
+ "enum": ["AND", "OR"],
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "items": {
+ "items": {
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "key": {
+ "description": "The event property this condition reads.",
+ "enum": [
+ "$raw_user_agent",
+ "$ip",
+ "$lib",
+ "$host",
+ "$pathname",
+ "$current_url",
+ "$browser",
+ "$os",
+ "$browser_language",
+ "$screen_width",
+ "$screen_height",
+ "$geoip_country_code",
+ "$referrer",
+ "$referring_domain"
+ ],
+ "type": "string"
+ },
+ "matcher": {
+ "enum": ["contains", "regex", "exact", "cidr"],
+ "type": "string"
+ },
+ "pattern": {
+ "description": "Matched against the property named by `key`.",
+ "type": "string"
+ }
+ },
+ "required": ["id", "key", "matcher", "pattern"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "name": {
+ "description": "Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.",
+ "type": "string"
+ }
+ },
+ "required": ["combiner", "id", "items", "name"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "customChannelTypeRules": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "channel_type": {
+ "type": "string"
+ },
+ "combiner": {
+ "enum": ["AND", "OR"],
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "items": {
+ "items": {
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "key": {
+ "enum": [
+ "utm_source",
+ "utm_medium",
+ "utm_campaign",
+ "referring_domain",
+ "url",
+ "pathname",
+ "hostname"
+ ],
+ "type": "string"
+ },
+ "op": {
+ "enum": [
+ "exact",
+ "is_not",
+ "is_set",
+ "is_not_set",
+ "icontains",
+ "not_icontains",
+ "regex",
+ "not_regex"
+ ],
+ "type": "string"
+ },
+ "value": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": ["id", "key", "op"],
+ "type": "object"
+ },
+ "type": "array"
+ }
+ },
+ "required": ["channel_type", "combiner", "id", "items"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "dataWarehouseEventsModifiers": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "distinct_id_field": {
+ "type": "string"
+ },
+ "id_field": {
+ "type": "string"
+ },
+ "table_name": {
+ "type": "string"
+ },
+ "timestamp_field": {
+ "type": "string"
+ }
+ },
+ "required": ["distinct_id_field", "id_field", "table_name", "timestamp_field"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "debug": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "forceClickhouseDataSkippingIndexes": {
+ "anyOf": [
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "If these are provided, the query will fail if these skip indexes are not used"
+ },
+ "formatCsvAllowDoubleQuotes": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "inCohortVia": {
+ "anyOf": [
+ {
+ "enum": ["auto", "leftjoin", "subquery", "leftjoin_conjoined"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "inlineCohortCalculation": {
+ "anyOf": [
+ {
+ "enum": ["off", "auto", "always"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "materializationMode": {
+ "anyOf": [
+ {
+ "enum": ["auto", "legacy_null_as_string", "legacy_null_as_null", "disabled"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "materializedColumnsOptimizationMode": {
+ "anyOf": [
+ {
+ "enum": ["disabled", "optimized"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "mergeFederatedAggregateJoins": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap"
+ },
+ "optimizeJoinedFilters": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "optimizeProjections": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "parserMode": {
+ "anyOf": [
+ {
+ "enum": [
+ "cpp_only",
+ "cpp_with_rust_shadow",
+ "cpp_with_rust_py_shadow",
+ "rust_with_cpp_shadow",
+ "rust_only",
+ "rust_py_only",
+ "rust_py_with_cpp_shadow"
+ ],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "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."
+ },
+ "personsArgMaxVersion": {
+ "anyOf": [
+ {
+ "enum": ["auto", "v1", "v2"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "personsJoinMode": {
+ "anyOf": [
+ {
+ "enum": ["inner", "left"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "personsOnEventsMode": {
+ "anyOf": [
+ {
+ "enum": [
+ "disabled",
+ "person_id_no_override_properties_on_events",
+ "person_id_override_properties_on_events",
+ "person_id_override_properties_joined"
+ ],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "propertyGroupsMode": {
+ "anyOf": [
+ {
+ "enum": ["enabled", "disabled", "optimized"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "pushDownPredicates": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "s3TableUseInvalidColumns": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "sessionIdPushdown": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter."
+ },
+ "sessionPropertyPreAggregation": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`)."
+ },
+ "sessionsV2JoinMode": {
+ "anyOf": [
+ {
+ "enum": ["string", "uuid"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "sessionTableVersion": {
+ "anyOf": [
+ {
+ "enum": ["auto", "v1", "v2", "v3"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "timings": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "typeAwareCastSimplification": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types"
+ },
+ "useMaterializedViews": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "usePreaggregatedIntermediateResults": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "usePreaggregatedTableTransforms": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Try to automatically convert HogQL queries to use preaggregated tables at the AST level *"
+ },
+ "useWebAnalyticsPreAggregatedTables": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "webAnalyticsFirstPageviewFilters": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ }
+ },
+ "type": "object"
+ },
"hogql_query": {
"description": "HogQL SELECT query whose results are exported. This model is in closed beta and is enabled per team; when it is not enabled, the request fails with a permission error that names HogQL batch exports. Contact PostHog support to request access. The query may reference the {data_interval_start} and {data_interval_end} placeholders. Provide a value for each placeholder the query references; missing referenced bounds are rejected, not inferred. When both bounds are supplied, they must span at most seven days. Neither supplied bound may be in the future. Without placeholders, the query runs unchanged, even if bounds are supplied. Every column in the SELECT clause must be a field or have an alias. It is recommended to limit the query with a WHERE clause, for example bounding timestamp on the events table, both to avoid exporting more rows than expected and because user queries run under stricter resource limits than the other models.",
"type": "string"
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/file-download-batch-exports-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/file-download-batch-exports-create.json
index 85ae006a8024..c508e7cc54d3 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/file-download-batch-exports-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/file-download-batch-exports-create.json
@@ -243,6 +243,555 @@
},
"type": "object"
},
+ "hogql_modifiers": {
+ "description": "HogQL modifiers to use when the query runs. Only supported when 'model' is 'hogql'. Each modifier set here overrides the project modifier with the same name, and the project modifiers apply to all others. For example, set convertToProjectTimezone to false to export timestamps in UTC instead of the project timezone.",
+ "properties": {
+ "bounceRateDurationSeconds": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "bounceRatePageViewMode": {
+ "anyOf": [
+ {
+ "enum": ["count_pageviews", "uniq_urls", "uniq_page_screen_autocaptures"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "convertToProjectTimezone": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "cookielessTrafficIsRegular": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Do not treat a missing user agent as automation on cookieless events. Positive bot signals and custom project rules still apply. Resolved server-side; not intended to be set by clients."
+ },
+ "customBotDefinitions": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "category": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Reported by `$virt_traffic_category`. Defaults to `custom`."
+ },
+ "combiner": {
+ "description": "Whether every condition must match (AND) or any one of them (OR).",
+ "enum": ["AND", "OR"],
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "items": {
+ "items": {
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "key": {
+ "description": "The event property this condition reads.",
+ "enum": [
+ "$raw_user_agent",
+ "$ip",
+ "$lib",
+ "$host",
+ "$pathname",
+ "$current_url",
+ "$browser",
+ "$os",
+ "$browser_language",
+ "$screen_width",
+ "$screen_height",
+ "$geoip_country_code",
+ "$referrer",
+ "$referring_domain"
+ ],
+ "type": "string"
+ },
+ "matcher": {
+ "enum": ["contains", "regex", "exact", "cidr"],
+ "type": "string"
+ },
+ "pattern": {
+ "description": "Matched against the property named by `key`.",
+ "type": "string"
+ }
+ },
+ "required": ["id", "key", "matcher", "pattern"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "name": {
+ "description": "Reported by `$virt_bot_name` and `$virt_bot_operator` when the rule matches.",
+ "type": "string"
+ }
+ },
+ "required": ["combiner", "id", "items", "name"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "customChannelTypeRules": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "channel_type": {
+ "type": "string"
+ },
+ "combiner": {
+ "enum": ["AND", "OR"],
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "items": {
+ "items": {
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "key": {
+ "enum": [
+ "utm_source",
+ "utm_medium",
+ "utm_campaign",
+ "referring_domain",
+ "url",
+ "pathname",
+ "hostname"
+ ],
+ "type": "string"
+ },
+ "op": {
+ "enum": [
+ "exact",
+ "is_not",
+ "is_set",
+ "is_not_set",
+ "icontains",
+ "not_icontains",
+ "regex",
+ "not_regex"
+ ],
+ "type": "string"
+ },
+ "value": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": ["id", "key", "op"],
+ "type": "object"
+ },
+ "type": "array"
+ }
+ },
+ "required": ["channel_type", "combiner", "id", "items"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "dataWarehouseEventsModifiers": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "distinct_id_field": {
+ "type": "string"
+ },
+ "id_field": {
+ "type": "string"
+ },
+ "table_name": {
+ "type": "string"
+ },
+ "timestamp_field": {
+ "type": "string"
+ }
+ },
+ "required": ["distinct_id_field", "id_field", "table_name", "timestamp_field"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "debug": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "forceClickhouseDataSkippingIndexes": {
+ "anyOf": [
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "If these are provided, the query will fail if these skip indexes are not used"
+ },
+ "formatCsvAllowDoubleQuotes": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "inCohortVia": {
+ "anyOf": [
+ {
+ "enum": ["auto", "leftjoin", "subquery", "leftjoin_conjoined"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "inlineCohortCalculation": {
+ "anyOf": [
+ {
+ "enum": ["off", "auto", "always"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "materializationMode": {
+ "anyOf": [
+ {
+ "enum": ["auto", "legacy_null_as_string", "legacy_null_as_null", "disabled"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "materializedColumnsOptimizationMode": {
+ "anyOf": [
+ {
+ "enum": ["disabled", "optimized"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "mergeFederatedAggregateJoins": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Merge sibling aggregating LEFT JOINs over federated Postgres tables into one UNION ALL join, so their scans overlap"
+ },
+ "optimizeJoinedFilters": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "optimizeProjections": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "parserMode": {
+ "anyOf": [
+ {
+ "enum": [
+ "cpp_only",
+ "cpp_with_rust_shadow",
+ "cpp_with_rust_py_shadow",
+ "rust_with_cpp_shadow",
+ "rust_only",
+ "rust_py_only",
+ "rust_py_with_cpp_shadow"
+ ],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "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."
+ },
+ "personsArgMaxVersion": {
+ "anyOf": [
+ {
+ "enum": ["auto", "v1", "v2"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "personsJoinMode": {
+ "anyOf": [
+ {
+ "enum": ["inner", "left"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "personsOnEventsMode": {
+ "anyOf": [
+ {
+ "enum": [
+ "disabled",
+ "person_id_no_override_properties_on_events",
+ "person_id_override_properties_on_events",
+ "person_id_override_properties_joined"
+ ],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "propertyGroupsMode": {
+ "anyOf": [
+ {
+ "enum": ["enabled", "disabled", "optimized"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "pushDownPredicates": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "s3TableUseInvalidColumns": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "sessionIdPushdown": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Push a `session_id_v7 IN (SELECT … FROM events WHERE …)` predicate into the raw_sessions subquery to limit aggregation to sessions that participate in the outer events filter."
+ },
+ "sessionPropertyPreAggregation": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Pre-filter raw_sessions aggregation by `session_id_v7 IN (cheap pre-aggregation that only materializes the columns referenced by the outer-WHERE session predicate)`. Useful when the breakdown/SELECT pulls in many session columns (e.g. `$channel_type`) but the filter only references one (e.g. `$entry_current_url`)."
+ },
+ "sessionsV2JoinMode": {
+ "anyOf": [
+ {
+ "enum": ["string", "uuid"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "sessionTableVersion": {
+ "anyOf": [
+ {
+ "enum": ["auto", "v1", "v2", "v3"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "timings": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "typeAwareCastSimplification": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Remove provably redundant casts and nullability wrappers (e.g. `toString(String)`, `assumeNotNull(non_nullable)`, dead `ifNull` fallbacks) using inferred expression types"
+ },
+ "useMaterializedViews": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "usePreaggregatedIntermediateResults": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "usePreaggregatedTableTransforms": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Try to automatically convert HogQL queries to use preaggregated tables at the AST level *"
+ },
+ "useWebAnalyticsPreAggregatedTables": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "webAnalyticsFirstPageviewFilters": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Serve filters on the stored session-entry attribution properties (`$channel_type`, `$entry_utm_*`, `$entry_referring_domain`) by recomputing the value from the session's first pageview. Resolved server-side; not intended to be set by clients."
+ }
+ },
+ "type": "object"
+ },
"hogql_query": {
"description": "HogQL SELECT query whose results are exported. This model is in closed beta and is enabled per team; when it is not enabled, the request fails with a permission error that names HogQL batch exports. Contact PostHog support to request access. The query may reference the {data_interval_start} and {data_interval_end} placeholders. Provide a value for each placeholder the query references; missing referenced bounds are rejected, not inferred. When both bounds are supplied, they must span at most seven days. Neither supplied bound may be in the future. Without placeholders, the query runs unchanged, even if bounds are supplied. Every column in the SELECT clause must be a field or have an alias. It is recommended to limit the query with a WHERE clause, for example bounding timestamp on the events table, both to avoid exporting more rows than expected and because user queries run under stricter resource limits than the other models.",
"type": "string"