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(models): Add hogql_modifiers to BatchExportSource (#107650)

Tomás Farías Santana11555d07c46b
diff --git a/products/batch_exports/backend/migrations/0009_batchexportsource_hogql_modifiers.py b/products/batch_exports/backend/migrations/0009_batchexportsource_hogql_modifiers.py
new file mode 100644
index 000000000000..416e3580e306
--- /dev/null
+++ b/products/batch_exports/backend/migrations/0009_batchexportsource_hogql_modifiers.py
@@ -0,0 +1,21 @@
+# Generated by Django 5.2.17 on 2026-09-25 12:58
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("batch_exports", "0008_add_last_updated_by"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="batchexportsource",
+ name="hogql_modifiers",
+ field=models.JSONField(
+ blank=True,
+ help_text="HogQL modifiers used to run the query. They override the team modifiers key by key.",
+ null=True,
+ ),
+ ),
+ ]
diff --git a/products/batch_exports/backend/migrations/max_migration.txt b/products/batch_exports/backend/migrations/max_migration.txt
index eb18429f14bb..8dbef9ea31b7 100644
--- a/products/batch_exports/backend/migrations/max_migration.txt
+++ b/products/batch_exports/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0008_add_last_updated_by
+0009_batchexportsource_hogql_modifiers
diff --git a/products/batch_exports/backend/models/batch_export.py b/products/batch_exports/backend/models/batch_export.py
index 49ed7d9bc12b..9103e3328bb2 100644
--- a/products/batch_exports/backend/models/batch_export.py
+++ b/products/batch_exports/backend/models/batch_export.py
@@ -165,6 +165,11 @@ class BatchExportSource(TeamScopedRootMixin, UUIDTModel):
blank=True,
help_text="The HogQL query whose results are exported.",
)
+ hogql_modifiers = models.JSONField(
+ null=True,
+ blank=True,
+ help_text="HogQL modifiers used to run the query. They override the team modifiers key by key.",
+ )
created_at = models.DateTimeField(
auto_now_add=True,
help_text="The timestamp at which this BatchExportSource was created.",
@@ -519,6 +524,11 @@ class BatchExport(ModelActivityMixin, UUIDTModel):
"""Return the HogQL query of this batch export's source, if it has one."""
return self.source.hogql_query if self.source is not None else None
+ @property
+ def hogql_modifiers(self) -> dict[str, typing.Any] | None:
+ """Return the HogQL modifiers of this batch export's source, if it has any."""
+ return self.source.hogql_modifiers if self.source is not None else None
+
def get_batch_exports_using_integration(team_id: int, integration_id: int) -> list[BatchExport]:
"""Return a list of batch exports using integration_id.