: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(queries): replace the filters cached_property helper (#119085)
Phil Haackc6a9c4ab0456
diff --git a/posthog/hogql_queries/data_warehouse_mixin.py b/posthog/hogql_queries/data_warehouse_mixin.pyindex c35cc4fc5fcc..61a397e7c029 100644--- a/posthog/hogql_queries/data_warehouse_mixin.py+++ b/posthog/hogql_queries/data_warehouse_mixin.py@@ -1,9 +1,9 @@+from functools import cached_property+from posthog.schema import ActionsNode, DataWarehouseNode, EventsNode, GroupNodefrom posthog.hogql import ast-from posthog.models.filters.mixins.utils import cached_property-class DataWarehouseInsightQueryMixin:series: EventsNode | ActionsNode | DataWarehouseNode | GroupNodediff --git a/posthog/hogql_queries/endpoints/endpoints_usage_overview.py b/posthog/hogql_queries/endpoints/endpoints_usage_overview.pyindex 4fbd838f1b8b..c4c26d20a967 100644--- a/posthog/hogql_queries/endpoints/endpoints_usage_overview.py+++ b/posthog/hogql_queries/endpoints/endpoints_usage_overview.py@@ -1,3 +1,5 @@+from functools import cached_property+from posthog.schema import (CachedEndpointsUsageOverviewQueryResponse,EndpointsUsageOverviewItem,@@ -11,7 +13,6 @@ from posthog.hogql.query import execute_hogql_queryfrom posthog.hogql_queries.endpoints.endpoints_usage_query_runner import EndpointsUsageQueryRunnerfrom posthog.hogql_queries.utils.query_previous_period_date_range import QueryPreviousPeriodDateRange-from posthog.models.filters.mixins.utils import cached_propertyclass EndpointsUsageOverviewQueryRunner(EndpointsUsageQueryRunner[EndpointsUsageOverviewQueryResponse]):diff --git a/posthog/hogql_queries/endpoints/endpoints_usage_query_runner.py b/posthog/hogql_queries/endpoints/endpoints_usage_query_runner.pyindex 3884df5f71e4..a74c52305bf0 100644--- a/posthog/hogql_queries/endpoints/endpoints_usage_query_runner.py+++ b/posthog/hogql_queries/endpoints/endpoints_usage_query_runner.py@@ -1,6 +1,7 @@import typingfrom abc import ABCfrom datetime import datetime+from functools import cached_propertyfrom typing import Union, castfrom posthog.schema import EndpointsUsageOverviewQuery, EndpointsUsageTableQuery, EndpointsUsageTrendsQuery@@ -9,7 +10,6 @@ from posthog.hogql import astfrom posthog.hogql_queries.query_runner import AnalyticsQueryResponseProtocol, AnalyticsQueryRunnerfrom posthog.hogql_queries.utils.query_date_range import QueryDateRange-from posthog.models.filters.mixins.utils import cached_propertyEndpointsUsageQueryNode = Union[EndpointsUsageOverviewQuery,diff --git a/posthog/hogql_queries/endpoints/endpoints_usage_trends.py b/posthog/hogql_queries/endpoints/endpoints_usage_trends.pyindex b622cffbcb8c..d8e28471a54e 100644--- a/posthog/hogql_queries/endpoints/endpoints_usage_trends.py+++ b/posthog/hogql_queries/endpoints/endpoints_usage_trends.py@@ -1,4 +1,5 @@from datetime import datetime+from functools import cached_propertyfrom typing import castfrom posthog.schema import (@@ -14,7 +15,6 @@ from posthog.hogql.query import execute_hogql_queryfrom posthog.hogql_queries.endpoints.endpoints_usage_query_runner import EndpointsUsageQueryRunnerfrom posthog.hogql_queries.utils.query_date_range import QueryDateRange-from posthog.models.filters.mixins.utils import cached_propertyclass EndpointsUsageTrendsQueryRunner(EndpointsUsageQueryRunner[EndpointsUsageTrendsQueryResponse]):diff --git a/posthog/hogql_queries/insight_actors_query_options_runner.py b/posthog/hogql_queries/insight_actors_query_options_runner.pyindex 809763365e16..0be97614d6ec 100644--- a/posthog/hogql_queries/insight_actors_query_options_runner.py+++ b/posthog/hogql_queries/insight_actors_query_options_runner.py@@ -1,3 +1,4 @@+from functools import cached_propertyfrom typing import Any, Optional, castfrom posthog.schema import (@@ -13,7 +14,6 @@ from posthog.hogql.timings import HogQLTimingsfrom posthog.hogql_queries.query_runner import QueryRunner, get_query_runner, query_node_modifiersfrom posthog.models import Team-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.models.user import Userfrom products.product_analytics.backend.facade.queries import (diff --git a/posthog/hogql_queries/insight_actors_query_runner.py b/posthog/hogql_queries/insight_actors_query_runner.pyindex 133b97b52582..b9063a7efb32 100644--- a/posthog/hogql_queries/insight_actors_query_runner.py+++ b/posthog/hogql_queries/insight_actors_query_runner.py@@ -1,3 +1,4 @@+from functools import cached_propertyfrom typing import Any, Optional, castfrom posthog.schema import (@@ -26,7 +27,6 @@ from posthog.hogql.timings import HogQLTimingsfrom posthog.hogql_queries.query_runner import AnalyticsQueryRunner, QueryRunner, get_query_runner, query_node_modifiersfrom posthog.models import Team-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.models.user import Userfrom posthog.types import InsightActorsQueryNodediff --git a/posthog/hogql_queries/properties_timeline/properties_timeline.py b/posthog/hogql_queries/properties_timeline/properties_timeline.pyindex 69562c0df963..178ae27d5413 100644--- a/posthog/hogql_queries/properties_timeline/properties_timeline.py+++ b/posthog/hogql_queries/properties_timeline/properties_timeline.py@@ -103,7 +103,7 @@ class PropertiesTimeline:else (property_type == "group" and property_group_type_index == filter.aggregation_group_type_index))- property_filters = filter.property_groups.flat+ property_filters = list(filter.property_groups.flat)for event in filter.entities:property_filters.extend(event.property_groups.flat)all_property_identifiers = extract_tables_and_properties(property_filters, team_id=team_id)diff --git a/posthog/models/filters/mixins/common.py b/posthog/models/filters/mixins/common.pyindex 19d360e07167..3588a5401116 100644--- a/posthog/models/filters/mixins/common.py+++ b/posthog/models/filters/mixins/common.py@@ -1,5 +1,6 @@import jsonimport datetime+from functools import cached_propertyfrom math import ceilfrom typing import Any, Literal, Optional, Unionfrom zoneinfo import ZoneInfo@@ -41,7 +42,7 @@ from posthog.constants import ()from posthog.models.entity import Entityfrom posthog.models.filters.mixins.base import BaseParamMixin, BreakdownType-from posthog.models.filters.mixins.utils import cached_property, include_dict, include_query_tags, process_bool+from posthog.models.filters.mixins.utils import include_dict, include_query_tags, process_boolfrom posthog.models.filters.utils import GroupTypeIndex, validate_group_type_indexfrom posthog.utils import DEFAULT_DATE_FROM_DAYS, relative_date_parse_with_delta_mappingdiff --git a/posthog/models/filters/mixins/groups.py b/posthog/models/filters/mixins/groups.pyindex 1bae3747650d..60e291d4fa7c 100644--- a/posthog/models/filters/mixins/groups.py+++ b/posthog/models/filters/mixins/groups.py@@ -1,8 +1,9 @@+from functools import cached_propertyfrom typing import Optionalfrom posthog.constants import AGGREGATION_GROUP_TYPE_INDEXfrom posthog.models.filters.mixins.common import BaseParamMixin-from posthog.models.filters.mixins.utils import cached_property, include_dict+from posthog.models.filters.mixins.utils import include_dictfrom posthog.models.filters.utils import GroupTypeIndex, validate_group_type_indexdiff --git a/posthog/models/filters/mixins/interval.py b/posthog/models/filters/mixins/interval.pyindex 22db741e8abc..85e20b4a6aa5 100644--- a/posthog/models/filters/mixins/interval.py+++ b/posthog/models/filters/mixins/interval.py@@ -1,9 +1,10 @@+from functools import cached_propertyfrom typing import castfrom posthog.constants import INTERVALfrom posthog.models.filters.mixins.base import IntervalTypefrom posthog.models.filters.mixins.common import DateMixin-from posthog.models.filters.mixins.utils import cached_property, include_dict+from posthog.models.filters.mixins.utils import include_dictclass IntervalMixin(DateMixin): # Interval doesn't make sense without a date rangediff --git a/posthog/models/filters/mixins/property.py b/posthog/models/filters/mixins/property.pyindex 74ca8036861b..bacfe1650251 100644--- a/posthog/models/filters/mixins/property.py+++ b/posthog/models/filters/mixins/property.py@@ -1,10 +1,11 @@import json+from functools import cached_propertyfrom rest_framework.exceptions import ValidationErrorfrom posthog.constants import PROPERTIESfrom posthog.models.filters.mixins.base import BaseParamMixin-from posthog.models.filters.mixins.utils import cached_property, include_dict, include_query_tags+from posthog.models.filters.mixins.utils import include_dict, include_query_tagsfrom posthog.models.property import Property, PropertyGroupfrom posthog.models.property.parse import parse_properties, parse_property_group_datadiff --git a/posthog/models/filters/mixins/utils.py b/posthog/models/filters/mixins/utils.pyindex ab64a27f9fb2..d205ec03b64d 100644--- a/posthog/models/filters/mixins/utils.py+++ b/posthog/models/filters/mixins/utils.py@@ -1,18 +1,7 @@-from collections.abc import Callable-from functools import lru_cache-from typing import Optional, TypeVar, Union+from typing import Optional, Unionfrom posthog.utils import str_to_bool-T = TypeVar("T")---# Each decorated function gets one cache slot. Every instance in the process shares it. The slot keys-# on the instance's __hash__ and __eq__, so a class that compares by value, such as a Django model,-# gets the result that another equal instance cached. Use functools.cached_property instead.-def cached_property(func: Callable[..., T]) -> T:- return property(lru_cache(maxsize=1)(func)) # type: ignore-def include_dict(f):f.include_dict = Truediff --git a/posthog/models/property/property.py b/posthog/models/property/property.pyindex 02c65e8f405c..805288823a71 100644--- a/posthog/models/property/property.py+++ b/posthog/models/property/property.py@@ -1,10 +1,10 @@import jsonimport mathfrom enum import StrEnum+from functools import cached_propertyfrom typing import Any, Literal, Optional, Union, castfrom posthog.constants import PropertyOperatorType-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.models.filters.utils import GroupTypeIndex, validate_group_type_index# Relocated to the Django-free posthog.property_columns module so the HogQL engine can use themdiff --git a/products/demo/backend/logic/legacy/web_data_generator.py b/products/demo/backend/logic/legacy/web_data_generator.pyindex bb525f192452..29014386cea2 100644--- a/products/demo/backend/logic/legacy/web_data_generator.py+++ b/products/demo/backend/logic/legacy/web_data_generator.py@@ -1,6 +1,7 @@import jsonimport randomfrom datetime import timedelta+from functools import cached_propertyfrom pathlib import Pathfrom typing import Any@@ -11,7 +12,6 @@ from dateutil.relativedelta import relativedeltafrom posthog.schema import ActionsNode, FunnelsQuery, InsightVizNodefrom posthog.models import Person, PropertyDefinition-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.models.utils import UUIDTfrom products.actions.backend.models.action import Actiondiff --git a/products/error_tracking/backend/hogql_queries/error_tracking_query_runner.py b/products/error_tracking/backend/hogql_queries/error_tracking_query_runner.pyindex 8853a52f4ec8..e52b6d754237 100644--- a/products/error_tracking/backend/hogql_queries/error_tracking_query_runner.py+++ b/products/error_tracking/backend/hogql_queries/error_tracking_query_runner.py@@ -1,4 +1,5 @@import datetime+from functools import cached_propertyfrom zoneinfo import ZoneInfofrom django.db import OperationalError@@ -17,7 +18,6 @@ from posthog.hogql.query import execute_hogql_queryfrom posthog.hogql_queries.paginators import HogQLHasMorePaginatorfrom posthog.hogql_queries.query_runner import AnalyticsQueryRunner-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.utils import relative_date_parsefrom products.error_tracking.backend.hogql_queries.access import ErrorTrackingQueryRunnerAccessMixindiff --git a/products/logs/backend/group_by_query_runner.py b/products/logs/backend/group_by_query_runner.pyindex 23e5cdf8503b..a5ca4c4c18a9 100644--- a/products/logs/backend/group_by_query_runner.py+++ b/products/logs/backend/group_by_query_runner.py@@ -1,4 +1,5 @@from collections.abc import Sequence+from functools import cached_propertyfrom typing import TYPE_CHECKING, NamedTuplefrom zoneinfo import ZoneInfo@@ -15,7 +16,6 @@ from posthog.hogql.query import execute_hogql_queryfrom posthog.clickhouse.client.connection import Workloadfrom posthog.hogql_queries.query_runner import AnalyticsQueryRunner-from posthog.models.filters.mixins.utils import cached_propertyfrom products.logs.backend.logs_query_runner import LogsQueryResponse, LogsQueryRunnerMixindiff --git a/products/logs/backend/log_attributes_query_runner.py b/products/logs/backend/log_attributes_query_runner.pyindex e12e25c99778..0e77508d46b7 100644--- a/products/logs/backend/log_attributes_query_runner.py+++ b/products/logs/backend/log_attributes_query_runner.py@@ -1,4 +1,5 @@import datetime as dt+from functools import cached_propertyfrom zoneinfo import ZoneInfofrom posthog.schema import IntervalType, LogAttributeResult, LogAttributesQuery, LogAttributesQueryResponse, MatchedOn@@ -11,7 +12,6 @@ from posthog.hogql.query import execute_hogql_queryfrom posthog.clickhouse.client.connection import Workloadfrom posthog.hogql_queries.query_runner import AnalyticsQueryRunnerfrom posthog.hogql_queries.utils.query_date_range import QueryDateRange-from posthog.models.filters.mixins.utils import cached_propertyfrom products.logs.backend.logs_query_runner import LogsQueryRunnerMixin, ilike_patterndiff --git a/products/logs/backend/log_values_query_runner.py b/products/logs/backend/log_values_query_runner.pyindex 3b958f4370c5..b135a9afc80e 100644--- a/products/logs/backend/log_values_query_runner.py+++ b/products/logs/backend/log_values_query_runner.py@@ -1,4 +1,5 @@import datetime as dt+from functools import cached_propertyfrom zoneinfo import ZoneInfofrom posthog.schema import IntervalType, LogValueResult, LogValuesQuery, LogValuesQueryResponse@@ -11,7 +12,6 @@ from posthog.hogql.query import execute_hogql_queryfrom posthog.clickhouse.client.connection import Workloadfrom posthog.hogql_queries.query_runner import AnalyticsQueryRunnerfrom posthog.hogql_queries.utils.query_date_range import QueryDateRange-from posthog.models.filters.mixins.utils import cached_propertyfrom products.logs.backend.logs_query_runner import LogsQueryRunnerMixin, ilike_patterndiff --git a/products/logs/backend/logs_query_runner.py b/products/logs/backend/logs_query_runner.pyindex 3f906a38c00c..2ab6efb2d675 100644--- a/products/logs/backend/logs_query_runner.py+++ b/products/logs/backend/logs_query_runner.py@@ -1,6 +1,7 @@import jsonimport base64import datetime as dt+from functools import cached_propertyfrom typing import TYPE_CHECKING, castfrom zoneinfo import ZoneInfo@@ -27,7 +28,6 @@ from posthog.clickhouse.client.connection import Workloadfrom posthog.hogql_queries.paginators import HogQLHasMorePaginatorfrom posthog.hogql_queries.query_runner import AnalyticsQueryRunner, QueryRunnerfrom posthog.hogql_queries.utils.query_date_range import QueryDateRange-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.models.person.person import MAX_LIMIT_DISTINCT_IDS, get_distinct_ids_for_subqueryfrom posthog.models.person.util import get_person_by_pk_or_uuidfrom posthog.personhog_client.caller_tag import personhog_caller_tagdiff --git a/products/logs/backend/sparkline_query_runner.py b/products/logs/backend/sparkline_query_runner.pyindex 764cbe3dbc20..f48ae5ebec0d 100644--- a/products/logs/backend/sparkline_query_runner.py+++ b/products/logs/backend/sparkline_query_runner.py@@ -1,3 +1,4 @@+from functools import cached_propertyfrom zoneinfo import ZoneInfofrom posthog.schema import LogsSparklineBreakdownBy, LogsSparklineRankBy@@ -9,7 +10,6 @@ from posthog.hogql.query import execute_hogql_queryfrom posthog.clickhouse.client.connection import Workloadfrom posthog.hogql_queries.utils.breakdowns import BREAKDOWN_OTHER_STRING_LABEL-from posthog.models.filters.mixins.utils import cached_propertyfrom products.logs.backend.logs_query_runner import LogsQueryResponse, LogsQueryRunnerdiff --git a/products/product_analytics/backend/hogql_queries/funnels/funnels_query_runner.py b/products/product_analytics/backend/hogql_queries/funnels/funnels_query_runner.pyindex 585ce7ef0606..8457315290c4 100644--- a/products/product_analytics/backend/hogql_queries/funnels/funnels_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/funnels/funnels_query_runner.py@@ -1,7 +1,7 @@import jsonfrom collections.abc import Callable, Sequencefrom datetime import datetime, timedelta-from functools import partial+from functools import cached_property, partialfrom math import ceilfrom typing import Any, Optional, TypeVar, cast@@ -47,7 +47,6 @@ from posthog.hogql_queries.utils.query_previous_period_date_range import QueryPrfrom posthog.hogql_queries.validation.rules import DisallowUnsupportedDataWarehouseSettingsfrom posthog.hogql_queries.validation.validation import QueryValidationRulefrom posthog.models import Team-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.models.user import Userfrom products.cohorts.backend.models.cohort import Cohortdiff --git a/products/product_analytics/backend/hogql_queries/lifecycle/lifecycle_query_runner.py b/products/product_analytics/backend/hogql_queries/lifecycle/lifecycle_query_runner.pyindex d944700298e5..6bbe3d62852d 100644--- a/products/product_analytics/backend/hogql_queries/lifecycle/lifecycle_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/lifecycle/lifecycle_query_runner.py@@ -1,5 +1,6 @@from collections.abc import Sequencefrom datetime import datetime, timedelta+from functools import cached_propertyfrom math import ceilfrom typing import Any, Optional@@ -33,7 +34,6 @@ from posthog.hogql_queries.utils.query_date_range import QueryDateRange, comparefrom posthog.hogql_queries.utils.timestamp_utils import format_label_date, get_earliest_timestamp_from_seriesfrom posthog.hogql_queries.validation.rules import DisallowUnsupportedDataWarehouseSettings, RequireAtLeastOneSeriesfrom posthog.hogql_queries.validation.validation import QueryValidationRule-from posthog.models.filters.mixins.utils import cached_propertyfrom products.actions.backend.models.action import Actionfrom products.product_analytics.backend.hogql_queries.lifecycle.lifecycle_validation_rules import (diff --git a/products/product_analytics/backend/hogql_queries/paths/paths_query_runner.py b/products/product_analytics/backend/hogql_queries/paths/paths_query_runner.pyindex 292db6053473..698e81a76312 100644--- a/products/product_analytics/backend/hogql_queries/paths/paths_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/paths/paths_query_runner.py@@ -1,6 +1,7 @@import itertoolsfrom collections import defaultdictfrom datetime import datetime, timedelta+from functools import cached_propertyfrom math import ceilfrom re import (compile as re_compile,@@ -38,7 +39,6 @@ from posthog.hogql_queries.query_runner import AnalyticsQueryRunnerfrom posthog.hogql_queries.utils.query_date_range import QueryDateRangefrom posthog.hogql_queries.utils.sampling import correct_result_for_samplingfrom posthog.models import Team-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.models.user import Userfrom products.product_analytics.backend.hogql_queries.funnels.funnels_query_runner import FunnelsQueryRunnerdiff --git a/products/product_analytics/backend/hogql_queries/retention/retention_query_runner.py b/products/product_analytics/backend/hogql_queries/retention/retention_query_runner.pyindex acbed7705500..4a584c89d854 100644--- a/products/product_analytics/backend/hogql_queries/retention/retention_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/retention/retention_query_runner.py@@ -1,5 +1,6 @@from collections.abc import Sequencefrom datetime import datetime, timedelta+from functools import cached_propertyfrom math import ceilfrom typing import Any, Literal, Optional, cast@@ -46,7 +47,6 @@ from posthog.hogql_queries.utils.sampling import correct_result_for_samplingfrom posthog.hogql_queries.validation.rules import DisallowUnsupportedDataWarehouseSettingsfrom posthog.hogql_queries.validation.validation import QueryValidationRulefrom posthog.models import Team-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.models.user import Userfrom products.actions.backend.models.action import Actiondiff --git a/products/product_analytics/backend/hogql_queries/stickiness/stickiness_query_runner.py b/products/product_analytics/backend/hogql_queries/stickiness/stickiness_query_runner.pyindex 86066b27da19..30f19432d356 100644--- a/products/product_analytics/backend/hogql_queries/stickiness/stickiness_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/stickiness/stickiness_query_runner.py@@ -1,5 +1,6 @@from collections.abc import Sequencefrom datetime import timedelta+from functools import cached_propertyfrom math import ceilfrom typing import Any, Optional, cast@@ -38,7 +39,6 @@ from posthog.hogql_queries.validation.rules import ()from posthog.hogql_queries.validation.validation import QueryValidationRulefrom posthog.models import Team-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.models.user import Userfrom products.actions.backend.models.action import Actiondiff --git a/products/product_analytics/backend/hogql_queries/trends/breakdown.py b/products/product_analytics/backend/hogql_queries/trends/breakdown.pyindex b466b6c72b5a..1851f8c6e504 100644--- a/products/product_analytics/backend/hogql_queries/trends/breakdown.py+++ b/products/product_analytics/backend/hogql_queries/trends/breakdown.py@@ -1,4 +1,5 @@import json+from functools import cached_propertyfrom typing import Union, castfrom posthog.schema import (@@ -31,7 +32,6 @@ from posthog.hogql_queries.utils.breakdowns import (strip_user_aliases,)from posthog.hogql_queries.utils.query_date_range import QueryDateRange-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.models.team.team import Teamfrom products.product_analytics.backend.hogql_queries.trends.display import TrendsDisplaydiff --git a/products/product_analytics/backend/hogql_queries/trends/calendar_heatmap_query_runner.py b/products/product_analytics/backend/hogql_queries/trends/calendar_heatmap_query_runner.pyindex 97693ed7d466..6d347b85fa27 100644--- a/products/product_analytics/backend/hogql_queries/trends/calendar_heatmap_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/trends/calendar_heatmap_query_runner.py@@ -1,4 +1,5 @@from datetime import datetime, timedelta+from functools import cached_propertyfrom math import ceilfrom typing import Any, Optional, Union@@ -38,7 +39,6 @@ from posthog.caching.insights_api import (from posthog.hogql_queries.query_runner import AnalyticsQueryRunnerfrom posthog.hogql_queries.utils.query_date_range import QueryDateRangefrom posthog.models import Team-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.models.user import Userfrom products.actions.backend.models.action import Actiondiff --git a/products/product_analytics/backend/hogql_queries/trends/trends_query_builder.py b/products/product_analytics/backend/hogql_queries/trends/trends_query_builder.pyindex 89850c907814..e2ba01af0ac6 100644--- a/products/product_analytics/backend/hogql_queries/trends/trends_query_builder.py+++ b/products/product_analytics/backend/hogql_queries/trends/trends_query_builder.py@@ -1,3 +1,4 @@+from functools import cached_propertyfrom typing import Any, castfrom posthog.schema import (@@ -20,7 +21,6 @@ from posthog.hogql.timings import HogQLTimingsfrom posthog.hogql_queries.data_warehouse_mixin import DataWarehouseInsightQueryMixinfrom posthog.hogql_queries.utils.breakdowns import BREAKDOWN_NULL_STRING_LABEL, BREAKDOWN_OTHER_STRING_LABELfrom posthog.hogql_queries.utils.query_date_range import QueryDateRange-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.models.team.team import Teamfrom posthog.ph_client import feature_enabled_or_falsediff --git a/products/product_analytics/backend/hogql_queries/trends/trends_query_runner.py b/products/product_analytics/backend/hogql_queries/trends/trends_query_runner.pyindex ec351fdae81a..10798a2da471 100644--- a/products/product_analytics/backend/hogql_queries/trends/trends_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/trends/trends_query_runner.py@@ -1,7 +1,7 @@from collections.abc import Sequencefrom copy import deepcopyfrom datetime import date, datetime, timedelta-from functools import partial+from functools import cached_property, partialfrom math import ceilfrom operator import itemgetterfrom typing import Any, Optional, Union@@ -77,7 +77,6 @@ from posthog.hogql_queries.validation.rules import ()from posthog.hogql_queries.validation.validation import QueryValidationRulefrom posthog.models import Team-from posthog.models.filters.mixins.utils import cached_propertyfrom posthog.models.user import Userfrom posthog.ph_client import feature_enabled_or_falsefrom posthog.utils import multisortdiff --git a/products/tracing/backend/aggregation_query_runner.py b/products/tracing/backend/aggregation_query_runner.pyindex 6deab9bb29ff..d917c3019019 100644--- a/products/tracing/backend/aggregation_query_runner.py+++ b/products/tracing/backend/aggregation_query_runner.py@@ -18,6 +18,7 @@ windows in parallel when set.import datetime as dtimport contextvarsfrom concurrent.futures import ThreadPoolExecutor+from functools import cached_propertyfrom typing import TYPE_CHECKING, castfrom zoneinfo import ZoneInfo@@ -51,7 +52,6 @@ from posthog.hogql_queries.query_runner import AnalyticsQueryRunnerfrom posthog.hogql_queries.utils.query_compare_to_date_range import QueryCompareToDateRangefrom posthog.hogql_queries.utils.query_date_range import QueryDateRangefrom posthog.hogql_queries.utils.query_previous_period_date_range import QueryPreviousPeriodDateRange-from posthog.models.filters.mixins.utils import cached_property# _ROW_LIMIT lives in logic.py so the presentation layer can reach it through the# facade-allowed `logic` module; imported here (and re-exported) for the sibling runners.diff --git a/products/tracing/backend/logic.py b/products/tracing/backend/logic.pyindex 1e5388814b8b..e487b63e22a6 100644--- a/products/tracing/backend/logic.py+++ b/products/tracing/backend/logic.py@@ -9,6 +9,7 @@ import jsonimport base64import decimalimport datetime as dt+from functools import cached_propertyfrom typing import TYPE_CHECKING, castfrom zoneinfo import ZoneInfo@@ -44,7 +45,6 @@ from posthog.clickhouse.client.connection import Workloadfrom posthog.hogql_queries.paginators import HogQLHasMorePaginatorfrom posthog.hogql_queries.query_runner import AnalyticsQueryRunner, ExecutionMode, QueryRunnerfrom posthog.hogql_queries.utils.query_date_range import QueryDateRange-from posthog.models.filters.mixins.utils import cached_propertyif TYPE_CHECKING:from posthog.models import Team, Userdiff --git a/products/tracing/backend/symbol_stats_query_runner.py b/products/tracing/backend/symbol_stats_query_runner.pyindex c842c34999e3..d38d69f3c90d 100644--- a/products/tracing/backend/symbol_stats_query_runner.py+++ b/products/tracing/backend/symbol_stats_query_runner.py@@ -22,6 +22,7 @@ and a per-span `is_current` flag drives conditional aggregates for each bucket.import mathimport datetime as dt+from functools import cached_propertyfrom typing import TYPE_CHECKINGfrom zoneinfo import ZoneInfo@@ -47,7 +48,6 @@ from posthog.clickhouse.client.connection import Workloadfrom posthog.hogql_queries.query_runner import AnalyticsQueryRunner, ExecutionModefrom posthog.hogql_queries.utils.query_date_range import QueryDateRangefrom posthog.hogql_queries.utils.query_previous_period_date_range import QueryPreviousPeriodDateRange-from posthog.models.filters.mixins.utils import cached_propertyfrom products.tracing.backend.logic import TIME_BUCKET_DATE_RANGE_WHEREfrom products.tracing.backend.span_identity import str_attr_fielddiff --git a/products/web_analytics/backend/hogql_queries/external/summary_query_runner.py b/products/web_analytics/backend/hogql_queries/external/summary_query_runner.pyindex bdce604a0ff8..b79d4df3c15e 100644--- a/products/web_analytics/backend/hogql_queries/external/summary_query_runner.py+++ b/products/web_analytics/backend/hogql_queries/external/summary_query_runner.py@@ -1,6 +1,7 @@import csvfrom dataclasses import dataclassfrom datetime import datetime+from functools import cached_propertyfrom io import StringIOfrom typing import Any@@ -21,7 +22,6 @@ from posthog.hogql.database.schema.web_analytics_s3 import create_s3_web_bouncesfrom posthog.hogql_queries.query_runner import QueryRunnerfrom posthog.hogql_queries.utils.query_date_range import QueryDateRange-from posthog.models.filters.mixins.utils import cached_property@dataclassdiff --git a/products/web_analytics/backend/hogql_queries/stats_table.py b/products/web_analytics/backend/hogql_queries/stats_table.pyindex cd2628ea9f18..6b4dcf6c69f1 100644--- a/products/web_analytics/backend/hogql_queries/stats_table.py+++ b/products/web_analytics/backend/hogql_queries/stats_table.py@@ -1,6 +1,7 @@import mathfrom collections.abc import Callablefrom dataclasses import dataclass+from functools import cached_propertyfrom typing import Literal, Optional, Union, castfrom posthog.schema import (@@ -30,7 +31,6 @@ from posthog.hogql.visitor import TraversingVisitorfrom posthog.clickhouse.query_tagging import clear_tag, get_query_tag_valuefrom posthog.hogql_queries.paginators import HogQLHasMorePaginator-from posthog.models.filters.mixins.utils import cached_propertyfrom products.web_analytics.backend.hogql_queries.first_pageview_attribution import (FIRST_PAGEVIEW_BREAKDOWNS,diff --git a/products/web_analytics/backend/hogql_queries/web_agent_analytics.py b/products/web_analytics/backend/hogql_queries/web_agent_analytics.pyindex 1d8a4546d629..7c89013b519d 100644--- a/products/web_analytics/backend/hogql_queries/web_agent_analytics.py+++ b/products/web_analytics/backend/hogql_queries/web_agent_analytics.py@@ -1,4 +1,5 @@import urllib.parse as urlparse+from functools import cached_propertyfrom posthog.schema import (CachedWebAgentAnalyticsQueryResponse,@@ -16,7 +17,6 @@ from posthog.hogql.parser import parse_expr, parse_selectfrom posthog.hogql.query import execute_hogql_queryfrom posthog.hogql_queries.paginators import HogQLHasMorePaginator-from posthog.models.filters.mixins.utils import cached_propertyfrom products.web_analytics.backend.hogql_queries.agent_analytics_definitions import (AGENT_CATEGORIES,diff --git a/products/web_analytics/backend/hogql_queries/web_analytics_query_runner.py b/products/web_analytics/backend/hogql_queries/web_analytics_query_runner.pyindex 6e3c2054101d..b659ec104edb 100644--- a/products/web_analytics/backend/hogql_queries/web_analytics_query_runner.py+++ b/products/web_analytics/backend/hogql_queries/web_analytics_query_runner.py@@ -1,6 +1,7 @@import typingfrom abc import ABCfrom datetime import datetime, timedelta+from functools import cached_propertyfrom math import ceilfrom time import perf_counterfrom typing import Any, Optional, Union@@ -43,7 +44,6 @@ from posthog.hogql_queries.utils.query_compare_to_date_range import QueryComparefrom posthog.hogql_queries.utils.query_date_range import QueryDateRangefrom posthog.hogql_queries.utils.query_previous_period_date_range import QueryPreviousPeriodDateRangefrom posthog.models import User-from posthog.models.filters.mixins.utils import cached_propertyfrom products.access_control.backend.facade.user_access_control import UserAccessControlfrom products.actions.backend.models.action import Actiondiff --git a/products/web_analytics/backend/hogql_queries/web_overview.py b/products/web_analytics/backend/hogql_queries/web_overview.pyindex f208f5df3644..f9cb48eca76f 100644--- a/products/web_analytics/backend/hogql_queries/web_overview.py+++ b/products/web_analytics/backend/hogql_queries/web_overview.py@@ -1,4 +1,5 @@import math+from functools import cached_propertyfrom typing import Optional, Unionimport structlog@@ -19,8 +20,6 @@ from posthog.hogql.parser import parse_expr, parse_selectfrom posthog.hogql.property import property_to_exprfrom posthog.hogql.query import execute_hogql_query-from posthog.models.filters.mixins.utils import cached_property-from products.web_analytics.backend.hogql_queries.web_analytics_query_runner import (WEB_ANALYTICS_NO_JOIN_SERVED,WebAnalyticsQueryRunner,