diff --git a/products/cohorts/backend/models/util.py b/products/cohorts/backend/models/util.py index 7ba45a0939c3..bee48a0b5391 100644 --- a/products/cohorts/backend/models/util.py +++ b/products/cohorts/backend/models/util.py @@ -18,7 +18,7 @@ from rest_framework.exceptions import ValidationError from posthog.hogql import ast -from posthog.hogql.constants import HogQLGlobalSettings, LimitContext +from posthog.hogql.constants import HogQLGlobalSettings, LimitContext, get_default_hogql_global_settings from posthog.hogql.hogql import HogQLContext from posthog.hogql.modifiers import create_default_modifiers_for_team from posthog.hogql.parser import parse_select @@ -843,7 +843,7 @@ def execute_query(): cohort_id=cohort.pk, team_id=team.id, ) - hogql_global_settings = HogQLGlobalSettings() + hogql_global_settings = get_default_hogql_global_settings(team_id=team.id) return sync_execute( recalculate_cohortpeople_sql, @@ -854,12 +854,11 @@ def execute_query(): "new_version": pending_version, }, settings={ + **hogql_global_settings.model_dump(exclude_none=True), "max_execution_time": COHORT_QUERY_TIMEOUT_SECONDS, "send_timeout": COHORT_QUERY_TIMEOUT_SECONDS, "receive_timeout": COHORT_QUERY_TIMEOUT_SECONDS, "optimize_on_insert": 0, - "max_ast_elements": hogql_global_settings.max_ast_elements, - "max_expanded_ast_elements": hogql_global_settings.max_expanded_ast_elements, "max_bytes_ratio_before_external_group_by": 0.5, "max_bytes_ratio_before_external_sort": 0.5, },