diff --git a/frontend/src/scenes/data-warehouse/ViewLinkModal.tsx b/frontend/src/scenes/data-warehouse/ViewLinkModal.tsx index 83d141856b397..3004b8ee60daf 100644 --- a/frontend/src/scenes/data-warehouse/ViewLinkModal.tsx +++ b/frontend/src/scenes/data-warehouse/ViewLinkModal.tsx @@ -60,7 +60,7 @@ export function ViewLinkForm(): JSX.Element { joiningIsUsingHogQLExpression, isViewLinkSubmitting, experimentsOptimized, - experimentsTimestampField, + experimentsTimestampKey, } = useValues(viewLinkLogic) const { selectJoiningTable, @@ -70,7 +70,7 @@ export function ViewLinkForm(): JSX.Element { selectSourceKey, selectJoiningKey, setExperimentsOptimized, - selectExperimentsTimestampField, + selectExperimentsTimestampKey, } = useActions(viewLinkLogic) const [advancedSettingsExpanded, setAdvancedSettingsExpanded] = useState(false) @@ -173,12 +173,12 @@ export function ViewLinkForm(): JSX.Element {
- Timestamp Field - + Source Timestamp Key + diff --git a/frontend/src/scenes/data-warehouse/viewLinkLogic.tsx b/frontend/src/scenes/data-warehouse/viewLinkLogic.tsx index 991383b96c8af..9d2a7cd171d5b 100644 --- a/frontend/src/scenes/data-warehouse/viewLinkLogic.tsx +++ b/frontend/src/scenes/data-warehouse/viewLinkLogic.tsx @@ -42,7 +42,7 @@ export const viewLinkLogic = kea([ setError: (error: string) => ({ error }), setFieldName: (fieldName: string) => ({ fieldName }), setExperimentsOptimized: (experimentsOptimized: boolean) => ({ experimentsOptimized }), - selectExperimentsTimestampField: (experimentsTimestampField: string | null) => ({ experimentsTimestampField }), + selectExperimentsTimestampKey: (experimentsTimestampKey: string | null) => ({ experimentsTimestampKey }), clearModalFields: true, })), reducers({ @@ -111,11 +111,11 @@ export const viewLinkLogic = kea([ clearModalFields: () => false, }, ], - experimentsTimestampField: [ + experimentsTimestampKey: [ null as string | null, { - selectExperimentsTimestampField: (_, { experimentsTimestampField }) => experimentsTimestampField, - toggleEditJoinModal: (_, { join }) => join.configuration?.experiments_timestamp_field ?? null, + selectExperimentsTimestampKey: (_, { experimentsTimestampKey }) => experimentsTimestampKey, + toggleEditJoinModal: (_, { join }) => join.configuration?.experiments_timestamp_key ?? null, clearModalFields: () => null, }, ], @@ -156,7 +156,7 @@ export const viewLinkLogic = kea([ field_name: values.fieldName, configuration: { experiments_optimized: values.experimentsOptimized, - experiments_timestamp_field: values.experimentsTimestampField ?? undefined, + experiments_timestamp_key: values.experimentsTimestampKey ?? undefined, }, }) @@ -180,7 +180,7 @@ export const viewLinkLogic = kea([ field_name: values.fieldName, configuration: { experiments_optimized: values.experimentsOptimized, - experiments_timestamp_field: values.experimentsTimestampField ?? undefined, + experiments_timestamp_key: values.experimentsTimestampKey ?? undefined, }, }) @@ -203,11 +203,11 @@ export const viewLinkLogic = kea([ }, setExperimentsOptimized: ({ experimentsOptimized }) => { if (!experimentsOptimized) { - actions.selectExperimentsTimestampField(null) + actions.selectExperimentsTimestampKey(null) } }, - selectExperimentsTimestampField: ({ experimentsTimestampField }) => { - if (experimentsTimestampField) { + selectExperimentsTimestampKey: ({ experimentsTimestampKey }) => { + if (experimentsTimestampKey) { actions.setExperimentsOptimized(true) } }, diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 6a0bd1e87c04e..c4f4031a0e06e 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -4055,7 +4055,7 @@ export interface DataWarehouseViewLink { created_at?: string | null configuration?: { experiments_optimized?: boolean - experiments_timestamp_field?: string | null + experiments_timestamp_key?: string | null } } diff --git a/posthog/hogql_queries/experiments/test/test_experiment_trends_query_runner.py b/posthog/hogql_queries/experiments/test/test_experiment_trends_query_runner.py index a0cd5c03c527e..8837bfeab8607 100644 --- a/posthog/hogql_queries/experiments/test/test_experiment_trends_query_runner.py +++ b/posthog/hogql_queries/experiments/test/test_experiment_trends_query_runner.py @@ -177,7 +177,7 @@ def create_data_warehouse_table_with_payments(self): joining_table_name="events", joining_table_key="distinct_id", field_name="events", - configuration={"experiments_optimized": True, "experiments_timestamp_field": "dw_timestamp"}, + configuration={"experiments_optimized": True, "experiments_timestamp_key": "dw_timestamp"}, ) return table_name diff --git a/posthog/warehouse/api/test/test_view_link.py b/posthog/warehouse/api/test/test_view_link.py index bac9177beb524..4bf4f697ef4a8 100644 --- a/posthog/warehouse/api/test/test_view_link.py +++ b/posthog/warehouse/api/test/test_view_link.py @@ -42,7 +42,7 @@ def test_create_with_configuration(self): "source_table_key": "uuid", "joining_table_key": "id", "field_name": "some_field", - "configuration": {"experiments_optimized": True, "experiments_timestamp_field": "timestamp"}, + "configuration": {"experiments_optimized": True, "experiments_timestamp_key": "timestamp"}, }, ) self.assertEqual(response.status_code, 201, response.content) @@ -59,7 +59,7 @@ def test_create_with_configuration(self): "joining_table_name": "persons", "joining_table_key": "id", "field_name": "some_field", - "configuration": {"experiments_optimized": True, "experiments_timestamp_field": "timestamp"}, + "configuration": {"experiments_optimized": True, "experiments_timestamp_key": "timestamp"}, }, ) @@ -116,7 +116,7 @@ def test_update_with_configuration(self): response = self.client.patch( f"/api/projects/{self.team.id}/warehouse_view_links/{join.id}/", - {"configuration": {"experiments_optimized": True, "experiments_timestamp_field": "timestamp"}}, + {"configuration": {"experiments_optimized": True, "experiments_timestamp_key": "timestamp"}}, ) self.assertEqual(response.status_code, 200, response.content) view_link = response.json() @@ -132,13 +132,11 @@ def test_update_with_configuration(self): "joining_table_name": "persons", "joining_table_key": "id", "field_name": "some_field", - "configuration": {"experiments_optimized": True, "experiments_timestamp_field": "timestamp"}, + "configuration": {"experiments_optimized": True, "experiments_timestamp_key": "timestamp"}, }, ) join.refresh_from_db() - self.assertEqual( - join.configuration, {"experiments_optimized": True, "experiments_timestamp_field": "timestamp"} - ) + self.assertEqual(join.configuration, {"experiments_optimized": True, "experiments_timestamp_key": "timestamp"}) def test_delete(self): response = self.client.post( diff --git a/posthog/warehouse/models/join.py b/posthog/warehouse/models/join.py index 6fd9c319cd803..b091c476cf23c 100644 --- a/posthog/warehouse/models/join.py +++ b/posthog/warehouse/models/join.py @@ -106,9 +106,9 @@ def _join_function_for_experiments( if not self.configuration.get("experiments_optimized"): raise ResolutionError("experiments_optimized is not enabled for this join") - timestamp_field = self.configuration.get("experiments_timestamp_field") - if not timestamp_field: - raise ResolutionError("experiments_timestamp_field is not set for this join") + timestamp_key = self.configuration.get("experiments_timestamp_key") + if not timestamp_key: + raise ResolutionError("experiments_timestamp_key is not set for this join") return ast.JoinExpr( table=ast.SelectQuery( @@ -165,7 +165,7 @@ def _join_function_for_experiments( left=ast.Field( chain=[ join_to_add.from_table, - timestamp_field, + timestamp_key, ] ), op=ast.CompareOperationOp.GtEq,