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.

chore(data-modeling): remove incremental views feature flag (#121429)

Thiago Salvatore7b21bf711c3e
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index d8efe0ac7a8e..52813b7e61a1 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -294,7 +294,6 @@ export const FEATURE_FLAGS = {
CUSTOMER_ANALYTICS_TRACK_RULES: 'customer-analytics-track-rules', // owner: @arthurdedeus #team-customer-analytics
DASHBOARD_EXPORT_NUDGE: 'dashboard-export-nudge', // owner: #team-analytics-platform multivariate=control,test, nudges people who just exported a dashboard toward a recurring subscription
DASHBOARD_LAYOUT_DISCARD_PROMPT: 'dashboard-layout-discard-prompt', // owner: @cory.s #team-analytics-platform
- DATA_MODELING_INCREMENTAL_VIEWS: 'data-modeling-incremental-views', // owner: #team-data-modeling
DATA_QUALITY_CHECKS: 'data-quality-checks', // owner: #team-data-modeling
DATA_WAREHOUSE_CUSTOM_SOURCE_AI_BUILDER: 'dwh-custom-source-ai-builder', // owner: #team-warehouse-sources
DATA_WAREHOUSE_CUSTOM_SOURCE_OAUTH2: 'dwh-custom-source-oauth2', // owner: #team-warehouse-sources
diff --git a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts
index f75af78e9916..5c8771d66a5b 100644
--- a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts
+++ b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts
@@ -284,6 +284,14 @@ describe('sqlEditorLogic', () => {
},
post: {
'/api/environments/:team_id/query/': queryEndpointMock,
+ '/api/environments/:team_id/warehouse_saved_queries/check_incremental/': {
+ eligible: false,
+ key_candidates: [],
+ unique_key_candidates: [],
+ key_candidate_types: {},
+ blockers: [],
+ warnings: [],
+ },
'/api/environments/:team_id/warehouse_saved_queries/': () => [
200,
{
diff --git a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx
index 96e338f2d448..f93e31518a1a 100644
--- a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx
@@ -2468,14 +2468,12 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
// on the SQL being saved, which cannot change while the dialog is up. A failure
// leaves the incremental fields hidden, so the view saves as a normal full refresh.
let incrementalCheck: DataWarehouseSavedQueryIncrementalCheck | null = null
- if (values.featureFlags[FEATURE_FLAGS.DATA_MODELING_INCREMENTAL_VIEWS]) {
- try {
- incrementalCheck = await api.dataWarehouseSavedQueries.checkIncremental({
- query: selectedRef.current ?? values.queryInput ?? '',
- })
- } catch {
- incrementalCheck = null
- }
+ try {
+ incrementalCheck = await api.dataWarehouseSavedQueries.checkIncremental({
+ query: selectedRef.current ?? values.queryInput ?? '',
+ })
+ } catch {
+ incrementalCheck = null
}
const folderOptions: { value: string | null; label: string }[] = [
diff --git a/frontend/src/scenes/data-warehouse/saved_queries/MaterializationStatusPanel.tsx b/frontend/src/scenes/data-warehouse/saved_queries/MaterializationStatusPanel.tsx
index 5ae505f2e457..df501a0a7286 100644
--- a/frontend/src/scenes/data-warehouse/saved_queries/MaterializationStatusPanel.tsx
+++ b/frontend/src/scenes/data-warehouse/saved_queries/MaterializationStatusPanel.tsx
@@ -4,12 +4,10 @@ import { IconRefresh } from '@posthog/icons'
import { LemonBanner, LemonCard, LemonSkeleton, LemonTable, Link } from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
-import { FEATURE_FLAGS } from 'lib/constants'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonProgress } from 'lib/lemon-ui/LemonProgress'
import { LemonTag, LemonTagType } from 'lib/lemon-ui/LemonTag'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'
import { humanFriendlyDetailedTime } from 'lib/utils/datetime'
import { humanFriendlyNumber } from 'lib/utils/numbers'
@@ -155,7 +153,6 @@ export function MaterializationStatusPanel({
setIncrementalDraft,
setSyncFrequencyDraft,
} = useActions(jobsLogic)
- const { featureFlags } = useValues(featureFlagLogic)
const { updatingDataWarehouseSavedQuery, materializationActionLoading } = useValues(dataWarehouseViewsLogic)
@@ -178,8 +175,8 @@ export function MaterializationStatusPanel({
const currentJobStatus = dataModelingJobs?.results?.[0]?.status || null
const { sync } = getMaterializationDisabledReasons(currentJobStatus, startingMaterialization)
- const incrementalFlagOn = kind !== 'endpoint' && !!featureFlags[FEATURE_FLAGS.DATA_MODELING_INCREMENTAL_VIEWS]
- const showIncremental = incrementalFlagOn && !!savedQuery.incremental?.enabled
+ const supportsIncremental = kind !== 'endpoint'
+ const showIncremental = supportsIncremental && !!savedQuery.incremental?.enabled
const lastRunMode = savedQuery.incremental_state?.last_run_mode
const savedIncremental = savedQuery.incremental
// Key or unique-key edits change what the stored rows mean, so the next run rebuilds (via the
@@ -311,7 +308,7 @@ export function MaterializationStatusPanel({
</div>
)}
</div>
- {incrementalFlagOn && !savedQuery.managed_viewset_kind && incrementalCheck && (
+ {supportsIncremental && !savedQuery.managed_viewset_kind && incrementalCheck && (
<fieldset
className="mt-4 max-w-160"
disabled={
@@ -371,7 +368,7 @@ export function MaterializationStatusPanel({
)}
{showRunActions && <MaterializationRunActions viewId={viewId} kind={kind} />}
</div>
- {incrementalFlagOn && (
+ {supportsIncremental && (
<div className="max-w-160">
<IncrementalConfigOptions
check={incrementalCheck}
@@ -463,7 +460,7 @@ export function MaterializationStatusPanel({
{
title: 'Refresh mode',
dataIndex: 'run_mode',
- isHidden: !incrementalFlagOn || !savedQuery.has_incremental_history,
+ isHidden: !supportsIncremental || !savedQuery.has_incremental_history,
render: (_, { run_mode, full_refresh_reason }: DataModelingJobApi) => {
if (run_mode === 'incremental') {
return 'Incremental'
diff --git a/frontend/src/scenes/data-warehouse/saved_queries/materializationJobsLogic.test.ts b/frontend/src/scenes/data-warehouse/saved_queries/materializationJobsLogic.test.ts
index 6c88508c5136..2f98eba930b1 100644
--- a/frontend/src/scenes/data-warehouse/saved_queries/materializationJobsLogic.test.ts
+++ b/frontend/src/scenes/data-warehouse/saved_queries/materializationJobsLogic.test.ts
@@ -5,8 +5,6 @@ import posthog from 'posthog-js'
import { createElement } from 'react'
import api from 'lib/api'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { useMocks } from '~/mocks/jest'
import { DataWarehouseSavedQueryOrigin } from '~/queries/schema/schema-general'
@@ -88,16 +86,11 @@ describe('materializationJobsLogic', () => {
checkCalls = 0
savedSyncFrequency = null
initKeaTests()
- featureFlagLogic.mount()
- featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.DATA_MODELING_INCREMENTAL_VIEWS], {
- [FEATURE_FLAGS.DATA_MODELING_INCREMENTAL_VIEWS]: true,
- })
})
afterEach(() => {
cleanup()
logic?.unmount()
- featureFlagLogic.unmount()
jest.useRealTimers()
delete (document as { hidden?: boolean }).hidden
})
@@ -393,15 +386,9 @@ describe('materializationJobsLogic', () => {
}
)
- it.each([
- ['the surface is an endpoint', { kind: 'endpoint' as const, flag: true }],
- ['the feature flag is off', { kind: 'view' as const, flag: false }],
- ])('does not run the eligibility check when %s', async (_name, { kind, flag }) => {
- featureFlagLogic.actions.setFeatureFlags([], {
- [FEATURE_FLAGS.DATA_MODELING_INCREMENTAL_VIEWS]: flag,
- })
+ it('does not run the eligibility check when the surface is an endpoint', async () => {
useMocks(apiMocks({ isMaterialized: false }))
- logic = materializationJobsLogic({ viewId: 'view-1', kind })
+ logic = materializationJobsLogic({ viewId: 'view-1', kind: 'endpoint' })
logic.mount()
await expectLogic(logic).toDispatchActions(['loadSavedQuerySuccess']).toFinishAllListeners()
@@ -409,12 +396,10 @@ describe('materializationJobsLogic', () => {
})
it.each([
- ['flag disabled', 'view' as const, false, false],
- ['endpoint', 'endpoint' as const, true, false],
- ['untouched draft', 'view' as const, true, false],
- ['explicit full refresh', 'view' as const, true, true],
- ])('preserves stored incremental settings unless edited: %s', async (_name, kind, flag, edited) => {
- featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.DATA_MODELING_INCREMENTAL_VIEWS]: flag })
+ ['endpoint', 'endpoint' as const, false],
+ ['untouched draft', 'view' as const, false],
+ ['explicit full refresh', 'view' as const, true],
+ ])('preserves stored incremental settings unless edited: %s', async (_name, kind, edited) => {
const incremental = { enabled: true, incremental_key: 'id', unique_key: ['id'], lookback_seconds: 0 }
const updates: unknown[] = []
let materializations = 0
diff --git a/frontend/src/scenes/data-warehouse/saved_queries/materializationJobsLogic.ts b/frontend/src/scenes/data-warehouse/saved_queries/materializationJobsLogic.ts
index 0d6206e82e0e..adf828f08dc3 100644
--- a/frontend/src/scenes/data-warehouse/saved_queries/materializationJobsLogic.ts
+++ b/frontend/src/scenes/data-warehouse/saved_queries/materializationJobsLogic.ts
@@ -18,8 +18,6 @@ import posthog from 'posthog-js'
import { lemonToast } from '@posthog/lemon-ui'
import api, { ApiConfig, ApiError } from 'lib/api'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import type { DataWarehouseSavedQuerySummary } from 'scenes/data-warehouse/saved_queries/dataWarehouseViewsLogic'
import type { DataWarehouseSavedQuery } from '~/types'
@@ -717,9 +715,6 @@ export const materializationJobsLogic = kea<materializationJobsLogicType>([
if (!savedQuery || props.kind === 'endpoint') {
return
}
- if (!featureFlagLogic.findMounted()?.values.featureFlags[FEATURE_FLAGS.DATA_MODELING_INCREMENTAL_VIEWS]) {
- return
- }
// Reflect the saved config so a materialized view's editor starts from what is
// actually configured, not from the empty draft.
if (!values.incrementalDraftTouched && savedQuery.incremental?.enabled) {
diff --git a/posthog/temporal/tests/data_modeling/test_materialize_view_activities.py b/posthog/temporal/tests/data_modeling/test_materialize_view_activities.py
index 18ece9ef1624..c17795e358fe 100644
--- a/posthog/temporal/tests/data_modeling/test_materialize_view_activities.py
+++ b/posthog/temporal/tests/data_modeling/test_materialize_view_activities.py
@@ -244,9 +244,6 @@ class TestMaterializeViewManagedWarehouseActivity:
team_id=ateam.pk, node_id=str(anode.id), dag_id=str(adag.id), job_id=str(ajob.id), use_trino=True
)
with (
- unittest.mock.patch(
- "products.data_modeling.backend.logic.incremental_plan.incremental_enabled", return_value=True
- ),
unittest.mock.patch(
"products.managed_warehouse.backend.facade.client.request_model_alias_reconciliation",
),
diff --git a/posthog/temporal/tests/data_modeling/test_materialize_view_incremental.py b/posthog/temporal/tests/data_modeling/test_materialize_view_incremental.py
index 101b3f9e701a..710053fcd486 100644
--- a/posthog/temporal/tests/data_modeling/test_materialize_view_incremental.py
+++ b/posthog/temporal/tests/data_modeling/test_materialize_view_incremental.py
@@ -1,7 +1,6 @@
"""Incremental materialization, exercised against real deltalite and real Delta tables.
-Mocked out here: only ``hogql_table`` (so a test controls exactly which rows a "run" returns) and
-the feature flags. The write path itself is real, because every load-bearing unknown lives in the
+Mocked out here: only ``hogql_table`` (so a test controls exactly which rows a "run" returns). The write path itself is real, because every load-bearing unknown lives in the
Rust crate — key matching, duplicate rejection, schema handling, column-name case — and a mock
would assert our idea of deltalite rather than deltalite.
"""
@@ -114,7 +113,6 @@ async def _run(
ajob,
adag,
*batches: pa.RecordBatch,
- enabled: bool = True,
value_column: str = "c",
windows: list[Any] | None = None,
column_types: list[tuple[str, str]] | None = None,
@@ -124,10 +122,6 @@ async def _run(
"posthog.temporal.data_modeling.activities.materialize_view.hogql_table",
_mock_hogql_table(*batches, value_column=value_column, windows=windows, column_types=column_types),
),
- unittest.mock.patch(
- "products.data_modeling.backend.logic.incremental_plan.incremental_enabled",
- return_value=enabled,
- ),
):
return await activity_environment.run(
materialize_view_activity,
@@ -324,9 +318,6 @@ class TestIncrementalMaterialization:
unittest.mock.patch(
"posthog.temporal.data_modeling.activities.materialize_view.hogql_table", remove_log_then_yield
),
- unittest.mock.patch(
- "products.data_modeling.backend.logic.incremental_plan.incremental_enabled", return_value=True
- ),
pytest.raises(TableUnreadableError),
):
await activity_environment.run(
@@ -450,18 +441,6 @@ class TestIncrementalMaterialization:
await database_sync_to_async(asaved_query.refresh_from_db)()
assert get_incremental_state(asaved_query).watermark == before
- async def test_flag_off_rebuilds_every_run(
- self, activity_environment, ateam, anode, asaved_query, ajob, bucket_name, adag
- ):
- """The kill switch. With the flag off the behaviour is exactly what ships today."""
- await _configure(asaved_query)
-
- with _settings(bucket_name):
- first = await _run(activity_environment, ateam, anode, ajob, adag, _batch([DAY1], [10]), enabled=False)
- await _run(activity_environment, ateam, anode, ajob, adag, _batch([DAY2], [20]), enabled=False)
-
- assert _rows(first.table_uri) == [(DAY2, 20)], "a full refresh replaces the table wholesale"
-
async def test_no_config_rebuilds_every_run(
self, activity_environment, ateam, anode, asaved_query, ajob, bucket_name, adag
):
diff --git a/products/data_modeling/backend/facade/api.py b/products/data_modeling/backend/facade/api.py
index 714141d6eac9..da31c39339fa 100644
--- a/products/data_modeling/backend/facade/api.py
+++ b/products/data_modeling/backend/facade/api.py
@@ -98,9 +98,7 @@ _LAZY = {
"record_incremental_history": "logic.incremental",
"set_incremental_state": "logic.incremental",
"window_start": "logic.incremental",
- "INCREMENTAL_FLAG": "logic.incremental_plan",
"WritePlan": "logic.incremental_plan",
- "incremental_enabled": "logic.incremental_plan",
"resolve_write_plan": "logic.incremental_plan",
"IncrementalFilterError": "logic.incremental_filter",
"inject_incremental_filter": "logic.incremental_filter",
diff --git a/products/data_modeling/backend/logic/incremental_plan.py b/products/data_modeling/backend/logic/incremental_plan.py
index a7e486de95c0..1472b70b1a21 100644
--- a/products/data_modeling/backend/logic/incremental_plan.py
+++ b/products/data_modeling/backend/logic/incremental_plan.py
@@ -10,11 +10,6 @@ from dataclasses import dataclass
from typing import Any, cast
from uuid import UUID
-import structlog
-
-from posthog.models import Team
-from posthog.ph_client import feature_enabled_or_false
-
from products.data_modeling.backend.logic.incremental import (
IncrementalConfig,
definition_fingerprint,
@@ -24,33 +19,6 @@ from products.data_modeling.backend.logic.incremental import (
)
from products.data_modeling.backend.models.datawarehouse_saved_query import DataWarehouseSavedQuery
-LOGGER = structlog.get_logger(__name__)
-
-# The only gate. Incremental is also the only path that writes through deltalite, so turning this
-# off falls back to full refresh on delta-rs and takes the engine with it.
-INCREMENTAL_FLAG = "data-modeling-incremental-views"
-
-
-def incremental_enabled(team_id: int) -> bool:
- """Fails closed: a flag-service outage produces a full refresh, which costs money but is
- never wrong."""
- try:
- team = Team.objects.only("organization_id").get(id=team_id)
- return feature_enabled_or_false(
- INCREMENTAL_FLAG,
- str(team_id),
- groups={"organization": str(team.organization_id), "project": str(team_id)},
- group_properties={
- "organization": {"id": str(team.organization_id)},
- "project": {"id": str(team_id)},
- },
- only_evaluate_locally=True,
- send_feature_flag_events=False,
- )
- except Exception:
- LOGGER.warning("Failed to evaluate incremental flag; falling back to full refresh", team_id=team_id)
- return False
-
@dataclass(frozen=True, kw_only=True, slots=True)
class WritePlan:
@@ -70,9 +38,6 @@ def resolve_write_plan(team_id: int, saved_query_id: UUID | str, *, scope: str |
if config is None:
return WritePlan(incremental=False, reason="not configured for incremental materialization")
- if not incremental_enabled(team_id):
- return WritePlan(incremental=False, reason="incremental materialization is not enabled")
-
fingerprint = definition_fingerprint(cast(dict, saved_query.query), config)
state = get_incremental_state(saved_query, scope=scope)
diff --git a/products/data_warehouse/frontend/shared/components/MaterializationRunActions.tsx b/products/data_warehouse/frontend/shared/components/MaterializationRunActions.tsx
index 4516028e4492..5a2586e0bc3c 100644
--- a/products/data_warehouse/frontend/shared/components/MaterializationRunActions.tsx
+++ b/products/data_warehouse/frontend/shared/components/MaterializationRunActions.tsx
@@ -3,8 +3,6 @@ import { useActions, useValues } from 'kea'
import { IconEllipsis, IconRefresh } from '@posthog/icons'
import { LemonButton, LemonDialog, LemonMenu } from '@posthog/lemon-ui'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'
import { dataWarehouseViewsLogic } from 'scenes/data-warehouse/saved_queries/dataWarehouseViewsLogic'
import { materializationJobsLogic } from 'scenes/data-warehouse/saved_queries/materializationJobsLogic'
@@ -59,7 +57,6 @@ export function MaterializationRunActions({
updateDataWarehouseSavedQuery,
revertMaterialization,
} = useActions(dataWarehouseViewsLogic)
- const { featureFlags } = useValues(featureFlagLogic)
if (!savedQuery) {
return null
@@ -152,9 +149,7 @@ export function MaterializationRunActions({
materializeDataWarehouseSavedQuery(
viewId,
defaultCadenceWithin(savedQuery.sync_frequency_bounds, initialSyncFrequency),
- !incrementalDraftTouched ||
- kind === 'endpoint' ||
- !featureFlags[FEATURE_FLAGS.DATA_MODELING_INCREMENTAL_VIEWS]
+ !incrementalDraftTouched || kind === 'endpoint'
? undefined
: incrementalDraft.enabled && incrementalDraft.incrementalKey
? {
@@ -294,8 +289,7 @@ export function MaterializationRunActions({
: []),
...(kind !== 'endpoint'
? [
- ...(featureFlags[FEATURE_FLAGS.DATA_MODELING_INCREMENTAL_VIEWS] &&
- savedQuery.incremental?.enabled
+ ...(savedQuery.incremental?.enabled
? [
{
label: 'Run full refresh',
diff --git a/products/warehouse_suggestions/backend/logic/accept.py b/products/warehouse_suggestions/backend/logic/accept.py
index 7fc392aa5349..eaa850dd5abc 100644
--- a/products/warehouse_suggestions/backend/logic/accept.py
+++ b/products/warehouse_suggestions/backend/logic/accept.py
@@ -21,7 +21,6 @@ from products.data_modeling.backend.facade.api import (
get_saved_query_columns,
get_saved_query_sql,
get_saved_query_summary,
- incremental_enabled,
propose_incremental_config,
)
from products.warehouse_sources.backend.facade.api import get_queryable_table
@@ -118,7 +117,6 @@ KEYS_NEED_INCREMENTAL = (
"incremental_key, unique_key and lookback_seconds only apply to an incremental refresh. "
"Set refresh_mode to incremental to use them."
)
-INCREMENTAL_UNAVAILABLE = "Incremental refresh is not available for this project. Use a full refresh."
KEYS_REQUIRED = (
"An incremental refresh needs an incremental_key and a unique_key. Choose them with view-check-incremental."
)
@@ -138,7 +136,7 @@ class MaterializeAcceptor(Acceptor):
raise AcceptFailedError("This suggestion has no refresh interval to apply.")
options = request.options
interval = timedelta(seconds=options.refresh_interval_seconds or payload.refresh_interval_seconds)
- incremental_config = _incremental_config(payload, options, suggestion.team_id)
+ incremental_config = _incremental_config(payload, options)
if (
incremental_config is not None
and not _chose_keys(options)
@@ -168,13 +166,11 @@ class MaterializeAcceptor(Acceptor):
return _materialization_asset(suggestion, interval, incremental_config)
-def _incremental_config(payload: MaterializePayload, options: AcceptOptions, team_id: int) -> IncrementalConfig | None:
+def _incremental_config(payload: MaterializePayload, options: AcceptOptions) -> IncrementalConfig | None:
if (options.refresh_mode or payload.refresh_mode) == WarehouseSuggestionRefreshMode.FULL:
if _chose_keys(options) or options.lookback_seconds is not None:
raise AcceptOptionRefusedError(REFRESH_MODE_FIELD, KEYS_NEED_INCREMENTAL)
return None
- if not incremental_enabled(team_id):
- raise AcceptOptionRefusedError(REFRESH_MODE_FIELD, INCREMENTAL_UNAVAILABLE)
incremental_key = options.incremental_key or payload.incremental_key
if incremental_key is None:
raise AcceptOptionRefusedError(INCREMENTAL_KEY_FIELD, KEYS_REQUIRED)
diff --git a/products/warehouse_suggestions/backend/logic/candidates/materialize.py b/products/warehouse_suggestions/backend/logic/candidates/materialize.py
index a409a9ef5190..8e9649093ffb 100644
--- a/products/warehouse_suggestions/backend/logic/candidates/materialize.py
+++ b/products/warehouse_suggestions/backend/logic/candidates/materialize.py
@@ -15,7 +15,6 @@ from products.data_modeling.backend.facade.api import (
SavedQueryFrequencyBounds,
definition_database,
get_saved_query_columns,
- incremental_enabled,
propose_incremental_config,
saved_query_target_bounds,
upstream_table_refs,
@@ -58,15 +57,11 @@ class _Proposal:
class _IncrementalProposer:
- """Proposes incremental keys for one team run, reading the flag and building the team database at most once."""
+ """Proposes incremental keys for one team run, building the team database at most once."""
def __init__(self, team_id: int) -> None:
self._team_id = team_id
- @cached_property
- def _enabled(self) -> bool:
- return incremental_enabled(self._team_id)
-
@cached_property
def _database(self) -> Database | None:
try:
@@ -76,7 +71,7 @@ class _IncrementalProposer:
return None
def config_for(self, saved_query: SavedQueryDefinition) -> IncrementalConfig | None:
- if not self._enabled or self._database is None:
+ if self._database is None:
return None
column_types = get_saved_query_columns(self._team_id, saved_query.id)
return propose_incremental_config(saved_query.hogql, column_types, database=self._database)
diff --git a/products/warehouse_suggestions/backend/tests/test_accept.py b/products/warehouse_suggestions/backend/tests/test_accept.py
index 5a3de50019db..7cd5b25ce4ed 100644
--- a/products/warehouse_suggestions/backend/tests/test_accept.py
+++ b/products/warehouse_suggestions/backend/tests/test_accept.py
@@ -37,7 +37,6 @@ from .test_suggestions import make_draft
FLAG = "products.warehouse_suggestions.backend.presentation.views.is_warehouse_suggestions_enabled"
DAY_SECONDS = 24 * 60 * 60
REPORT = "products.warehouse_suggestions.backend.logic.analytics.report_user_or_team_action"
-ACCEPT_INCREMENTAL_FLAG = "products.warehouse_suggestions.backend.logic.accept.incremental_enabled"
DAY_KEYS = {"refresh_mode": "incremental", "incremental_key": "day", "unique_key": ["day"]}
DAILY_COUNTS = "SELECT toStartOfDay(timestamp) AS day, count() AS c FROM events GROUP BY day"
DAILY_COUNT_COLUMNS = {
@@ -97,7 +96,6 @@ class TestAcceptSuggestion(APIBaseTest):
super().setUp()
self.enterContext(patch(FLAG, return_value=True))
self.enterContext(patch.object(DataWarehouseSavedQuery, "schedule_materialization"))
- self.enterContext(patch(ACCEPT_INCREMENTAL_FLAG, return_value=True))
self.url = f"/api/projects/{self.team.id}/warehouse_suggestions"
self.view = create_view_in_dag(self.team, self.user)
@@ -245,7 +243,7 @@ class TestAcceptSuggestion(APIBaseTest):
self.view.refresh_from_db()
assert (accepted["http_status"], self.view.incremental_config) == (expected_status, expected_config), accepted
- def _suggest_and_accept(self, payload: SuggestionPayload, body: dict, flag_on: bool) -> tuple[dict, list]:
+ def _suggest_and_accept(self, payload: SuggestionPayload, body: dict) -> tuple[dict, list]:
DataWarehouseSavedQuery.objects.filter(id=self.view.id).update(
query={"kind": "HogQLQuery", "query": DAILY_COUNTS}
)
@@ -256,7 +254,7 @@ class TestAcceptSuggestion(APIBaseTest):
)
draft = make_draft(fingerprint=f"{kind}:orders", subject_id=self.view.id)
suggestion = ingest_surfaced(self.team.id, replace(draft, kind=kind, payload=payload))
- with patch(ACCEPT_INCREMENTAL_FLAG, return_value=flag_on), patch(REPORT) as report:
+ with patch(REPORT) as report:
accepted = self._accept(suggestion.id, body)
self.view.refresh_from_db()
return accepted, [call.args[1]["changed_fields"] for call in report.call_args_list]
@@ -282,7 +280,7 @@ class TestAcceptSuggestion(APIBaseTest):
def test_a_person_can_change_the_refresh_before_accepting(
self, _name: str, payload: MaterializePayload, body: dict, expected_config: dict | None, changed: list[str]
) -> None:
- accepted, reported_changes = self._suggest_and_accept(payload, body, flag_on=True)
+ accepted, reported_changes = self._suggest_and_accept(payload, body)
assert accepted["http_status"] == status.HTTP_200_OK, accepted
assert (self.view.incremental_config, reported_changes) == (expected_config, [changed])
@@ -293,7 +291,6 @@ class TestAcceptSuggestion(APIBaseTest):
"hostile_key",
INCREMENTAL_DAY_PAYLOAD,
{"incremental_key": 'day"; DROP TABLE events; --'},
- True,
status.HTTP_400_BAD_REQUEST,
"incremental_key",
),
@@ -301,7 +298,6 @@ class TestAcceptSuggestion(APIBaseTest):
"aggregate_in_a_chosen_unique_key",
MATERIALIZE_PAYLOAD,
{**DAY_KEYS, "unique_key": ["day", "c"]},
- True,
status.HTTP_400_BAD_REQUEST,
"unique_key",
),
@@ -309,15 +305,6 @@ class TestAcceptSuggestion(APIBaseTest):
"keys_with_a_full_refresh",
MATERIALIZE_PAYLOAD,
{"incremental_key": "day"},
- True,
- status.HTTP_400_BAD_REQUEST,
- "refresh_mode",
- ),
- (
- "incremental_while_the_flag_is_off",
- MATERIALIZE_PAYLOAD,
- DAY_KEYS,
- False,
status.HTTP_400_BAD_REQUEST,
"refresh_mode",
),
@@ -325,7 +312,6 @@ class TestAcceptSuggestion(APIBaseTest):
"an_option_for_another_kind",
PAYLOADS[WarehouseSuggestionKind.CERTIFY],
{"refresh_interval_seconds": 60 * 60},
- True,
status.HTTP_400_BAD_REQUEST,
"refresh_interval_seconds",
),
@@ -333,7 +319,6 @@ class TestAcceptSuggestion(APIBaseTest):
"lookback_only_on_stale_suggested_keys",
replace(INCREMENTAL_DAY_PAYLOAD, incremental_key="hour", unique_key=("hour",)),
{"lookback_seconds": 60 * 60},
- True,
status.HTTP_409_CONFLICT,
None,
),
@@ -344,11 +329,10 @@ class TestAcceptSuggestion(APIBaseTest):
_name: str,
payload: SuggestionPayload,
body: dict,
- flag_on: bool,
expected_status: int,
expected_attr: str | None,
) -> None:
- accepted, reported_changes = self._suggest_and_accept(payload, body, flag_on)
+ accepted, reported_changes = self._suggest_and_accept(payload, body)
assert (accepted["http_status"], accepted.get("attr")) == (expected_status, expected_attr), accepted
assert (self.view.incremental_config, reported_changes) == (None, [])
diff --git a/products/warehouse_suggestions/backend/tests/test_candidates.py b/products/warehouse_suggestions/backend/tests/test_candidates.py
index e2dc6e625e88..f8fee1e37bee 100644
--- a/products/warehouse_suggestions/backend/tests/test_candidates.py
+++ b/products/warehouse_suggestions/backend/tests/test_candidates.py
@@ -3,7 +3,6 @@ from datetime import timedelta
from uuid import uuid4
from posthog.test.base import BaseTest
-from unittest.mock import patch
from django.test import SimpleTestCase
@@ -39,7 +38,6 @@ VIEW_ID = uuid4()
AT_CERTIFY_FLOORS = {"human_users": 5, "human_days": 20}
HOUR = timedelta(hours=1)
DAY = timedelta(hours=24)
-INCREMENTAL_FLAG = "products.warehouse_suggestions.backend.logic.candidates.materialize.incremental_enabled"
DAILY_COUNTS = "SELECT toStartOfDay(timestamp) AS day, count() AS c FROM events GROUP BY day"
DAILY_COUNT_COLUMNS = {
"day": {"hogql": "DateTimeDatabaseField", "clickhouse": "DateTime64(6, 'UTC')"},
@@ -215,12 +213,10 @@ class TestMaterializeRules(SimpleTestCase):
class TestMaterializeRefreshMode(BaseTest):
@parameterized.expand(
[
- ("grouped_by_day", DAILY_COUNTS, True, WarehouseSuggestionRefreshMode.INCREMENTAL, "day", ("day",)),
- ("flag_off", DAILY_COUNTS, False, WarehouseSuggestionRefreshMode.FULL, None, ()),
+ ("grouped_by_day", DAILY_COUNTS, WarehouseSuggestionRefreshMode.INCREMENTAL, "day", ("day",)),
(
"limited_query",
"SELECT timestamp, event FROM events ORDER BY timestamp DESC LIMIT 10",
- True,
WarehouseSuggestionRefreshMode.FULL,
None,
(),
@@ -228,7 +224,6 @@ class TestMaterializeRefreshMode(BaseTest):
(
"grouped_over_a_nondeterministic_view",
DAILY_COUNTS.replace("FROM events", "FROM sampled_events"),
- True,
WarehouseSuggestionRefreshMode.FULL,
None,
(),
@@ -239,7 +234,6 @@ class TestMaterializeRefreshMode(BaseTest):
self,
_name: str,
hogql: str,
- flag_on: bool,
refresh_mode: WarehouseSuggestionRefreshMode,
incremental_key: str | None,
unique_key: tuple[str, ...],
@@ -264,8 +258,7 @@ class TestMaterializeRefreshMode(BaseTest):
team_id=self.team.pk,
)
- with patch(INCREMENTAL_FLAG, return_value=flag_on):
- [draft] = MaterializeCandidate().evaluate(candidate_context).drafts
+ [draft] = MaterializeCandidate().evaluate(candidate_context).drafts
assert isinstance(draft.payload, MaterializePayload)
expected_lookback = RULES.materialize.incremental_lookback_seconds if incremental_key else 0
diff --git a/products/warehouse_suggestions/backend/tests/test_job.py b/products/warehouse_suggestions/backend/tests/test_job.py
index c32bfcd38e54..b97d54b26f57 100644
--- a/products/warehouse_suggestions/backend/tests/test_job.py
+++ b/products/warehouse_suggestions/backend/tests/test_job.py
@@ -2,7 +2,6 @@ from datetime import UTC, date, datetime, time, timedelta
from uuid import uuid4
from posthog.test.base import BaseTest, ClickhouseTestMixin
-from unittest.mock import patch
from parameterized import parameterized
@@ -23,7 +22,6 @@ TODAY = date.today()
NOW = datetime.combine(TODAY, time(hour=9), tzinfo=UTC)
BEFORE_THE_WINDOW = NOW - timedelta(days=2 * RULES.window_days)
SCENES = ("SQLEditor", "Dashboard")
-INCREMENTAL_FLAG = "products.warehouse_suggestions.backend.logic.candidates.materialize.incremental_enabled"
DAILY_COUNTS = "SELECT toStartOfDay(timestamp) AS day, count() AS c FROM events GROUP BY day"
DAILY_COUNT_COLUMNS = {
"day": {"hogql": "DateTimeDatabaseField", "clickhouse": "DateTime64(6, 'UTC')"},
@@ -82,8 +80,7 @@ class TestRunTeam(ClickhouseTestMixin, BaseTest):
],
)
- with patch(INCREMENTAL_FLAG, return_value=True):
- result = run_team(self.team.pk, run_id="run-1", today=TODAY, rollup_days=FULL_ROLLUP, now=NOW)
+ result = run_team(self.team.pk, run_id="run-1", today=TODAY, rollup_days=FULL_ROLLUP, now=NOW)
assert result.status == TeamRunStatus.PROCESSED
assert sorted(