diff --git a/ee/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr b/ee/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr index fb9003b341b61..fd0b7d5358f5f 100644 --- a/ee/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr +++ b/ee/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr @@ -194,9 +194,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -232,9 +231,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -265,9 +263,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -303,9 +300,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -336,9 +332,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -374,9 +369,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -407,9 +401,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -445,9 +438,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -478,9 +470,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -528,9 +519,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -561,9 +551,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -611,9 +600,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -644,9 +632,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -694,9 +681,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -727,9 +713,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -777,9 +762,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -810,9 +794,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -848,9 +831,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -881,9 +863,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -919,9 +900,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -952,9 +932,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -990,9 +969,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1023,9 +1001,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1061,9 +1038,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1097,9 +1073,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1133,9 +1108,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1169,9 +1143,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1205,9 +1178,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1246,9 +1218,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1287,9 +1258,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1328,9 +1298,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1369,9 +1338,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1411,9 +1379,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1453,9 +1420,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1495,9 +1461,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1537,9 +1502,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/frontend/src/lib/lemon-ui/LemonSwitch/LemonSwitch.tsx b/frontend/src/lib/lemon-ui/LemonSwitch/LemonSwitch.tsx index c77e374a62133..9dc79c902c10d 100644 --- a/frontend/src/lib/lemon-ui/LemonSwitch/LemonSwitch.tsx +++ b/frontend/src/lib/lemon-ui/LemonSwitch/LemonSwitch.tsx @@ -18,7 +18,7 @@ export interface LemonSwitchProps { /** Like plain `disabled`, except we enforce a reason to be shown in the tooltip. */ disabledReason?: string | null | false 'data-attr'?: string - tooltip?: string | null + tooltip?: string | JSX.Element | null handleContent?: React.ReactElement | null 'aria-label'?: string } diff --git a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.test.ts b/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.test.ts index 4922cc0b66a7b..902907830c7d1 100644 --- a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.test.ts +++ b/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.test.ts @@ -81,6 +81,44 @@ describe('actionsAndEventsToSeries', () => { expect(result[0].kind).toEqual(NodeKind.EventsNode) }) + + it('converts funnels math types', () => { + const actions: ActionFilter[] = [ + { type: 'actions', id: '1', order: 0, name: 'item1', math: 'total' }, + { type: 'actions', id: '1', order: 1, name: 'item2', math: 'first_time_for_user' }, + ] + const events: ActionFilter[] = [ + { id: '$pageview', type: 'events', order: 2, name: 'item3', math: 'total' }, + { id: '$autocapture', type: 'events', order: 3, name: 'item4', math: 'first_time_for_user' }, + ] + + const result = actionsAndEventsToSeries({ events, actions }, false, MathAvailability.FunnelsOnly) + + expect(result).toEqual([ + { + kind: NodeKind.ActionsNode, + id: '1', + name: 'item1', + }, + { + kind: NodeKind.ActionsNode, + id: '1', + name: 'item2', + math: BaseMathType.FirstTimeForUser, + }, + { + kind: NodeKind.EventsNode, + event: '$pageview', + name: 'item3', + }, + { + kind: NodeKind.EventsNode, + event: '$autocapture', + name: 'item4', + math: BaseMathType.FirstTimeForUser, + }, + ]) + }) }) describe('hiddenLegendKeysToIndexes', () => { @@ -598,6 +636,27 @@ describe('filtersToQueryNode', () => { } expect(result).toEqual(query) }) + + it('converts math type', () => { + const filters: Partial = { + events: [{ id: '$pageview', type: 'events', order: 0, math: BaseMathType.FirstTimeForUser }], + insight: InsightType.FUNNELS, + } + + const result = filtersToQueryNode(filters) + + const query: FunnelsQuery = { + kind: NodeKind.FunnelsQuery, + series: [ + { + kind: NodeKind.EventsNode, + event: '$pageview', + math: BaseMathType.FirstTimeForUser, + }, + ], + } + expect(result).toEqual(query) + }) }) describe('retention filter', () => { diff --git a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts b/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts index 90c0c007c06b8..6acf6bd829c0b 100644 --- a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts +++ b/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts @@ -27,6 +27,7 @@ import { InsightQueryNode, InsightsQueryBase, LifecycleFilter, + MathType, NodeKind, PathsFilter, RetentionFilter, @@ -83,6 +84,8 @@ const actorsOnlyMathTypes = [ HogQLMathType.HogQL, ] +const funnelsMathTypes = [BaseMathType.FirstTimeForUser] + type FilterTypeActionsAndEvents = { events?: ActionFilter[] actions?: ActionFilter[] @@ -122,6 +125,13 @@ export const legacyEntityToNode = ( ...shared, math: BaseMathType.UniqueUsers, } + } else if (mathAvailability === MathAvailability.FunnelsOnly) { + if (funnelsMathTypes.includes(entity.math as any)) { + shared = { + ...shared, + math: entity.math as MathType, + } + } } else { shared = { ...shared, @@ -283,6 +293,8 @@ export const filtersToQueryNode = (filters: Partial): InsightQueryNo includeMath = MathAvailability.All } else if (isStickinessQuery(query)) { includeMath = MathAvailability.ActorsOnly + } else if (isFunnelsQuery(query)) { + includeMath = MathAvailability.FunnelsOnly } const { events, actions, data_warehouse } = filters diff --git a/frontend/src/scenes/insights/EditorFilters/FunnelsQuerySteps.tsx b/frontend/src/scenes/insights/EditorFilters/FunnelsQuerySteps.tsx index c21895d997a69..57d185d93866a 100644 --- a/frontend/src/scenes/insights/EditorFilters/FunnelsQuerySteps.tsx +++ b/frontend/src/scenes/insights/EditorFilters/FunnelsQuerySteps.tsx @@ -1,6 +1,8 @@ import { useActions, useValues } from 'kea' import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types' +import { FEATURE_FLAGS } from 'lib/constants' import { LemonLabel } from 'lib/lemon-ui/LemonLabel/LemonLabel' +import { featureFlagLogic } from 'lib/logic/featureFlagLogic' import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow' import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic' import { keyForInsightLogicProps } from 'scenes/insights/sharedUtils' @@ -23,19 +25,24 @@ export function FunnelsQuerySteps({ insightProps }: EditorFilterProps): JSX.Elem const { series, querySource } = useValues(insightVizDataLogic(insightProps)) const { updateQuerySource } = useActions(insightVizDataLogic(insightProps)) - if (!isInsightQueryNode(querySource)) { - return null - } + const { featureFlags } = useValues(featureFlagLogic) + const mathAvailability = featureFlags[FEATURE_FLAGS.FIRST_TIME_FOR_USER_MATH] + ? MathAvailability.FunnelsOnly + : MathAvailability.None - const actionFilters = queryNodeToFilter(querySource) + const actionFilters = isInsightQueryNode(querySource) ? queryNodeToFilter(querySource) : null const setActionFilters = (payload: Partial): void => { updateQuerySource({ - series: actionsAndEventsToSeries(payload as any, true, MathAvailability.None), + series: actionsAndEventsToSeries(payload as any, true, mathAvailability), } as FunnelsQuery) } const { groupsTaxonomicTypes, showGroupsOptions } = useValues(groupsModel) + if (!actionFilters) { + return null + } + const filterSteps = series || [] const showSeriesIndicator = (series || []).length > 0 @@ -55,7 +62,7 @@ export function FunnelsQuerySteps({ insightProps }: EditorFilterProps): JSX.Elem filters={actionFilters} setFilters={setActionFilters} typeKey={keyForInsightLogicProps('new')(insightProps)} - mathAvailability={MathAvailability.None} + mathAvailability={mathAvailability} hideDeleteBtn={filterSteps.length === 1} buttonCopy="Add step" showSeriesIndicator={showSeriesIndicator} diff --git a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx index 32f7651006293..a1ecdd39c48c4 100644 --- a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx +++ b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx @@ -3,8 +3,16 @@ import './ActionFilterRow.scss' import { DraggableSyntheticListeners } from '@dnd-kit/core' import { useSortable } from '@dnd-kit/sortable' import { CSS } from '@dnd-kit/utilities' -import { IconCopy, IconFilter, IconPencil, IconTrash, IconWarning } from '@posthog/icons' -import { LemonSelect, LemonSelectOption, LemonSelectOptions } from '@posthog/lemon-ui' +import { IconCopy, IconEllipsis, IconFilter, IconPencil, IconTrash, IconWarning } from '@posthog/icons' +import { + LemonBadge, + LemonCheckbox, + LemonDivider, + LemonMenu, + LemonSelect, + LemonSelectOption, + LemonSelectOptions, +} from '@posthog/lemon-ui' import { BuiltLogic, useActions, useValues } from 'kea' import { EntityFilterInfo } from 'lib/components/EntityFilterInfo' import { HogQLEditor } from 'lib/components/HogQLEditor/HogQLEditor' @@ -61,6 +69,7 @@ const DragHandle = (props: DraggableSyntheticListeners | undefined): JSX.Element export enum MathAvailability { All, ActorsOnly, + FunnelsOnly, None, } @@ -160,6 +169,7 @@ export function ActionFilterRow({ const { dataWarehouseTablesMap } = useValues(databaseTableListLogic) const [isHogQLDropdownVisible, setIsHogQLDropdownVisible] = useState(false) + const [isMenuVisible, setIsMenuVisible] = useState(false) const { setNodeRef, attributes, transform, transition, listeners, isDragging } = useSortable({ id: filter.uuid }) @@ -176,19 +186,30 @@ export function ActionFilterRow({ const onClose = (): void => { removeLocalFilter({ ...filter, index }) } - const onMathSelect = (_: unknown, selectedMath: string): void => { + const onMathSelect = (_: unknown, selectedMath?: string): void => { + const mathProperties = selectedMath + ? { + ...mathTypeToApiValues(selectedMath), + math_property: + mathDefinitions[selectedMath]?.category === MathCategory.PropertyValue + ? mathProperty ?? '$time' + : undefined, + math_hogql: + mathDefinitions[selectedMath]?.category === MathCategory.HogQLExpression + ? mathHogQL ?? 'count()' + : undefined, + } + : { + math_property: undefined, + math_hogql: undefined, + math_group_type_index: undefined, + math: undefined, + } + updateFilterMath({ - ...mathTypeToApiValues(selectedMath), - math_property: - mathDefinitions[selectedMath]?.category === MathCategory.PropertyValue - ? mathProperty ?? '$time' - : undefined, - math_hogql: - mathDefinitions[selectedMath]?.category === MathCategory.HogQLExpression - ? mathHogQL ?? 'count()' - : undefined, - type: filter.type, index, + type: filter.type, + ...mathProperties, }) } const onMathPropertySelect = (_: unknown, property: string): void => { @@ -284,18 +305,24 @@ export function ActionFilterRow({ ) + const enablePopup = mathAvailability === MathAvailability.FunnelsOnly + const renameRowButton = ( } title="Rename graph series" data-attr={`show-prop-rename-${index}`} - noPadding + noPadding={!enablePopup} onClick={() => { + setIsMenuVisible(false) selectFilter(filter) onRenameClick() }} - /> + fullWidth={enablePopup} + > + {enablePopup ? 'Rename' : undefined} + ) const duplicateRowButton = ( @@ -304,22 +331,32 @@ export function ActionFilterRow({ icon={} title="Duplicate graph series" data-attr={`show-prop-duplicate-${index}`} - noPadding + noPadding={!enablePopup} onClick={() => { + setIsMenuVisible(false) duplicateFilter(filter) }} - /> + fullWidth={enablePopup} + > + {enablePopup ? 'Duplicate' : undefined} + ) const deleteButton = ( } - title="Delete graph series" + // title="Delete graph series" data-attr={`delete-prop-filter-${index}`} - noPadding - onClick={onClose} - /> + noPadding={!enablePopup} + onClick={() => { + setIsMenuVisible(false) + onClose() + }} + fullWidth={enablePopup} + > + {enablePopup ? 'Delete' : undefined} + ) const rowStartElements = [ @@ -329,7 +366,7 @@ export function ActionFilterRow({ const rowEndElements = !readOnly ? [ - !hideFilter && propertyFiltersButton, + !hideFilter && !enablePopup && propertyFiltersButton, !hideRename && renameRowButton, !hideDuplicate && !singleFilter && duplicateRowButton, !hideDeleteBtn && !singleFilter && deleteButton, @@ -369,111 +406,180 @@ export function ActionFilterRow({
{filterElement}
{customRowSuffix !== undefined && <>{suffix}} - {mathAvailability !== MathAvailability.None && ( - <> - - {mathDefinitions[math || BaseMathType.TotalCount]?.category === - MathCategory.PropertyValue && ( -
- onMathPropertySelect(index, currentValue)} - eventNames={name ? [name] : []} - data-attr="math-property-select" - renderValue={(currentValue) => ( - - Calculate{' '} - {mathDefinitions[math ?? ''].name.toLowerCase()} of - the session duration. This is based on the{' '} - $session_id property associated with - events. The duration is derived from the time - difference between the first and last event for each - distinct $session_id. - - ) : ( - <> - Calculate{' '} - {mathDefinitions[math ?? ''].name.toLowerCase()}{' '} - from property {currentValue}. Note that - only {name} occurences where{' '} - {currentValue} is set with a numeric - value will be taken into account. - - ) + {mathAvailability !== MathAvailability.None && + mathAvailability !== MathAvailability.FunnelsOnly && ( + <> + + {mathDefinitions[math || BaseMathType.TotalCount]?.category === + MathCategory.PropertyValue && ( +
+ + onMathPropertySelect(index, currentValue) + } + eventNames={name ? [name] : []} + data-attr="math-property-select" + renderValue={(currentValue) => ( + + Calculate{' '} + {mathDefinitions[math ?? ''].name.toLowerCase()}{' '} + of the session duration. This is based on the{' '} + $session_id property associated + with events. The duration is derived from the + time difference between the first and last event + for each distinct $session_id. + + ) : ( + <> + Calculate{' '} + {mathDefinitions[math ?? ''].name.toLowerCase()}{' '} + from property {currentValue}. Note + that only {name} occurences where{' '} + {currentValue} is set with a + numeric value will be taken into account. + + ) + } + placement="right" + > + + + )} + /> +
+ )} + {mathDefinitions[math || BaseMathType.TotalCount]?.category === + MathCategory.HogQLExpression && ( +
+ setIsHogQLDropdownVisible(false)} + overlay={ + // eslint-disable-next-line react/forbid-dom-props +
+ { + onMathHogQLSelect(index, currentValue) + setIsHogQLDropdownVisible(false) + }} + /> +
+ } + > + + setIsHogQLDropdownVisible(!isHogQLDropdownVisible) } - placement="right" > - - - )} - /> -
- )} - {mathDefinitions[math || BaseMathType.TotalCount]?.category === - MathCategory.HogQLExpression && ( -
- {mathHogQL} + + +
+ )} + + )} +
+ {/* right section fixed */} + {rowEndElements.length ? ( +
+ {mathAvailability === MathAvailability.FunnelsOnly ? ( + <> + {!hideFilter && propertyFiltersButton} +
+ setIsHogQLDropdownVisible(false)} - overlay={ - // eslint-disable-next-line react/forbid-dom-props -
- { - onMathHogQLSelect(index, currentValue) - setIsHogQLDropdownVisible(false) - }} - /> -
- } + onVisibilityChange={setIsMenuVisible} + items={[ + { + label: () => ( + <> + { + onMathSelect( + index, + checked + ? BaseMathType.FirstTimeForUser + : undefined + ) + }} + data-attr={`math-first-time-for-user-${index}`} + label="Count by first time for user" + fullWidth + /> + + + ), + }, + { + label: () => renameRowButton, + }, + { + label: () => duplicateRowButton, + }, + { + label: () => deleteButton, + }, + ]} > setIsHogQLDropdownVisible(!isHogQLDropdownVisible)} - > - {mathHogQL} - - + size="medium" + aria-label="Show more actions" + data-attr={`more-button-${index}`} + icon={} + noPadding + /> +
+
- )} - - )} -
- {/* right section fixed */} - {rowEndElements.length ?
{rowEndElements}
: null} + + ) : ( + rowEndElements + )} +
+ ) : null} )} diff --git a/frontend/src/scenes/retention/retentionTableLogic.ts b/frontend/src/scenes/retention/retentionTableLogic.ts index 3fd153edebcc6..0969d1ffa6f53 100644 --- a/frontend/src/scenes/retention/retentionTableLogic.ts +++ b/frontend/src/scenes/retention/retentionTableLogic.ts @@ -81,19 +81,19 @@ export const retentionTableLogic = kea([ } else { switch (period) { case 'Hour': - firstColumn = dayjs(currentResult.date).format('MMM D, h A') + firstColumn = dayjs.utc(currentResult.date).format('MMM D, h A') break case 'Month': - firstColumn = dayjs(currentResult.date).format('MMM YYYY') + firstColumn = dayjs.utc(currentResult.date).format('MMM YYYY') break case 'Week': { - const startDate = dayjs(currentResult.date) + const startDate = dayjs.utc(currentResult.date) const endDate = startDate.add(6, 'day') // To show last day of the week we add 6 days, not 7 firstColumn = `${startDate.format('MMM D')} to ${endDate.format('MMM D')}` break } default: - firstColumn = dayjs(currentResult.date).format('MMM D') + firstColumn = dayjs.utc(currentResult.date).format('MMM D') } } diff --git a/plugin-server/src/worker/ingestion/property-definitions-manager.ts b/plugin-server/src/worker/ingestion/property-definitions-manager.ts index 3b45278504ec6..fd99af328958d 100644 --- a/plugin-server/src/worker/ingestion/property-definitions-manager.ts +++ b/plugin-server/src/worker/ingestion/property-definitions-manager.ts @@ -134,7 +134,7 @@ export class PropertyDefinitionsManager { this.syncEventDefinitions(team, event), this.syncEventProperties(team, event, properties), this.syncPropertyDefinitions(team, event, properties), - this.teamManager.setTeamIngestedEvent(team), + this.teamManager.setTeamIngestedEvent(team, properties), ]) } finally { clearTimeout(timeout) diff --git a/plugin-server/src/worker/ingestion/team-manager.ts b/plugin-server/src/worker/ingestion/team-manager.ts index 202bb0d914660..b7742e6c0c746 100644 --- a/plugin-server/src/worker/ingestion/team-manager.ts +++ b/plugin-server/src/worker/ingestion/team-manager.ts @@ -1,3 +1,4 @@ +import { Properties } from '@posthog/plugin-scaffold' import LRU from 'lru-cache' import { ONE_MINUTE } from '../../config/constants' @@ -5,6 +6,7 @@ import { TeamIDWithConfig } from '../../main/ingestion-queues/session-recording/ import { PipelineEvent, PluginsServerConfig, Team, TeamId } from '../../types' import { PostgresRouter, PostgresUse } from '../../utils/db/postgres' import { timeoutGuard } from '../../utils/db/utils' +import { posthog } from '../../utils/posthog' export class TeamManager { postgres: PostgresRouter @@ -102,7 +104,7 @@ export class TeamManager { } } - public async setTeamIngestedEvent(team: Team) { + public async setTeamIngestedEvent(team: Team, properties: Properties) { if (team && !team.ingested_event) { await this.postgres.query( PostgresUse.COMMON_WRITE, @@ -111,11 +113,37 @@ export class TeamManager { 'setTeamIngestedEvent' ) - // This doesn't totally stop the first event from being spammed if a - // new team suddenly gets a lot of events, since other pods will still - // wait a while before pulling the team data from the DB, but it might - // help a bit. + // So long as team id is used as the partition key, this helps avoid + // double-firing of the first events, but it's not perfect (pod crashes + // or other rebalances, for example, can still cause double-firing). Exactly + // once is hard. this.teamCache.set(team.id, { ...team, ingested_event: true }) + + // First event for the team captured - we fire this because comms and others rely on this event for onboarding flows in downstream systems (e.g. customer.io) + const organizationMembers = await this.postgres.query( + PostgresUse.COMMON_WRITE, + 'SELECT distinct_id FROM posthog_user JOIN posthog_organizationmembership ON posthog_user.id = posthog_organizationmembership.user_id WHERE organization_id = $1', + [team.organization_id], + 'posthog_organizationmembership' + ) + const distinctIds: { distinct_id: string }[] = organizationMembers.rows + for (const { distinct_id } of distinctIds) { + posthog.capture({ + distinctId: distinct_id, + event: 'first team event ingested', + properties: { + team: team.uuid, + sdk: properties.$lib, + realm: properties.realm, + host: properties.$host, + }, + groups: { + project: team.uuid, + organization: team.organization_id, + instance: this.instanceSiteUrl, + }, + }) + } } } } diff --git a/plugin-server/tests/main/process-event.test.ts b/plugin-server/tests/main/process-event.test.ts index c2d5fccae8152..e1c582becda7c 100644 --- a/plugin-server/tests/main/process-event.test.ts +++ b/plugin-server/tests/main/process-event.test.ts @@ -1224,6 +1224,19 @@ test('capture first team event', async () => { new UUIDT().toString() ) + expect(posthog.capture).toHaveBeenCalledWith({ + distinctId: 'plugin_test_user_distinct_id_1001', + event: 'first team event ingested', + properties: { + team: team.uuid, + }, + groups: { + project: team.uuid, + organization: team.organization_id, + instance: 'unknown', + }, + }) + team = await getFirstTeam(hub) expect(team.ingested_event).toEqual(true) diff --git a/posthog/api/test/__snapshots__/test_query.ambr b/posthog/api/test/__snapshots__/test_query.ambr index 4598a9a6a3253..fbea79986c2ba 100644 --- a/posthog/api/test/__snapshots__/test_query.ambr +++ b/posthog/api/test/__snapshots__/test_query.ambr @@ -15,9 +15,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -37,9 +36,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -59,9 +57,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -81,9 +78,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -103,9 +99,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -125,9 +120,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -143,9 +137,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -161,9 +154,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -179,9 +171,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -199,9 +190,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -219,9 +209,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -239,9 +228,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -263,9 +251,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -285,9 +272,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -307,9 +293,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -329,9 +314,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -351,9 +335,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -373,9 +356,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -395,9 +377,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -417,9 +398,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -439,9 +419,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -479,9 +458,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -519,9 +497,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -539,9 +516,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -560,9 +536,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -580,9 +555,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -601,9 +575,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -621,9 +594,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -642,9 +614,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -661,9 +632,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -681,9 +651,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -701,9 +670,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/clickhouse/client/execute.py b/posthog/clickhouse/client/execute.py index 317fa66755e8a..1fcc1402c948a 100644 --- a/posthog/clickhouse/client/execute.py +++ b/posthog/clickhouse/client/execute.py @@ -47,6 +47,9 @@ def default_settings() -> dict: return { "join_algorithm": "direct,parallel_hash,hash", "distributed_replica_max_ignored_errors": 1000, + # max_query_size can't be set in a query, because it determines the size of the buffer used to parse the query + # https://clickhouse.com/docs/en/operations/settings/settings#max_query_size + "max_query_size": 1048576, } diff --git a/posthog/clickhouse/client/test/__snapshots__/test_execute_async.ambr b/posthog/clickhouse/client/test/__snapshots__/test_execute_async.ambr index 82072cc8ef027..4eebf577dab69 100644 --- a/posthog/clickhouse/client/test/__snapshots__/test_execute_async.ambr +++ b/posthog/clickhouse/client/test/__snapshots__/test_execute_async.ambr @@ -7,9 +7,8 @@ max_execution_time=600, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/heatmaps/test/__snapshots__/test_heatmaps_api.ambr b/posthog/heatmaps/test/__snapshots__/test_heatmaps_api.ambr index 2fa2e26e9e367..b53d60c32151f 100644 --- a/posthog/heatmaps/test/__snapshots__/test_heatmaps_api.ambr +++ b/posthog/heatmaps/test/__snapshots__/test_heatmaps_api.ambr @@ -20,9 +20,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -47,9 +46,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -74,9 +72,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -101,9 +98,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -128,9 +124,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -155,9 +150,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -182,9 +176,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -209,9 +202,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -236,9 +228,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -263,9 +254,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -290,9 +280,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -317,9 +306,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -344,9 +332,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -371,9 +358,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -398,9 +384,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -425,9 +410,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -452,9 +436,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -479,9 +462,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -506,9 +488,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -533,9 +514,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -560,9 +540,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -587,9 +566,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -614,9 +592,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -641,9 +618,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -668,9 +644,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -695,9 +670,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -722,9 +696,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -749,9 +722,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -776,9 +748,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -803,9 +774,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/hogql/constants.py b/posthog/hogql/constants.py index 02e29cbfad351..557cbfd05c01e 100644 --- a/posthog/hogql/constants.py +++ b/posthog/hogql/constants.py @@ -101,8 +101,7 @@ class HogQLGlobalSettings(HogQLQuerySettings): max_execution_time: Optional[int] = 60 allow_experimental_object_type: Optional[bool] = True format_csv_allow_double_quotes: Optional[bool] = False - max_ast_elements: Optional[int] = 2_000_000 # default value 50000 - max_expanded_ast_elements: Optional[int] = 2_000_000 - max_query_size: Optional[int] = 262144 * 4 # default value 262144 (= 256 KiB) + max_ast_elements: Optional[int] = 4_000_000 # default value 50000 + max_expanded_ast_elements: Optional[int] = 4_000_000 max_bytes_before_external_group_by: Optional[int] = 0 # default value means we don't swap ordering by to disk allow_experimental_analyzer: Optional[bool] = None diff --git a/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.ambr b/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.ambr index 1cbecfd53c1f5..95d6d8919921d 100644 --- a/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.ambr +++ b/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.ambr @@ -17,9 +17,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -43,9 +42,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -69,9 +67,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -90,9 +87,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -111,9 +107,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -134,9 +129,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -173,9 +167,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -196,9 +189,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -226,9 +218,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -262,9 +253,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -298,9 +288,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -334,9 +323,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -359,9 +347,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -377,9 +364,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/hogql/database/test/test_database.py b/posthog/hogql/database/test/test_database.py index 661c36d2e4d5a..73d86544f5c33 100644 --- a/posthog/hogql/database/test/test_database.py +++ b/posthog/hogql/database/test/test_database.py @@ -216,7 +216,7 @@ def test_database_with_warehouse_tables(self, patch_execute): self.assertEqual( response.clickhouse, - f"SELECT whatever.id AS id FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_3_sensitive)s, %(hogql_val_4_sensitive)s, %(hogql_val_1)s, %(hogql_val_2)s) AS whatever LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0", + f"SELECT whatever.id AS id FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_3_sensitive)s, %(hogql_val_4_sensitive)s, %(hogql_val_1)s, %(hogql_val_2)s) AS whatever LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0", ) def test_database_group_type_mappings(self): diff --git a/posthog/hogql/functions/test/__snapshots__/test_cohort.ambr b/posthog/hogql/functions/test/__snapshots__/test_cohort.ambr index bd4cef607d721..58f4492899fa8 100644 --- a/posthog/hogql/functions/test/__snapshots__/test_cohort.ambr +++ b/posthog/hogql/functions/test/__snapshots__/test_cohort.ambr @@ -12,7 +12,7 @@ GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0))), equals(events.event, %(hogql_val_0)s)) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -38,7 +38,7 @@ FROM person_static_cohort WHERE and(equals(person_static_cohort.team_id, 420), equals(person_static_cohort.cohort_id, XX))))) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -62,7 +62,7 @@ FROM person_static_cohort WHERE and(equals(person_static_cohort.team_id, 420), equals(person_static_cohort.cohort_id, XX))))) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL diff --git a/posthog/hogql/functions/test/test_sparkline.py b/posthog/hogql/functions/test/test_sparkline.py index 9e5dfdb33042a..c7dfa946140e5 100644 --- a/posthog/hogql/functions/test/test_sparkline.py +++ b/posthog/hogql/functions/test/test_sparkline.py @@ -8,7 +8,7 @@ def test_sparkline(self): response = execute_hogql_query("select sparkline([1,2,3])", self.team, pretty=False) self.assertEqual( response.clickhouse, - f"SELECT tuple(%(hogql_val_0)s, %(hogql_val_1)s, %(hogql_val_2)s, [1, 2, 3]) LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0", + f"SELECT tuple(%(hogql_val_0)s, %(hogql_val_1)s, %(hogql_val_2)s, [1, 2, 3]) LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0", ) self.assertEqual( response.hogql, diff --git a/posthog/hogql/test/__snapshots__/test_query.ambr b/posthog/hogql/test/__snapshots__/test_query.ambr index a5ae80eee4644..24ff3ec47cb6e 100644 --- a/posthog/hogql/test/__snapshots__/test_query.ambr +++ b/posthog/hogql/test/__snapshots__/test_query.ambr @@ -5,7 +5,7 @@ SELECT [1, 2, 3], [10, 11, 12][1] LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -19,7 +19,7 @@ SELECT arrayMap(x -> multiply(x, 2), [1, 2, 3]), 1 LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -35,7 +35,7 @@ FROM events WHERE and(equals(events.team_id, 420), equals(events.distinct_id, %(hogql_val_0)s), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', ''), %(hogql_val_2)s), 0)) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -62,7 +62,7 @@ FROM events WHERE and(equals(events.team_id, 420), equals(events.distinct_id, %(hogql_val_0)s), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', ''), %(hogql_val_2)s), 0), less(toTimeZone(events.timestamp, %(hogql_val_3)s), toDateTime64('2020-01-02 00:00:00.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, %(hogql_val_4)s), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')))) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -89,7 +89,7 @@ FROM events AS e WHERE and(equals(e.team_id, 420), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', ''), %(hogql_val_1)s), 0)) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -111,7 +111,7 @@ GROUP BY sessions.session_id, sessions.session_id) AS sessions WHERE and(ifNull(less(sessions.`$start_timestamp`, toDateTime64('2024-07-06 00:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(sessions.`$start_timestamp`, toDateTime64('2024-07-04 00:00:00.000000', 6, 'UTC')), 0)) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -142,7 +142,7 @@ GROUP BY sessions.session_id, sessions.session_id) AS sessions WHERE and(ifNull(equals(sessions.`$entry_current_url`, %(hogql_val_2)s), 0), 1) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -173,7 +173,7 @@ FROM events WHERE equals(events.team_id, 420) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -197,7 +197,7 @@ GROUP BY session_replay_events.session_id) AS s ON equals(s.session_id, nullIf(nullIf(e.`$session_id`, ''), 'null')) WHERE and(equals(e.team_id, 420), isNotNull(nullIf(nullIf(e.`$session_id`, ''), 'null'))) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -228,7 +228,7 @@ GROUP BY session_replay_events.session_id) AS s LEFT JOIN events AS e ON equals(nullIf(nullIf(e.`$session_id`, ''), 'null'), s.session_id) WHERE and(equals(e.team_id, 420), isNotNull(nullIf(nullIf(e.`$session_id`, ''), 'null'))) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -259,7 +259,7 @@ GROUP BY session_replay_events.session_id) AS s ON equals(s.session_id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', '')) WHERE and(equals(e.team_id, 420), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', ''))) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -290,7 +290,7 @@ GROUP BY session_replay_events.session_id) AS s LEFT JOIN events AS e ON equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', ''), s.session_id) WHERE and(equals(e.team_id, 420), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', ''))) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -329,7 +329,7 @@ HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0))), 0)) GROUP BY events.event LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -359,7 +359,7 @@ HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0)))) GROUP BY events.event LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -393,7 +393,7 @@ WHERE and(equals(person_static_cohort.team_id, 420), equals(person_static_cohort.cohort_id, XX)))), 0)) GROUP BY events.event LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -419,7 +419,7 @@ WHERE and(equals(person_static_cohort.team_id, 420), equals(person_static_cohort.cohort_id, XX))))) GROUP BY events.event LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -442,7 +442,7 @@ WHERE and(equals(events.team_id, 420), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', ''), %(hogql_val_1)s), 0)) GROUP BY events.event LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -470,7 +470,7 @@ SETTINGS optimize_aggregation_in_order=1) AS persons WHERE ifNull(equals(persons.properties___random_uuid, %(hogql_val_4)s), 0) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -494,7 +494,7 @@ SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) WHERE equals(e.team_id, 420) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -517,7 +517,7 @@ SETTINGS optimize_aggregation_in_order=1) AS events__pdi ON equals(events.distinct_id, events__pdi.distinct_id) WHERE equals(events.team_id, 420) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -549,7 +549,7 @@ SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.id) WHERE equals(e.team_id, 420) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -578,7 +578,7 @@ SETTINGS optimize_aggregation_in_order=1) AS events__pdi__person ON equals(events__pdi.events__pdi___person_id, events__pdi__person.id) WHERE equals(events.team_id, 420) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -610,7 +610,7 @@ SETTINGS optimize_aggregation_in_order=1) AS events__pdi__person ON equals(events__pdi.events__pdi___person_id, events__pdi__person.id) WHERE equals(events.team_id, 420) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -642,7 +642,7 @@ SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.id) WHERE equals(e.team_id, 420) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -675,7 +675,7 @@ WHERE equals(s.team_id, 420) GROUP BY s__pdi__person.properties___sneaky_mail LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -698,7 +698,7 @@ HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0)) AS pdi ON equals(e.distinct_id, pdi.distinct_id) WHERE equals(e.team_id, 420) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -733,7 +733,7 @@ HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, %(hogql_val_1)s), person.version), plus(now64(6, %(hogql_val_2)s), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS pdi__person ON equals(pdi.pdi___person_id, pdi__person.id) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -761,7 +761,7 @@ HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, %(hogql_val_1)s), person.version), plus(now64(6, %(hogql_val_2)s), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS pdi__person ON equals(pdi.pdi___person_id, pdi__person.id) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -793,7 +793,7 @@ SETTINGS optimize_aggregation_in_order=1) AS p ON equals(p.id, pdi.person_id) WHERE equals(e.team_id, 420) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -815,7 +815,7 @@ HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -847,7 +847,7 @@ SETTINGS optimize_aggregation_in_order=1) AS events__pdi__person ON equals(events__pdi.events__pdi___person_id, events__pdi__person.id) WHERE equals(events.team_id, 420) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -864,7 +864,7 @@ FROM events WHERE equals(events.team_id, 420) LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -882,7 +882,7 @@ WHERE equals(s.team_id, 420) GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(s.person_properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', '') LIMIT 10 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -904,7 +904,7 @@ GROUP BY events.event) GROUP BY count, event LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -930,7 +930,7 @@ GROUP BY events.event) AS c GROUP BY c.count, c.event LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -959,7 +959,7 @@ GROUP BY col_a) GROUP BY col_a ORDER BY col_a ASC LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -992,7 +992,7 @@ GROUP BY PIVOT_TABLE_COL_ABC.col_a) AS PIVOT_FUNCTION_1 GROUP BY PIVOT_FUNCTION_1.col_a) AS PIVOT_FUNCTION_2 ORDER BY PIVOT_FUNCTION_2.col_a ASC LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -1029,7 +1029,7 @@ GROUP BY PIVOT_TABLE_COL_ABC.col_a) AS PIVOT_FUNCTION_1 GROUP BY PIVOT_FUNCTION_1.col_a) AS PIVOT_FUNCTION_2) AS final ORDER BY final.col_a ASC LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL diff --git a/posthog/hogql/test/test_printer.py b/posthog/hogql/test/test_printer.py index 3fd48af45f147..800557e780a41 100644 --- a/posthog/hogql/test/test_printer.py +++ b/posthog/hogql/test/test_printer.py @@ -1238,7 +1238,7 @@ def test_print_global_settings(self): ) self.assertEqual( printed, - f"SELECT 1 FROM events WHERE equals(events.team_id, {self.team.pk}) LIMIT {MAX_SELECT_RETURNED_ROWS} SETTINGS readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0", + f"SELECT 1 FROM events WHERE equals(events.team_id, {self.team.pk}) LIMIT {MAX_SELECT_RETURNED_ROWS} SETTINGS readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0", ) def test_print_query_level_settings(self): @@ -1265,7 +1265,7 @@ def test_print_both_settings(self): ) self.assertEqual( printed, - f"SELECT 1 FROM events WHERE equals(events.team_id, {self.team.pk}) LIMIT {MAX_SELECT_RETURNED_ROWS} SETTINGS optimize_aggregation_in_order=1, readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0", + f"SELECT 1 FROM events WHERE equals(events.team_id, {self.team.pk}) LIMIT {MAX_SELECT_RETURNED_ROWS} SETTINGS optimize_aggregation_in_order=1, readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0", ) def test_pretty_print(self): @@ -1368,7 +1368,7 @@ def test_print_hidden_aliases_timestamp(self): printed, f"SELECT timestamp AS timestamp FROM (SELECT toTimeZone(events.timestamp, %(hogql_val_0)s), " f"toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp FROM events WHERE equals(events.team_id, {self.team.pk})) " - f"LIMIT {MAX_SELECT_RETURNED_ROWS} SETTINGS readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0", + f"LIMIT {MAX_SELECT_RETURNED_ROWS} SETTINGS readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0", ) def test_print_hidden_aliases_column_override(self): @@ -1383,7 +1383,7 @@ def test_print_hidden_aliases_column_override(self): printed, f"SELECT event AS event FROM (SELECT toTimeZone(events.timestamp, %(hogql_val_0)s) AS event, " f"event FROM events WHERE equals(events.team_id, {self.team.pk})) " - f"LIMIT {MAX_SELECT_RETURNED_ROWS} SETTINGS readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0", + f"LIMIT {MAX_SELECT_RETURNED_ROWS} SETTINGS readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0", ) def test_print_hidden_aliases_properties(self): @@ -1406,7 +1406,7 @@ def test_print_hidden_aliases_properties(self): printed, f"SELECT `$browser` AS `$browser` FROM (SELECT nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS `$browser` " f"FROM events WHERE equals(events.team_id, {self.team.pk})) LIMIT {MAX_SELECT_RETURNED_ROWS} " - f"SETTINGS readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0", + f"SETTINGS readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0", ) def test_print_hidden_aliases_double_property(self): @@ -1430,7 +1430,7 @@ def test_print_hidden_aliases_double_property(self): f"SELECT `$browser` AS `$browser` FROM (SELECT nullIf(nullIf(events.`mat_$browser`, ''), 'null'), " f"nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS `$browser` " # only the second one gets the alias f"FROM events WHERE equals(events.team_id, {self.team.pk})) LIMIT {MAX_SELECT_RETURNED_ROWS} " - f"SETTINGS readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0", + f"SETTINGS readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0", ) def test_lookup_domain_type(self): @@ -1449,9 +1449,8 @@ def test_lookup_domain_type(self): "(cutToFirstSignificantSubdomain(coalesce(%(hogql_val_0)s, '')), 'source'))) " f"FROM events WHERE equals(events.team_id, {self.team.pk}) LIMIT 50000 SETTINGS " "readonly=2, max_execution_time=10, allow_experimental_object_type=1, " - "format_csv_allow_double_quotes=0, max_ast_elements=2000000, " - "max_expanded_ast_elements=2000000, max_query_size=1048576, " - "max_bytes_before_external_group_by=0" + "format_csv_allow_double_quotes=0, max_ast_elements=4000000, " + "max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0" ), printed, ) @@ -1472,9 +1471,8 @@ def test_lookup_paid_source_type(self): "(cutToFirstSignificantSubdomain(coalesce(%(hogql_val_0)s, '')), 'source'))) " f"FROM events WHERE equals(events.team_id, {self.team.pk}) LIMIT 50000 SETTINGS " "readonly=2, max_execution_time=10, allow_experimental_object_type=1, " - "format_csv_allow_double_quotes=0, max_ast_elements=2000000, " - "max_expanded_ast_elements=2000000, max_query_size=1048576, " - "max_bytes_before_external_group_by=0" + "format_csv_allow_double_quotes=0, max_ast_elements=4000000, " + "max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0" ), printed, ) @@ -1492,7 +1490,7 @@ def test_lookup_paid_medium_type(self): "SELECT dictGetOrNull('channel_definition_dict', 'type_if_paid', " "(coalesce(%(hogql_val_0)s, ''), 'medium')) " f"FROM events WHERE equals(events.team_id, {self.team.pk}) LIMIT {MAX_SELECT_RETURNED_ROWS} SETTINGS " - "readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0" + "readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0" ), printed, ) @@ -1513,9 +1511,8 @@ def test_lookup_organic_source_type(self): "(cutToFirstSignificantSubdomain(coalesce(%(hogql_val_0)s, '')), 'source'))) " f"FROM events WHERE equals(events.team_id, {self.team.pk}) LIMIT 50000 SETTINGS " "readonly=2, max_execution_time=10, allow_experimental_object_type=1, " - "format_csv_allow_double_quotes=0, max_ast_elements=2000000, " - "max_expanded_ast_elements=2000000, max_query_size=1048576, " - "max_bytes_before_external_group_by=0" + "format_csv_allow_double_quotes=0, max_ast_elements=4000000, " + "max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0" ), printed, ) @@ -1533,7 +1530,7 @@ def test_lookup_organic_medium_type(self): "SELECT dictGetOrNull('channel_definition_dict', 'type_if_organic', " "(coalesce(%(hogql_val_0)s, ''), 'medium')) " f"FROM events WHERE equals(events.team_id, {self.team.pk}) LIMIT {MAX_SELECT_RETURNED_ROWS} SETTINGS " - "readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0" + "readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0" ), printed, ) @@ -1584,7 +1581,7 @@ def test_trim_leading_trailing_both(self): ) assert printed == ( f"SELECT trim(LEADING %(hogql_val_1)s FROM %(hogql_val_0)s), trim(TRAILING %(hogql_val_3)s FROM %(hogql_val_2)s), trim(BOTH %(hogql_val_5)s FROM %(hogql_val_4)s) LIMIT {MAX_SELECT_RETURNED_ROWS} SETTINGS " - "readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0" + "readonly=2, max_execution_time=10, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0" ) query2 = parse_select("select trimLeft('media', 'xy'), trimRight('media', 'xy'), trim('media', 'xy')") printed2 = print_ast( diff --git a/posthog/hogql/test/test_query.py b/posthog/hogql/test/test_query.py index 2fcc347dd36b7..772024ab53d8d 100644 --- a/posthog/hogql/test/test_query.py +++ b/posthog/hogql/test/test_query.py @@ -1015,7 +1015,7 @@ def test_property_access_with_arrays(self): f"FROM events " f"WHERE and(equals(events.team_id, {self.team.pk}), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_46)s), ''), 'null'), '^\"|\"$', ''), %(hogql_val_47)s), 0)) " f"LIMIT 100 " - f"SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0", + f"SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0", response.clickhouse, ) self.assertEqual(response.results[0], tuple(random_uuid for x in alternatives)) diff --git a/posthog/hogql/transforms/test/__snapshots__/test_in_cohort.ambr b/posthog/hogql/transforms/test/__snapshots__/test_in_cohort.ambr index 474fa9e1c8037..66203f817267f 100644 --- a/posthog/hogql/transforms/test/__snapshots__/test_in_cohort.ambr +++ b/posthog/hogql/transforms/test/__snapshots__/test_in_cohort.ambr @@ -10,7 +10,7 @@ WHERE and(equals(cohortpeople.team_id, 420), equals(cohortpeople.cohort_id, XX), equals(cohortpeople.version, 0))) AS __in_cohort ON equals(__in_cohort.cohort_person_id, events.person_id) WHERE and(equals(events.team_id, 420), and(1, equals(events.event, %(hogql_val_0)s)), ifNull(equals(__in_cohort.matched, 1), 0)) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -34,7 +34,7 @@ WHERE and(equals(person_static_cohort.team_id, 420), in(person_static_cohort.cohort_id, [13]))) AS __in_cohort ON equals(__in_cohort.cohort_person_id, events.person_id) WHERE and(equals(events.team_id, 420), 1, ifNull(equals(__in_cohort.matched, 1), 0)) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -58,7 +58,7 @@ WHERE and(equals(person_static_cohort.team_id, 420), in(person_static_cohort.cohort_id, [14]))) AS __in_cohort ON equals(__in_cohort.cohort_person_id, events.person_id) WHERE and(equals(events.team_id, 420), 1, ifNull(equals(__in_cohort.matched, 1), 0)) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -84,7 +84,7 @@ HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0)) AS in_cohort__XX ON equals(in_cohort__XX.person_id, events.person_id) WHERE and(equals(events.team_id, 420), ifNull(equals(in_cohort__XX.matched, 1), 0), equals(events.event, %(hogql_val_0)s)) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -110,7 +110,7 @@ WHERE and(equals(person_static_cohort.team_id, 420), equals(person_static_cohort.cohort_id, XX))) AS in_cohort__XX ON equals(in_cohort__XX.person_id, events.person_id) WHERE and(equals(events.team_id, 420), ifNull(equals(in_cohort__XX.matched, 1), 0)) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL @@ -134,7 +134,7 @@ WHERE and(equals(person_static_cohort.team_id, 420), equals(person_static_cohort.cohort_id, XX))) AS in_cohort__XX ON equals(in_cohort__XX.person_id, events.person_id) WHERE and(equals(events.team_id, 420), ifNull(equals(in_cohort__XX.matched, 1), 0)) LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, max_bytes_before_external_group_by=0 + SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 -- HogQL diff --git a/posthog/hogql_queries/actors_query_runner.py b/posthog/hogql_queries/actors_query_runner.py index 4cda01240f19e..ba7301b5e0c51 100644 --- a/posthog/hogql_queries/actors_query_runner.py +++ b/posthog/hogql_queries/actors_query_runner.py @@ -267,7 +267,11 @@ def to_query(self) -> ast.SelectQuery: # For some of our users, the persons table is large. If we're looking for person, # help make the join smarter by limiting the people it has to look up # The persons table inlines `in` conditions on the join (see `persons.py`) - if isinstance(self.strategy, PersonStrategy): + # Funnels queries are very big. Don't do this for funnels as it blows up the query size. + if isinstance(self.strategy, PersonStrategy) and not ( + isinstance(self.source_query_runner, InsightActorsQueryRunner) + and isinstance(self.source_query_runner.source_runner, FunnelsQueryRunner) + ): join_on = ast.And( exprs=[ join_on, diff --git a/posthog/hogql_queries/insights/funnels/base.py b/posthog/hogql_queries/insights/funnels/base.py index f1eac3cdc2d7b..477c205dd968c 100644 --- a/posthog/hogql_queries/insights/funnels/base.py +++ b/posthog/hogql_queries/insights/funnels/base.py @@ -1,12 +1,16 @@ +import uuid from abc import ABC from functools import cached_property from typing import Any, Optional, Union, cast -import uuid + +from rest_framework.exceptions import ValidationError + from posthog.clickhouse.materialized_columns.column import ColumnName from posthog.hogql import ast from posthog.hogql.constants import get_breakdown_limit_for_context from posthog.hogql.parser import parse_expr, parse_select from posthog.hogql.property import action_to_expr, property_to_expr +from posthog.hogql_queries.insights.funnels.funnel_aggregation_operations import FirstTimeForUserAggregationQuery from posthog.hogql_queries.insights.funnels.funnel_event_query import FunnelEventQuery from posthog.hogql_queries.insights.funnels.funnel_query_context import FunnelQueryContext from posthog.hogql_queries.insights.funnels.utils import ( @@ -17,10 +21,11 @@ from posthog.models.action.action import Action from posthog.models.cohort.cohort import Cohort from posthog.models.property.property import PropertyName -from posthog.queries.util import correct_result_for_sampling from posthog.queries.breakdown_props import ALL_USERS_COHORT_ID, get_breakdown_cohort_name +from posthog.queries.util import correct_result_for_sampling from posthog.schema import ( ActionsNode, + BaseMathType, BreakdownAttributionType, BreakdownType, DataWarehouseNode, @@ -30,7 +35,6 @@ FunnelVizType, ) from posthog.types import EntityNode, ExclusionEntityNode -from rest_framework.exceptions import ValidationError class FunnelBase(ABC): @@ -573,6 +577,8 @@ def _build_step_query( entity_name: str, step_prefix: str, ) -> ast.Expr: + filters: list[ast.Expr] = [] + if isinstance(entity, ActionsNode) or isinstance(entity, FunnelExclusionActionsNode): # action action = Action.objects.get(pk=int(entity.id), team=self.context.team) @@ -586,12 +592,21 @@ def _build_step_query( # event event_expr = parse_expr("event = {event}", {"event": ast.Constant(value=entity.event)}) + filters.append(event_expr) + + filter_expr: ast.Expr | None = None if entity.properties is not None and entity.properties != []: # add property filters filter_expr = property_to_expr(entity.properties, self.context.team) - return ast.And(exprs=[event_expr, filter_expr]) - else: - return event_expr + filters.append(filter_expr) + + if entity.math == BaseMathType.FIRST_TIME_FOR_USER: + subquery = FirstTimeForUserAggregationQuery(self.context, filter_expr, event_expr).to_query() + first_time_filter = parse_expr("e.uuid IN {subquery}", placeholders={"subquery": subquery}) + return ast.And(exprs=[*filters, first_time_filter]) + elif len(filters) > 1: + return ast.And(exprs=filters) + return filters[0] def _get_timestamp_outer_select(self) -> list[ast.Expr]: if self.context.includePrecedingTimestamp: diff --git a/posthog/hogql_queries/insights/funnels/funnel_aggregation_operations.py b/posthog/hogql_queries/insights/funnels/funnel_aggregation_operations.py new file mode 100644 index 0000000000000..37978754a14a3 --- /dev/null +++ b/posthog/hogql_queries/insights/funnels/funnel_aggregation_operations.py @@ -0,0 +1,79 @@ +from typing import cast + +from posthog.hogql import ast +from posthog.hogql_queries.insights.funnels.funnel_query_context import FunnelQueryContext +from posthog.hogql_queries.insights.utils.aggregations import FirstTimeForUserEventsQueryAlternator +from posthog.hogql_queries.utils.query_date_range import QueryDateRange + + +class FirstTimeForUserAggregationQuery: + _context: FunnelQueryContext + _filters: ast.Expr | None + _event_or_action_filter: ast.Expr | None + + def __init__( + self, + context: FunnelQueryContext, + filters: ast.Expr | None = None, + event_or_action_filter: ast.Expr | None = None, + ): + self._context = context + self._filters = filters + self._event_or_action_filter = event_or_action_filter + + def to_query(self) -> ast.SelectQuery: + query = ast.SelectQuery( + select=[ast.Field(chain=["uuid"])], + select_from=ast.JoinExpr(table=self._inner_query()), + ) + return query + + def _inner_query(self) -> ast.SelectQuery | None: + inner_query = ast.SelectQuery(select=[]) + builder = FirstTimeForUserEventsQueryAlternator( + inner_query, + self._date_from_expr(), + self._date_to_expr(), + self._filters, + self._event_or_action_filter, + self._ratio_expr(), + ) + builder.append_select(self._select_expr(), aggregate=True) + return cast(ast.SelectQuery, builder.build()) + + def _select_expr(self): + return ast.Alias( + alias="uuid", + expr=ast.Field(chain=["uuid"]), + ) + + def _date_range(self) -> QueryDateRange: + team, query, now = self._context.team, self._context.query, self._context.now + date_range = QueryDateRange( + date_range=query.dateRange, + team=team, + interval=query.interval, + now=now, + ) + return date_range + + def _date_to_expr(self) -> ast.Expr: + return ast.CompareOperation( + op=ast.CompareOperationOp.LtEq, + left=ast.Field(chain=["timestamp"]), + right=ast.Constant(value=self._date_range().date_to()), + ) + + def _date_from_expr(self) -> ast.Expr: + return ast.CompareOperation( + op=ast.CompareOperationOp.GtEq, + left=ast.Field(chain=["timestamp"]), + right=ast.Constant(value=self._date_range().date_from()), + ) + + def _ratio_expr(self) -> ast.RatioExpr | None: + query = self._context.query + if query.samplingFactor is None: + return None + else: + return ast.RatioExpr(left=ast.Constant(value=query.samplingFactor)) diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel.ambr index d733159ba5ee0..1dbe7a3fd269f 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel.ambr @@ -90,9 +90,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -189,41 +188,7 @@ (SELECT argMax(toTimeZone(person.created_at, 'UTC'), person.version) AS created_at, person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id - FROM - (SELECT aggregation_target AS aggregation_target, steps AS steps, avg(step_1_conversion_time) AS step_1_average_conversion_time_inner, avg(step_2_conversion_time) AS step_2_average_conversion_time_inner, median(step_1_conversion_time) AS step_1_median_conversion_time_inner, median(step_2_conversion_time) AS step_2_median_conversion_time_inner - FROM - (SELECT aggregation_target AS aggregation_target, steps AS steps, max(steps) OVER (PARTITION BY aggregation_target) AS max_steps, step_1_conversion_time AS step_1_conversion_time, step_2_conversion_time AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, latest_1 AS latest_1, step_2 AS step_2, latest_2 AS latest_2, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalSecond(15))), 0), ifNull(lessOrEquals(latest_1, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalSecond(15))), 0)), 3, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalSecond(15))), 0)), 2, 1)) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalSecond(15))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time, if(and(isNotNull(latest_2), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_1, 'UTC'), toIntervalSecond(15))), 0)), dateDiff('second', latest_1, latest_2), NULL) AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, latest_1 AS latest_1, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2 - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, latest_1 AS latest_1, step_2 AS step_2, if(ifNull(less(latest_2, latest_1), 0), NULL, latest_2) AS latest_2 - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_1, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2 - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, if(equals(e.event, 'step one'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(equals(e.event, 'step two'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(equals(e.event, 'step three'), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2 - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-05-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-05-14 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) - WHERE ifNull(equals(step_0, 1), 0))) - GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) - and isNull(max(max_steps)))) - WHERE ifNull(in(steps, [2, 3]), 0) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.created_at DESC @@ -232,9 +197,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' @@ -339,9 +303,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -427,9 +390,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -537,9 +499,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -648,50 +609,7 @@ (SELECT argMax(toTimeZone(person.created_at, 'UTC'), person.version) AS created_at, person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id - FROM - (SELECT aggregation_target AS aggregation_target, steps AS steps, avg(step_1_conversion_time) AS step_1_average_conversion_time_inner, avg(step_2_conversion_time) AS step_2_average_conversion_time_inner, median(step_1_conversion_time) AS step_1_median_conversion_time_inner, median(step_2_conversion_time) AS step_2_median_conversion_time_inner - FROM - (SELECT aggregation_target AS aggregation_target, steps AS steps, max(steps) OVER (PARTITION BY aggregation_target) AS max_steps, step_1_conversion_time AS step_1_conversion_time, step_2_conversion_time AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, latest_1 AS latest_1, step_2 AS step_2, latest_2 AS latest_2, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0), ifNull(lessOrEquals(latest_1, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 3, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 2, 1)) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time, if(and(isNotNull(latest_2), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_1, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_1, latest_2), NULL) AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, latest_1 AS latest_1, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2 - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, latest_1 AS latest_1, step_2 AS step_2, if(ifNull(less(latest_2, latest_1), 0), NULL, latest_2) AS latest_2 - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_1, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2 - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, if(equals(e.event, 'user signed up'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(and(equals(e.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'aloha.com'), 0)), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(and(equals(e.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'aloha2.com'), 0)), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2 - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS e__pdi___person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - LEFT JOIN - (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'age'), ''), 'null'), '^"|"$', '') AS properties___age - FROM person - WHERE and(equals(person.team_id, 2), ifNull(in(tuple(person.id, person.version), - (SELECT person.id AS id, max(person.version) AS version - FROM person - WHERE equals(person.team_id, 2) - GROUP BY person.id - HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-07-01 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('$pageview', 'user signed up')), or(and(ifNull(ilike(e__pdi__person.properties___email, '%.com%'), 0), ifNull(equals(e__pdi__person.properties___age, '20'), 0)), or(ifNull(ilike(e__pdi__person.properties___email, '%.org%'), 0), ifNull(equals(e__pdi__person.properties___age, '28'), 0)))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) - WHERE ifNull(equals(step_0, 1), 0))) - GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) - and isNull(max(max_steps)))) - WHERE ifNull(in(steps, [1, 2, 3]), 0) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.created_at DESC @@ -700,9 +618,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' @@ -811,50 +728,7 @@ (SELECT argMax(toTimeZone(person.created_at, 'UTC'), person.version) AS created_at, person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id - FROM - (SELECT aggregation_target AS aggregation_target, steps AS steps, avg(step_1_conversion_time) AS step_1_average_conversion_time_inner, avg(step_2_conversion_time) AS step_2_average_conversion_time_inner, median(step_1_conversion_time) AS step_1_median_conversion_time_inner, median(step_2_conversion_time) AS step_2_median_conversion_time_inner - FROM - (SELECT aggregation_target AS aggregation_target, steps AS steps, max(steps) OVER (PARTITION BY aggregation_target) AS max_steps, step_1_conversion_time AS step_1_conversion_time, step_2_conversion_time AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, latest_1 AS latest_1, step_2 AS step_2, latest_2 AS latest_2, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0), ifNull(lessOrEquals(latest_1, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 3, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 2, 1)) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time, if(and(isNotNull(latest_2), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_1, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_1, latest_2), NULL) AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, latest_1 AS latest_1, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2 - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, latest_1 AS latest_1, step_2 AS step_2, if(ifNull(less(latest_2, latest_1), 0), NULL, latest_2) AS latest_2 - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_1, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2 - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, if(equals(e.event, 'user signed up'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(and(equals(e.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'aloha.com'), 0)), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(and(equals(e.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'aloha2.com'), 0)), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2 - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS e__pdi___person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - LEFT JOIN - (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'age'), ''), 'null'), '^"|"$', '') AS properties___age - FROM person - WHERE and(equals(person.team_id, 2), ifNull(in(tuple(person.id, person.version), - (SELECT person.id AS id, max(person.version) AS version - FROM person - WHERE equals(person.team_id, 2) - GROUP BY person.id - HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-07-01 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('$pageview', 'user signed up')), or(and(ifNull(ilike(e__pdi__person.properties___email, '%.com%'), 0), ifNull(equals(e__pdi__person.properties___age, '20'), 0)), or(ifNull(ilike(e__pdi__person.properties___email, '%.org%'), 0), ifNull(equals(e__pdi__person.properties___age, '28'), 0)))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) - WHERE ifNull(equals(step_0, 1), 0))) - GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) - and isNull(max(max_steps)))) - WHERE ifNull(in(steps, [2, 3]), 0) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.created_at DESC @@ -863,9 +737,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' @@ -974,50 +847,7 @@ (SELECT argMax(toTimeZone(person.created_at, 'UTC'), person.version) AS created_at, person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id - FROM - (SELECT aggregation_target AS aggregation_target, steps AS steps, avg(step_1_conversion_time) AS step_1_average_conversion_time_inner, avg(step_2_conversion_time) AS step_2_average_conversion_time_inner, median(step_1_conversion_time) AS step_1_median_conversion_time_inner, median(step_2_conversion_time) AS step_2_median_conversion_time_inner - FROM - (SELECT aggregation_target AS aggregation_target, steps AS steps, max(steps) OVER (PARTITION BY aggregation_target) AS max_steps, step_1_conversion_time AS step_1_conversion_time, step_2_conversion_time AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, latest_1 AS latest_1, step_2 AS step_2, latest_2 AS latest_2, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0), ifNull(lessOrEquals(latest_1, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 3, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 2, 1)) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time, if(and(isNotNull(latest_2), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_1, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_1, latest_2), NULL) AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, latest_1 AS latest_1, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2 - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, latest_1 AS latest_1, step_2 AS step_2, if(ifNull(less(latest_2, latest_1), 0), NULL, latest_2) AS latest_2 - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_1, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2 - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, if(equals(e.event, 'user signed up'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(and(equals(e.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'aloha.com'), 0)), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(and(equals(e.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'aloha2.com'), 0)), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2 - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS e__pdi___person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - LEFT JOIN - (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'age'), ''), 'null'), '^"|"$', '') AS properties___age - FROM person - WHERE and(equals(person.team_id, 2), ifNull(in(tuple(person.id, person.version), - (SELECT person.id AS id, max(person.version) AS version - FROM person - WHERE equals(person.team_id, 2) - GROUP BY person.id - HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-07-01 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('$pageview', 'user signed up')), or(and(ifNull(ilike(e__pdi__person.properties___email, '%.com%'), 0), ifNull(equals(e__pdi__person.properties___age, '20'), 0)), or(ifNull(ilike(e__pdi__person.properties___email, '%.org%'), 0), ifNull(equals(e__pdi__person.properties___age, '28'), 0)))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) - WHERE ifNull(equals(step_0, 1), 0))) - GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) - and isNull(max(max_steps)))) - WHERE ifNull(in(steps, [3]), 0) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.created_at DESC @@ -1026,9 +856,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' @@ -1103,9 +932,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -1168,9 +996,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -1266,9 +1093,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -1371,9 +1197,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -1469,9 +1294,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -1608,9 +1432,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -1747,9 +1570,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -1893,9 +1715,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.ambr index 968e9f59ec233..b507403f6e484 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.ambr @@ -90,9 +90,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -188,9 +187,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlation.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlation.ambr index 404380346de1c..04a7ddc45281f 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlation.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlation.ambr @@ -147,9 +147,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -310,9 +309,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -489,9 +487,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -504,9 +501,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -683,9 +679,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -698,9 +693,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -877,9 +871,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -892,9 +885,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1071,9 +1063,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1086,9 +1077,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1249,9 +1239,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1428,9 +1417,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1443,9 +1431,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1622,9 +1609,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1637,9 +1623,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1816,9 +1801,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1831,9 +1815,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2010,9 +1993,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2025,9 +2007,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2164,9 +2145,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2303,9 +2283,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2436,9 +2415,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2552,9 +2530,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2668,9 +2645,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2784,9 +2760,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2900,9 +2875,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3049,9 +3023,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3165,9 +3138,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3281,9 +3253,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3414,9 +3385,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3530,9 +3500,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3646,9 +3615,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3762,9 +3730,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3878,9 +3845,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4027,9 +3993,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4143,9 +4108,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4259,9 +4223,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4407,9 +4370,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4530,9 +4492,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4653,9 +4614,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4776,9 +4736,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4899,9 +4858,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5047,9 +5005,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5195,9 +5152,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5318,9 +5274,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5441,9 +5396,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5564,9 +5518,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5687,9 +5640,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5835,9 +5787,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5983,9 +5934,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -6106,9 +6056,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -6229,9 +6178,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -6352,9 +6300,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -6475,9 +6422,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -6623,9 +6569,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -6771,9 +6716,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -6894,9 +6838,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -7017,9 +6960,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -7140,9 +7082,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -7263,9 +7204,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -7411,9 +7351,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -7559,9 +7498,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -7682,9 +7620,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -7805,9 +7742,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -7928,9 +7864,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -8051,9 +7986,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -8199,9 +8133,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlations_persons.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlations_persons.ambr index e939cd2b30bfa..687a7c05a8429 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlations_persons.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlations_persons.ambr @@ -167,9 +167,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -182,9 +181,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -434,9 +432,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -449,9 +446,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -628,9 +624,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -643,9 +638,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -822,9 +816,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -837,9 +830,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1016,9 +1008,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1031,9 +1022,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_persons.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_persons.ambr index 2044dcbed3b96..77fe0acf7118f 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_persons.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_persons.ambr @@ -157,50 +157,7 @@ INNER JOIN (SELECT person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id, step_0_matching_events AS matching_events - FROM - (SELECT groupArray(10)(step_0_matching_event) AS step_0_matching_events, groupArray(10)(step_1_matching_event) AS step_1_matching_events, groupArray(10)(step_2_matching_event) AS step_2_matching_events, groupArray(10)(final_matching_event) AS final_matching_events, aggregation_target AS aggregation_target, steps AS steps, avg(step_1_conversion_time) AS step_1_average_conversion_time_inner, avg(step_2_conversion_time) AS step_2_average_conversion_time_inner, median(step_1_conversion_time) AS step_1_median_conversion_time_inner, median(step_2_conversion_time) AS step_2_median_conversion_time_inner - FROM - (SELECT tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event, aggregation_target AS aggregation_target, steps AS steps, max(steps) OVER (PARTITION BY aggregation_target) AS max_steps, step_1_conversion_time AS step_1_conversion_time, step_2_conversion_time AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, latest_2 AS latest_2, uuid_2 AS uuid_2, `$session_id_2` AS `$session_id_2`, `$window_id_2` AS `$window_id_2`, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0), ifNull(lessOrEquals(latest_1, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 3, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 2, 1)) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time, if(and(isNotNull(latest_2), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_1, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_1, latest_2), NULL) AS step_2_conversion_time, tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, if(ifNull(less(latest_2, latest_1), 0), NULL, latest_2) AS latest_2, if(ifNull(less(latest_2, latest_1), 0), NULL, uuid_2) AS uuid_2, if(ifNull(less(latest_2, latest_1), 0), NULL, `$session_id_2`) AS `$session_id_2`, if(ifNull(less(latest_2, latest_1), 0), NULL, `$window_id_2`) AS `$window_id_2` - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_1, last_value(uuid_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_1, last_value(`$session_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_1`, last_value(`$window_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, e.uuid AS uuid, if(equals(e.event, 'step one'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(ifNull(equals(step_0, 1), 0), uuid, NULL) AS uuid_0, if(ifNull(equals(step_0, 1), 0), e.`$session_id`, NULL) AS `$session_id_0`, if(ifNull(equals(step_0, 1), 0), e.`$window_id`, NULL) AS `$window_id_0`, if(equals(e.event, 'step two'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(ifNull(equals(step_1, 1), 0), uuid, NULL) AS uuid_1, if(ifNull(equals(step_1, 1), 0), e.`$session_id`, NULL) AS `$session_id_1`, if(ifNull(equals(step_1, 1), 0), e.`$window_id`, NULL) AS `$window_id_1`, if(equals(e.event, 'step three'), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2, if(ifNull(equals(step_2, 1), 0), uuid, NULL) AS uuid_2, if(ifNull(equals(step_2, 1), 0), e.`$session_id`, NULL) AS `$session_id_2`, if(ifNull(equals(step_2, 1), 0), e.`$window_id`, NULL) AS `$window_id_2` - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) - WHERE ifNull(equals(step_0, 1), 0))) - GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) - and isNull(max(max_steps)))) - WHERE ifNull(in(steps, [1, 2, 3]), 0) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.id ASC @@ -209,9 +166,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' @@ -225,9 +181,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -389,50 +344,7 @@ INNER JOIN (SELECT person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id, step_1_matching_events AS matching_events - FROM - (SELECT groupArray(10)(step_0_matching_event) AS step_0_matching_events, groupArray(10)(step_1_matching_event) AS step_1_matching_events, groupArray(10)(step_2_matching_event) AS step_2_matching_events, groupArray(10)(final_matching_event) AS final_matching_events, aggregation_target AS aggregation_target, steps AS steps, avg(step_1_conversion_time) AS step_1_average_conversion_time_inner, avg(step_2_conversion_time) AS step_2_average_conversion_time_inner, median(step_1_conversion_time) AS step_1_median_conversion_time_inner, median(step_2_conversion_time) AS step_2_median_conversion_time_inner - FROM - (SELECT tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event, aggregation_target AS aggregation_target, steps AS steps, max(steps) OVER (PARTITION BY aggregation_target) AS max_steps, step_1_conversion_time AS step_1_conversion_time, step_2_conversion_time AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, latest_2 AS latest_2, uuid_2 AS uuid_2, `$session_id_2` AS `$session_id_2`, `$window_id_2` AS `$window_id_2`, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0), ifNull(lessOrEquals(latest_1, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 3, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 2, 1)) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time, if(and(isNotNull(latest_2), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_1, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_1, latest_2), NULL) AS step_2_conversion_time, tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, if(ifNull(less(latest_2, latest_1), 0), NULL, latest_2) AS latest_2, if(ifNull(less(latest_2, latest_1), 0), NULL, uuid_2) AS uuid_2, if(ifNull(less(latest_2, latest_1), 0), NULL, `$session_id_2`) AS `$session_id_2`, if(ifNull(less(latest_2, latest_1), 0), NULL, `$window_id_2`) AS `$window_id_2` - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_1, last_value(uuid_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_1, last_value(`$session_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_1`, last_value(`$window_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, e.uuid AS uuid, if(equals(e.event, 'step one'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(ifNull(equals(step_0, 1), 0), uuid, NULL) AS uuid_0, if(ifNull(equals(step_0, 1), 0), e.`$session_id`, NULL) AS `$session_id_0`, if(ifNull(equals(step_0, 1), 0), e.`$window_id`, NULL) AS `$window_id_0`, if(equals(e.event, 'step two'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(ifNull(equals(step_1, 1), 0), uuid, NULL) AS uuid_1, if(ifNull(equals(step_1, 1), 0), e.`$session_id`, NULL) AS `$session_id_1`, if(ifNull(equals(step_1, 1), 0), e.`$window_id`, NULL) AS `$window_id_1`, if(equals(e.event, 'step three'), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2, if(ifNull(equals(step_2, 1), 0), uuid, NULL) AS uuid_2, if(ifNull(equals(step_2, 1), 0), e.`$session_id`, NULL) AS `$session_id_2`, if(ifNull(equals(step_2, 1), 0), e.`$window_id`, NULL) AS `$window_id_2` - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) - WHERE ifNull(equals(step_0, 1), 0))) - GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) - and isNull(max(max_steps)))) - WHERE ifNull(in(steps, [2, 3]), 0) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.id ASC @@ -441,9 +353,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' @@ -457,9 +368,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -621,50 +531,7 @@ INNER JOIN (SELECT person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id, step_1_matching_events AS matching_events - FROM - (SELECT groupArray(10)(step_0_matching_event) AS step_0_matching_events, groupArray(10)(step_1_matching_event) AS step_1_matching_events, groupArray(10)(step_2_matching_event) AS step_2_matching_events, groupArray(10)(final_matching_event) AS final_matching_events, aggregation_target AS aggregation_target, steps AS steps, avg(step_1_conversion_time) AS step_1_average_conversion_time_inner, avg(step_2_conversion_time) AS step_2_average_conversion_time_inner, median(step_1_conversion_time) AS step_1_median_conversion_time_inner, median(step_2_conversion_time) AS step_2_median_conversion_time_inner - FROM - (SELECT tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event, aggregation_target AS aggregation_target, steps AS steps, max(steps) OVER (PARTITION BY aggregation_target) AS max_steps, step_1_conversion_time AS step_1_conversion_time, step_2_conversion_time AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, latest_2 AS latest_2, uuid_2 AS uuid_2, `$session_id_2` AS `$session_id_2`, `$window_id_2` AS `$window_id_2`, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0), ifNull(lessOrEquals(latest_1, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 3, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 2, 1)) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time, if(and(isNotNull(latest_2), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_1, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_1, latest_2), NULL) AS step_2_conversion_time, tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, if(ifNull(less(latest_2, latest_1), 0), NULL, latest_2) AS latest_2, if(ifNull(less(latest_2, latest_1), 0), NULL, uuid_2) AS uuid_2, if(ifNull(less(latest_2, latest_1), 0), NULL, `$session_id_2`) AS `$session_id_2`, if(ifNull(less(latest_2, latest_1), 0), NULL, `$window_id_2`) AS `$window_id_2` - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_1, last_value(uuid_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_1, last_value(`$session_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_1`, last_value(`$window_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, e.uuid AS uuid, if(equals(e.event, 'step one'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(ifNull(equals(step_0, 1), 0), uuid, NULL) AS uuid_0, if(ifNull(equals(step_0, 1), 0), e.`$session_id`, NULL) AS `$session_id_0`, if(ifNull(equals(step_0, 1), 0), e.`$window_id`, NULL) AS `$window_id_0`, if(equals(e.event, 'step two'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(ifNull(equals(step_1, 1), 0), uuid, NULL) AS uuid_1, if(ifNull(equals(step_1, 1), 0), e.`$session_id`, NULL) AS `$session_id_1`, if(ifNull(equals(step_1, 1), 0), e.`$window_id`, NULL) AS `$window_id_1`, if(equals(e.event, 'step three'), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2, if(ifNull(equals(step_2, 1), 0), uuid, NULL) AS uuid_2, if(ifNull(equals(step_2, 1), 0), e.`$session_id`, NULL) AS `$session_id_2`, if(ifNull(equals(step_2, 1), 0), e.`$window_id`, NULL) AS `$window_id_2` - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) - WHERE ifNull(equals(step_0, 1), 0))) - GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) - and isNull(max(max_steps)))) - WHERE ifNull(equals(steps, 2), 0) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.id ASC @@ -673,9 +540,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' @@ -689,9 +555,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.ambr index 453e2164d2150..7e7d0e0586b32 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.ambr @@ -89,9 +89,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -193,9 +192,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -290,9 +288,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -406,9 +403,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -522,9 +518,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -645,9 +640,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict_persons.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict_persons.ambr index ce3fa166cffc8..38a6cd3b37d4f 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict_persons.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict_persons.ambr @@ -117,42 +117,7 @@ INNER JOIN (SELECT person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id, step_0_matching_events AS matching_events - FROM - (SELECT groupArray(10)(step_0_matching_event) AS step_0_matching_events, groupArray(10)(step_1_matching_event) AS step_1_matching_events, groupArray(10)(step_2_matching_event) AS step_2_matching_events, groupArray(10)(final_matching_event) AS final_matching_events, aggregation_target AS aggregation_target, steps AS steps, avg(step_1_conversion_time) AS step_1_average_conversion_time_inner, avg(step_2_conversion_time) AS step_2_average_conversion_time_inner, median(step_1_conversion_time) AS step_1_median_conversion_time_inner, median(step_2_conversion_time) AS step_2_median_conversion_time_inner - FROM - (SELECT tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event, aggregation_target AS aggregation_target, steps AS steps, max(steps) OVER (PARTITION BY aggregation_target) AS max_steps, step_1_conversion_time AS step_1_conversion_time, step_2_conversion_time AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, latest_2 AS latest_2, uuid_2 AS uuid_2, `$session_id_2` AS `$session_id_2`, `$window_id_2` AS `$window_id_2`, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0), ifNull(lessOrEquals(latest_1, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 3, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 2, 1)) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time, if(and(isNotNull(latest_2), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_1, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_1, latest_2), NULL) AS step_2_conversion_time, tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS latest_1, min(uuid_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS uuid_1, min(`$session_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS `$session_id_1`, min(`$window_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) AS latest_2, min(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) AS uuid_2, min(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) AS `$session_id_2`, min(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) AS `$window_id_2` - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, e.uuid AS uuid, if(equals(e.event, 'step one'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(ifNull(equals(step_0, 1), 0), uuid, NULL) AS uuid_0, if(ifNull(equals(step_0, 1), 0), e.`$session_id`, NULL) AS `$session_id_0`, if(ifNull(equals(step_0, 1), 0), e.`$window_id`, NULL) AS `$window_id_0`, if(equals(e.event, 'step two'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(ifNull(equals(step_1, 1), 0), uuid, NULL) AS uuid_1, if(ifNull(equals(step_1, 1), 0), e.`$session_id`, NULL) AS `$session_id_1`, if(ifNull(equals(step_1, 1), 0), e.`$window_id`, NULL) AS `$window_id_1`, if(equals(e.event, 'step three'), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2, if(ifNull(equals(step_2, 1), 0), uuid, NULL) AS uuid_2, if(ifNull(equals(step_2, 1), 0), e.`$session_id`, NULL) AS `$session_id_2`, if(ifNull(equals(step_2, 1), 0), e.`$window_id`, NULL) AS `$window_id_2` - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC')))))) - WHERE ifNull(equals(step_0, 1), 0))) - GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) - and isNull(max(max_steps)))) - WHERE ifNull(in(steps, [1, 2, 3]), 0) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.id ASC @@ -161,9 +126,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' @@ -177,9 +141,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -301,42 +264,7 @@ INNER JOIN (SELECT person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id, step_1_matching_events AS matching_events - FROM - (SELECT groupArray(10)(step_0_matching_event) AS step_0_matching_events, groupArray(10)(step_1_matching_event) AS step_1_matching_events, groupArray(10)(step_2_matching_event) AS step_2_matching_events, groupArray(10)(final_matching_event) AS final_matching_events, aggregation_target AS aggregation_target, steps AS steps, avg(step_1_conversion_time) AS step_1_average_conversion_time_inner, avg(step_2_conversion_time) AS step_2_average_conversion_time_inner, median(step_1_conversion_time) AS step_1_median_conversion_time_inner, median(step_2_conversion_time) AS step_2_median_conversion_time_inner - FROM - (SELECT tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event, aggregation_target AS aggregation_target, steps AS steps, max(steps) OVER (PARTITION BY aggregation_target) AS max_steps, step_1_conversion_time AS step_1_conversion_time, step_2_conversion_time AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, latest_2 AS latest_2, uuid_2 AS uuid_2, `$session_id_2` AS `$session_id_2`, `$window_id_2` AS `$window_id_2`, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0), ifNull(lessOrEquals(latest_1, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 3, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 2, 1)) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time, if(and(isNotNull(latest_2), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_1, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_1, latest_2), NULL) AS step_2_conversion_time, tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS latest_1, min(uuid_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS uuid_1, min(`$session_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS `$session_id_1`, min(`$window_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) AS latest_2, min(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) AS uuid_2, min(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) AS `$session_id_2`, min(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) AS `$window_id_2` - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, e.uuid AS uuid, if(equals(e.event, 'step one'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(ifNull(equals(step_0, 1), 0), uuid, NULL) AS uuid_0, if(ifNull(equals(step_0, 1), 0), e.`$session_id`, NULL) AS `$session_id_0`, if(ifNull(equals(step_0, 1), 0), e.`$window_id`, NULL) AS `$window_id_0`, if(equals(e.event, 'step two'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(ifNull(equals(step_1, 1), 0), uuid, NULL) AS uuid_1, if(ifNull(equals(step_1, 1), 0), e.`$session_id`, NULL) AS `$session_id_1`, if(ifNull(equals(step_1, 1), 0), e.`$window_id`, NULL) AS `$window_id_1`, if(equals(e.event, 'step three'), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2, if(ifNull(equals(step_2, 1), 0), uuid, NULL) AS uuid_2, if(ifNull(equals(step_2, 1), 0), e.`$session_id`, NULL) AS `$session_id_2`, if(ifNull(equals(step_2, 1), 0), e.`$window_id`, NULL) AS `$window_id_2` - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC')))))) - WHERE ifNull(equals(step_0, 1), 0))) - GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) - and isNull(max(max_steps)))) - WHERE ifNull(in(steps, [2, 3]), 0) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.id ASC @@ -345,9 +273,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' @@ -361,9 +288,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -485,42 +411,7 @@ INNER JOIN (SELECT person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id, step_1_matching_events AS matching_events - FROM - (SELECT groupArray(10)(step_0_matching_event) AS step_0_matching_events, groupArray(10)(step_1_matching_event) AS step_1_matching_events, groupArray(10)(step_2_matching_event) AS step_2_matching_events, groupArray(10)(final_matching_event) AS final_matching_events, aggregation_target AS aggregation_target, steps AS steps, avg(step_1_conversion_time) AS step_1_average_conversion_time_inner, avg(step_2_conversion_time) AS step_2_average_conversion_time_inner, median(step_1_conversion_time) AS step_1_median_conversion_time_inner, median(step_2_conversion_time) AS step_2_median_conversion_time_inner - FROM - (SELECT tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event, aggregation_target AS aggregation_target, steps AS steps, max(steps) OVER (PARTITION BY aggregation_target) AS max_steps, step_1_conversion_time AS step_1_conversion_time, step_2_conversion_time AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, latest_2 AS latest_2, uuid_2 AS uuid_2, `$session_id_2` AS `$session_id_2`, `$window_id_2` AS `$window_id_2`, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0), ifNull(lessOrEquals(latest_1, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 3, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 2, 1)) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time, if(and(isNotNull(latest_2), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_1, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_1, latest_2), NULL) AS step_2_conversion_time, tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS latest_1, min(uuid_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS uuid_1, min(`$session_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS `$session_id_1`, min(`$window_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) AS latest_2, min(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) AS uuid_2, min(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) AS `$session_id_2`, min(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) AS `$window_id_2` - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, e.uuid AS uuid, if(equals(e.event, 'step one'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(ifNull(equals(step_0, 1), 0), uuid, NULL) AS uuid_0, if(ifNull(equals(step_0, 1), 0), e.`$session_id`, NULL) AS `$session_id_0`, if(ifNull(equals(step_0, 1), 0), e.`$window_id`, NULL) AS `$window_id_0`, if(equals(e.event, 'step two'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(ifNull(equals(step_1, 1), 0), uuid, NULL) AS uuid_1, if(ifNull(equals(step_1, 1), 0), e.`$session_id`, NULL) AS `$session_id_1`, if(ifNull(equals(step_1, 1), 0), e.`$window_id`, NULL) AS `$window_id_1`, if(equals(e.event, 'step three'), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2, if(ifNull(equals(step_2, 1), 0), uuid, NULL) AS uuid_2, if(ifNull(equals(step_2, 1), 0), e.`$session_id`, NULL) AS `$session_id_2`, if(ifNull(equals(step_2, 1), 0), e.`$window_id`, NULL) AS `$window_id_2` - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC')))))) - WHERE ifNull(equals(step_0, 1), 0))) - GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) - and isNull(max(max_steps)))) - WHERE ifNull(equals(steps, 2), 0) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.id ASC @@ -529,9 +420,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' @@ -545,9 +435,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.ambr index 22a3489348248..1643acebc69ce 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.ambr @@ -413,9 +413,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -761,9 +760,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -1509,9 +1507,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends.ambr index e02eb64d9a216..7267c85d00c1b 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends.ambr @@ -85,9 +85,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -178,9 +177,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -271,9 +269,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends_persons.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends_persons.ambr index 5b7df2345a412..db29653790237 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends_persons.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends_persons.ambr @@ -143,47 +143,7 @@ INNER JOIN (SELECT person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id, step_1_matching_events AS matching_events - FROM - (SELECT aggregation_target AS aggregation_target, toStartOfDay(timestamp) AS entrance_period_start, max(steps) AS steps_completed, groupArray(10)(step_0_matching_event) AS step_0_matching_events, groupArray(10)(step_1_matching_event) AS step_1_matching_events, groupArray(10)(step_2_matching_event) AS step_2_matching_events, groupArray(10)(final_matching_event) AS final_matching_events - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, latest_2 AS latest_2, uuid_2 AS uuid_2, `$session_id_2` AS `$session_id_2`, `$window_id_2` AS `$window_id_2`, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0), ifNull(lessOrEquals(latest_1, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 3, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 2, 1)) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time, if(and(isNotNull(latest_2), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_1, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_1, latest_2), NULL) AS step_2_conversion_time, tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, if(ifNull(less(latest_2, latest_1), 0), NULL, latest_2) AS latest_2, if(ifNull(less(latest_2, latest_1), 0), NULL, uuid_2) AS uuid_2, if(ifNull(less(latest_2, latest_1), 0), NULL, `$session_id_2`) AS `$session_id_2`, if(ifNull(less(latest_2, latest_1), 0), NULL, `$window_id_2`) AS `$window_id_2` - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_1, last_value(uuid_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_1, last_value(`$session_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_1`, last_value(`$window_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, e.uuid AS uuid, if(equals(e.event, 'step one'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(ifNull(equals(step_0, 1), 0), uuid, NULL) AS uuid_0, if(ifNull(equals(step_0, 1), 0), e.`$session_id`, NULL) AS `$session_id_0`, if(ifNull(equals(step_0, 1), 0), e.`$window_id`, NULL) AS `$window_id_0`, if(equals(e.event, 'step two'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(ifNull(equals(step_1, 1), 0), uuid, NULL) AS uuid_1, if(ifNull(equals(step_1, 1), 0), e.`$session_id`, NULL) AS `$session_id_1`, if(ifNull(equals(step_1, 1), 0), e.`$window_id`, NULL) AS `$window_id_1`, if(equals(e.event, 'step three'), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2, if(ifNull(equals(step_2, 1), 0), uuid, NULL) AS uuid_2, if(ifNull(equals(step_2, 1), 0), e.`$session_id`, NULL) AS `$session_id_2`, if(ifNull(equals(step_2, 1), 0), e.`$window_id`, NULL) AS `$window_id_2` - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-05-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-05-07 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) - WHERE ifNull(equals(step_0, 1), 0)) - WHERE ifNull(equals(entrance_period_start, toDateTime64('2021-05-01 00:00:00.000000', 6, 'UTC')), 0) - GROUP BY aggregation_target, entrance_period_start) - WHERE ifNull(greaterOrEquals(steps_completed, 2), 0) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.id ASC @@ -192,9 +152,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' @@ -208,9 +167,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -358,47 +316,7 @@ INNER JOIN (SELECT person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id, final_matching_events AS matching_events - FROM - (SELECT aggregation_target AS aggregation_target, toStartOfDay(timestamp) AS entrance_period_start, max(steps) AS steps_completed, groupArray(10)(step_0_matching_event) AS step_0_matching_events, groupArray(10)(step_1_matching_event) AS step_1_matching_events, groupArray(10)(step_2_matching_event) AS step_2_matching_events, groupArray(10)(final_matching_event) AS final_matching_events - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, latest_2 AS latest_2, uuid_2 AS uuid_2, `$session_id_2` AS `$session_id_2`, `$window_id_2` AS `$window_id_2`, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0), ifNull(lessOrEquals(latest_1, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 3, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 2, 1)) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time, if(and(isNotNull(latest_2), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_1, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_1, latest_2), NULL) AS step_2_conversion_time, tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, if(ifNull(less(latest_2, latest_1), 0), NULL, latest_2) AS latest_2, if(ifNull(less(latest_2, latest_1), 0), NULL, uuid_2) AS uuid_2, if(ifNull(less(latest_2, latest_1), 0), NULL, `$session_id_2`) AS `$session_id_2`, if(ifNull(less(latest_2, latest_1), 0), NULL, `$window_id_2`) AS `$window_id_2` - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_1, last_value(uuid_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_1, last_value(`$session_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_1`, last_value(`$window_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, e.uuid AS uuid, if(equals(e.event, 'step one'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(ifNull(equals(step_0, 1), 0), uuid, NULL) AS uuid_0, if(ifNull(equals(step_0, 1), 0), e.`$session_id`, NULL) AS `$session_id_0`, if(ifNull(equals(step_0, 1), 0), e.`$window_id`, NULL) AS `$window_id_0`, if(equals(e.event, 'step two'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(ifNull(equals(step_1, 1), 0), uuid, NULL) AS uuid_1, if(ifNull(equals(step_1, 1), 0), e.`$session_id`, NULL) AS `$session_id_1`, if(ifNull(equals(step_1, 1), 0), e.`$window_id`, NULL) AS `$window_id_1`, if(equals(e.event, 'step three'), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2, if(ifNull(equals(step_2, 1), 0), uuid, NULL) AS uuid_2, if(ifNull(equals(step_2, 1), 0), e.`$session_id`, NULL) AS `$session_id_2`, if(ifNull(equals(step_2, 1), 0), e.`$window_id`, NULL) AS `$window_id_2` - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-05-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-05-07 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) - WHERE ifNull(equals(step_0, 1), 0)) - WHERE ifNull(equals(entrance_period_start, toDateTime64('2021-05-01 00:00:00.000000', 6, 'UTC')), 0) - GROUP BY aggregation_target, entrance_period_start) - WHERE and(ifNull(greaterOrEquals(steps_completed, 1), 0), ifNull(less(steps_completed, 3), 0)) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.id ASC @@ -407,9 +325,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' @@ -423,9 +340,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -573,47 +489,7 @@ INNER JOIN (SELECT person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id, final_matching_events AS matching_events - FROM - (SELECT aggregation_target AS aggregation_target, toStartOfDay(timestamp) AS entrance_period_start, max(steps) AS steps_completed, groupArray(10)(step_0_matching_event) AS step_0_matching_events, groupArray(10)(step_1_matching_event) AS step_1_matching_events, groupArray(10)(step_2_matching_event) AS step_2_matching_events, groupArray(10)(final_matching_event) AS final_matching_events - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, latest_2 AS latest_2, uuid_2 AS uuid_2, `$session_id_2` AS `$session_id_2`, `$window_id_2` AS `$window_id_2`, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0), ifNull(lessOrEquals(latest_1, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 3, if(and(ifNull(lessOrEquals(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 2, 1)) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time, if(and(isNotNull(latest_2), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_1, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_1, latest_2), NULL) AS step_2_conversion_time, tuple(latest_0, uuid_0, `$session_id_0`, `$window_id_0`) AS step_0_matching_event, tuple(latest_1, uuid_1, `$session_id_1`, `$window_id_1`) AS step_1_matching_event, tuple(latest_2, uuid_2, `$session_id_2`, `$window_id_2`) AS step_2_matching_event, if(isNull(latest_0), tuple(NULL, NULL, NULL, NULL), if(isNull(latest_1), step_0_matching_event, if(isNull(latest_2), step_1_matching_event, step_2_matching_event))) AS final_matching_event - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, if(ifNull(less(latest_2, latest_1), 0), NULL, latest_2) AS latest_2, if(ifNull(less(latest_2, latest_1), 0), NULL, uuid_2) AS uuid_2, if(ifNull(less(latest_2, latest_1), 0), NULL, `$session_id_2`) AS `$session_id_2`, if(ifNull(less(latest_2, latest_1), 0), NULL, `$window_id_2`) AS `$window_id_2` - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_1, last_value(uuid_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_1, last_value(`$session_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_1`, last_value(`$window_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, e.uuid AS uuid, if(equals(e.event, 'step one'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(ifNull(equals(step_0, 1), 0), uuid, NULL) AS uuid_0, if(ifNull(equals(step_0, 1), 0), e.`$session_id`, NULL) AS `$session_id_0`, if(ifNull(equals(step_0, 1), 0), e.`$window_id`, NULL) AS `$window_id_0`, if(equals(e.event, 'step two'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(ifNull(equals(step_1, 1), 0), uuid, NULL) AS uuid_1, if(ifNull(equals(step_1, 1), 0), e.`$session_id`, NULL) AS `$session_id_1`, if(ifNull(equals(step_1, 1), 0), e.`$window_id`, NULL) AS `$window_id_1`, if(equals(e.event, 'step three'), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2, if(ifNull(equals(step_2, 1), 0), uuid, NULL) AS uuid_2, if(ifNull(equals(step_2, 1), 0), e.`$session_id`, NULL) AS `$session_id_2`, if(ifNull(equals(step_2, 1), 0), e.`$window_id`, NULL) AS `$window_id_2` - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-05-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-05-07 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) - WHERE ifNull(equals(step_0, 1), 0)) - WHERE ifNull(equals(entrance_period_start, toDateTime64('2021-05-01 00:00:00.000000', 6, 'UTC')), 0) - GROUP BY aggregation_target, entrance_period_start) - WHERE ifNull(greaterOrEquals(steps_completed, 3), 0) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.id ASC @@ -622,9 +498,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' @@ -638,9 +513,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr index 778829c29b4da..47d77c0817e46 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr @@ -143,9 +143,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -308,9 +307,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -459,9 +457,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -705,9 +702,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -951,9 +947,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' @@ -1218,9 +1213,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128, allow_experimental_analyzer=1 ''' diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered_persons.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered_persons.ambr index b610dfb3f779d..65609c28ee890 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered_persons.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered_persons.ambr @@ -261,86 +261,7 @@ INNER JOIN (SELECT person.id AS id FROM person - WHERE and(equals(person.team_id, 2), in(id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id, array() AS matching_events - FROM - (SELECT aggregation_target AS aggregation_target, steps AS steps, avg(step_1_conversion_time) AS step_1_average_conversion_time_inner, avg(step_2_conversion_time) AS step_2_average_conversion_time_inner, median(step_1_conversion_time) AS step_1_median_conversion_time_inner, median(step_2_conversion_time) AS step_2_median_conversion_time_inner - FROM - (SELECT aggregation_target AS aggregation_target, steps AS steps, max(steps) OVER (PARTITION BY aggregation_target) AS max_steps, step_1_conversion_time AS step_1_conversion_time, step_2_conversion_time AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, latest_2 AS latest_2, uuid_2 AS uuid_2, `$session_id_2` AS `$session_id_2`, `$window_id_2` AS `$window_id_2`, arraySort([latest_0, latest_1, latest_2]) AS event_times, arraySum([if(and(ifNull(less(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 1, 0), if(and(ifNull(less(latest_0, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 1, 0), 1]) AS steps, arraySort([latest_0, latest_1, latest_2]) AS conversion_times, if(and(isNotNull(conversion_times[2]), ifNull(lessOrEquals(conversion_times[2], plus(toTimeZone(conversion_times[1], 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', conversion_times[1], conversion_times[2]), NULL) AS step_1_conversion_time, if(and(isNotNull(conversion_times[3]), ifNull(lessOrEquals(conversion_times[3], plus(toTimeZone(conversion_times[2], 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', conversion_times[2], conversion_times[3]), NULL) AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_1, last_value(uuid_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_1, last_value(`$session_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_1`, last_value(`$window_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, e.uuid AS uuid, if(equals(e.event, 'step one'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(ifNull(equals(step_0, 1), 0), uuid, NULL) AS uuid_0, if(ifNull(equals(step_0, 1), 0), e.`$session_id`, NULL) AS `$session_id_0`, if(ifNull(equals(step_0, 1), 0), e.`$window_id`, NULL) AS `$window_id_0`, if(equals(e.event, 'step two'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(ifNull(equals(step_1, 1), 0), uuid, NULL) AS uuid_1, if(ifNull(equals(step_1, 1), 0), e.`$session_id`, NULL) AS `$session_id_1`, if(ifNull(equals(step_1, 1), 0), e.`$window_id`, NULL) AS `$window_id_1`, if(equals(e.event, 'step three'), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2, if(ifNull(equals(step_2, 1), 0), uuid, NULL) AS uuid_2, if(ifNull(equals(step_2, 1), 0), e.`$session_id`, NULL) AS `$session_id_2`, if(ifNull(equals(step_2, 1), 0), e.`$window_id`, NULL) AS `$window_id_2` - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))) - WHERE ifNull(equals(step_0, 1), 0) - UNION ALL SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, latest_2 AS latest_2, uuid_2 AS uuid_2, `$session_id_2` AS `$session_id_2`, `$window_id_2` AS `$window_id_2`, arraySort([latest_0, latest_1, latest_2]) AS event_times, arraySum([if(and(ifNull(less(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 1, 0), if(and(ifNull(less(latest_0, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 1, 0), 1]) AS steps, arraySort([latest_0, latest_1, latest_2]) AS conversion_times, if(and(isNotNull(conversion_times[2]), ifNull(lessOrEquals(conversion_times[2], plus(toTimeZone(conversion_times[1], 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', conversion_times[1], conversion_times[2]), NULL) AS step_1_conversion_time, if(and(isNotNull(conversion_times[3]), ifNull(lessOrEquals(conversion_times[3], plus(toTimeZone(conversion_times[2], 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', conversion_times[2], conversion_times[3]), NULL) AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_1, last_value(uuid_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_1, last_value(`$session_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_1`, last_value(`$window_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, e.uuid AS uuid, if(equals(e.event, 'step two'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(ifNull(equals(step_0, 1), 0), uuid, NULL) AS uuid_0, if(ifNull(equals(step_0, 1), 0), e.`$session_id`, NULL) AS `$session_id_0`, if(ifNull(equals(step_0, 1), 0), e.`$window_id`, NULL) AS `$window_id_0`, if(equals(e.event, 'step three'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(ifNull(equals(step_1, 1), 0), uuid, NULL) AS uuid_1, if(ifNull(equals(step_1, 1), 0), e.`$session_id`, NULL) AS `$session_id_1`, if(ifNull(equals(step_1, 1), 0), e.`$window_id`, NULL) AS `$window_id_1`, if(equals(e.event, 'step one'), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2, if(ifNull(equals(step_2, 1), 0), uuid, NULL) AS uuid_2, if(ifNull(equals(step_2, 1), 0), e.`$session_id`, NULL) AS `$session_id_2`, if(ifNull(equals(step_2, 1), 0), e.`$window_id`, NULL) AS `$window_id_2` - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))) - WHERE ifNull(equals(step_0, 1), 0) - UNION ALL SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, latest_1 AS latest_1, uuid_1 AS uuid_1, `$session_id_1` AS `$session_id_1`, `$window_id_1` AS `$window_id_1`, step_2 AS step_2, latest_2 AS latest_2, uuid_2 AS uuid_2, `$session_id_2` AS `$session_id_2`, `$window_id_2` AS `$window_id_2`, arraySort([latest_0, latest_1, latest_2]) AS event_times, arraySum([if(and(ifNull(less(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 1, 0), if(and(ifNull(less(latest_0, latest_2), 0), ifNull(lessOrEquals(latest_2, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 1, 0), 1]) AS steps, arraySort([latest_0, latest_1, latest_2]) AS conversion_times, if(and(isNotNull(conversion_times[2]), ifNull(lessOrEquals(conversion_times[2], plus(toTimeZone(conversion_times[1], 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', conversion_times[1], conversion_times[2]), NULL) AS step_1_conversion_time, if(and(isNotNull(conversion_times[3]), ifNull(lessOrEquals(conversion_times[3], plus(toTimeZone(conversion_times[2], 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', conversion_times[2], conversion_times[3]), NULL) AS step_2_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, uuid_0 AS uuid_0, `$session_id_0` AS `$session_id_0`, `$window_id_0` AS `$window_id_0`, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_1, last_value(uuid_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_1, last_value(`$session_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_1`, last_value(`$window_id_1`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_1`, step_2 AS step_2, min(latest_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS latest_2, last_value(uuid_2) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS uuid_2, last_value(`$session_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$session_id_2`, last_value(`$window_id_2`) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) AS `$window_id_2` - FROM - (SELECT toTimeZone(e.timestamp, 'UTC') AS timestamp, e__pdi.person_id AS aggregation_target, e.uuid AS uuid, if(equals(e.event, 'step three'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(ifNull(equals(step_0, 1), 0), uuid, NULL) AS uuid_0, if(ifNull(equals(step_0, 1), 0), e.`$session_id`, NULL) AS `$session_id_0`, if(ifNull(equals(step_0, 1), 0), e.`$window_id`, NULL) AS `$window_id_0`, if(equals(e.event, 'step one'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1, if(ifNull(equals(step_1, 1), 0), uuid, NULL) AS uuid_1, if(ifNull(equals(step_1, 1), 0), e.`$session_id`, NULL) AS `$session_id_1`, if(ifNull(equals(step_1, 1), 0), e.`$window_id`, NULL) AS `$window_id_1`, if(equals(e.event, 'step two'), 1, 0) AS step_2, if(ifNull(equals(step_2, 1), 0), timestamp, NULL) AS latest_2, if(ifNull(equals(step_2, 1), 0), uuid, NULL) AS uuid_2, if(ifNull(equals(step_2, 1), 0), e.`$session_id`, NULL) AS `$session_id_2`, if(ifNull(equals(step_2, 1), 0), e.`$window_id`, NULL) AS `$window_id_2` - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))) - WHERE ifNull(equals(step_0, 1), 0))) - GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) - and isNull(max(max_steps)))) - WHERE ifNull(in(steps, [1, 2, 3]), 0) - ORDER BY aggregation_target ASC) AS source))) + WHERE equals(person.team_id, 2) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.id ASC @@ -349,9 +270,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, allow_experimental_analyzer=1 ''' diff --git a/posthog/hogql_queries/insights/funnels/test/breakdown_cases.py b/posthog/hogql_queries/insights/funnels/test/breakdown_cases.py index cb38a0f91be71..b284c6087a583 100644 --- a/posthog/hogql_queries/insights/funnels/test/breakdown_cases.py +++ b/posthog/hogql_queries/insights/funnels/test/breakdown_cases.py @@ -1,15 +1,13 @@ +from collections.abc import Callable from dataclasses import dataclass from datetime import datetime - from string import ascii_lowercase from typing import Any, Literal, Optional, Union, cast -from collections.abc import Callable from posthog.constants import INSIGHT_FUNNELS, FunnelOrderType from posthog.hogql_queries.insights.funnels.funnels_query_runner import FunnelsQueryRunner from posthog.hogql_queries.legacy_compatibility.filter_to_query import filter_to_query from posthog.models.action.action import Action - from posthog.models.cohort import Cohort from posthog.models.filters import Filter from posthog.models.group.util import create_group @@ -17,7 +15,7 @@ from posthog.models.instance_setting import override_instance_config from posthog.models.person.person import Person from posthog.queries.breakdown_props import ALL_USERS_COHORT_ID -from posthog.schema import FunnelsQuery +from posthog.schema import BaseMathType, FunnelsQuery from posthog.test.base import ( APIBaseTest, also_test_with_materialized_columns, @@ -2663,6 +2661,77 @@ def test_funnel_breakdown_correct_breakdown_props_are_chosen_for_step(self): self.assertCountEqual([res[0]["breakdown"] for res in results], [["Mac"], ["Safari"]]) + def test_funnel_step_breakdown_with_first_time_for_user_math(self): + filters = { + "insight": INSIGHT_FUNNELS, + "funnel_order_type": funnel_order_type, + "events": [ + {"id": "sign up", "order": 0, "math": BaseMathType.FIRST_TIME_FOR_USER}, + {"id": "play movie", "order": 1}, + ], + "date_from": "2020-01-01", + "date_to": "2020-01-08", + "funnel_window_days": 7, + "breakdown_type": "event", + "breakdown": ["$browser"], + "breakdown_attribution_type": "all_events", + } + + people = journeys_for( + { + "person1": [ + { + "event": "sign up", + "timestamp": datetime(2020, 1, 1, 12), + "properties": {"$browser": "Safari"}, + }, + { + "event": "play movie", + "timestamp": datetime(2020, 1, 2, 12, 30), + "properties": {"$browser": "Safari"}, + }, + { + "event": "sign up", + "timestamp": datetime(2020, 1, 2, 13), + "properties": {"$browser": "Chrome"}, + }, + { + "event": "play movie", + "timestamp": datetime(2020, 1, 2, 14), + "properties": {"$browser": "Safari"}, + }, + ] + }, + self.team, + ) + + query = cast(FunnelsQuery, filter_to_query(filters)) + results = FunnelsQueryRunner(query=query, team=self.team).calculate().results + + self.assertEqual(len(results), 1) + self._assert_funnel_breakdown_result_is_correct( + results[0], + [ + FunnelStepResult(name="sign up", count=1, breakdown=["Safari"]), + FunnelStepResult( + name="play movie", + count=1, + breakdown=["Safari"], + average_conversion_time=88200, + median_conversion_time=88200, + ), + ], + ) + + self.assertCountEqual( + self._get_actor_ids_at_step(filters, 1, "Safari"), + [people["person1"].uuid], + ) + self.assertCountEqual( + self._get_actor_ids_at_step(filters, 2, "Safari"), + [people["person1"].uuid], + ) + return TestFunnelBreakdown diff --git a/posthog/hogql_queries/insights/funnels/test/test_funnel.py b/posthog/hogql_queries/insights/funnels/test/test_funnel.py index d48ceadccf170..0a25bd220b7a4 100644 --- a/posthog/hogql_queries/insights/funnels/test/test_funnel.py +++ b/posthog/hogql_queries/insights/funnels/test/test_funnel.py @@ -1,16 +1,27 @@ +import uuid from datetime import datetime from typing import cast -import uuid + from django.test import override_settings from freezegun import freeze_time from rest_framework.exceptions import ValidationError + from posthog.api.instance_settings import get_instance_setting from posthog.clickhouse.client.execute import sync_execute from posthog.constants import INSIGHT_FUNNELS, FunnelOrderType, FunnelVizType from posthog.hogql.query import execute_hogql_query from posthog.hogql_queries.actors_query_runner import ActorsQueryRunner +from posthog.hogql_queries.insights.funnels import Funnel from posthog.hogql_queries.insights.funnels.funnel_query_context import FunnelQueryContext from posthog.hogql_queries.insights.funnels.funnels_query_runner import FunnelsQueryRunner +from posthog.hogql_queries.insights.funnels.test.breakdown_cases import ( + assert_funnel_results_equal, + funnel_breakdown_group_test_factory, + funnel_breakdown_test_factory, +) +from posthog.hogql_queries.insights.funnels.test.conversion_time_cases import ( + funnel_conversion_time_test_factory, +) from posthog.hogql_queries.legacy_compatibility.filter_to_query import filter_to_query from posthog.models import Action, Element from posthog.models.cohort.cohort import Cohort @@ -19,15 +30,19 @@ from posthog.models.property_definition import PropertyDefinition from posthog.queries.funnels import ClickhouseFunnelActors from posthog.schema import ( + ActionsNode, ActorsQuery, + BaseMathType, BreakdownFilter, BreakdownType, - FunnelConversionWindowTimeUnit, - FunnelsFilter, - InsightDateRange, + EventPropertyFilter, EventsNode, + FunnelConversionWindowTimeUnit, FunnelsActorsQuery, + FunnelsFilter, FunnelsQuery, + InsightDateRange, + PropertyOperator, ) from posthog.test.base import ( APIBaseTest, @@ -39,15 +54,6 @@ create_person_id_override_by_distinct_id, snapshot_clickhouse_queries, ) -from posthog.hogql_queries.insights.funnels.test.conversion_time_cases import ( - funnel_conversion_time_test_factory, -) -from posthog.hogql_queries.insights.funnels.test.breakdown_cases import ( - funnel_breakdown_test_factory, - funnel_breakdown_group_test_factory, - assert_funnel_results_equal, -) -from posthog.hogql_queries.insights.funnels import Funnel from posthog.test.test_journeys import journeys_for @@ -3768,6 +3774,271 @@ def test_time_to_convert_funnel_ignores_breakdown(self): assert result.average_conversion_time == 210 assert result.bins == [[60, 1], [210, 0], [360, 1]] + def test_first_time_for_user_funnel_basic(self): + _create_person( + distinct_ids=[f"user_1"], + team=self.team, + ) + + events_by_person = { + "user_1": [ + { + "event": "$pageview", + "timestamp": datetime(2024, 3, 22, 13, 46), + }, + { + "event": "$pageview", + "timestamp": datetime(2024, 3, 22, 13, 47), + }, + ], + } + journeys_for(events_by_person, self.team) + + query = FunnelsQuery( + series=[ + EventsNode(event="$pageview", math=BaseMathType.FIRST_TIME_FOR_USER), + EventsNode(event="$pageview"), + ], + dateRange=InsightDateRange( + date_from="2024-03-22", + date_to="2024-03-22", + ), + ) + results = FunnelsQueryRunner(query=query, team=self.team).calculate().results + + self.assertEqual(results[0]["count"], 1) + self.assertEqual(results[1]["count"], 1) + + query = FunnelsQuery( + series=[ + EventsNode(event="$pageview", math=BaseMathType.FIRST_TIME_FOR_USER), + EventsNode(event="$pageview", math=BaseMathType.FIRST_TIME_FOR_USER), + ], + dateRange=InsightDateRange( + date_from="2024-03-22", + date_to="2024-03-22", + ), + ) + results = FunnelsQueryRunner(query=query, team=self.team).calculate().results + + self.assertEqual(results[0]["count"], 1) + self.assertEqual(results[1]["count"], 0) + + def test_first_time_for_user_funnel_with_actions(self): + action_credit_card = Action.objects.create( + team=self.team, + name="paid", + steps_json=[ + { + "event": "$autocapture", + "tag_name": "button", + "text": "Pay $10", + } + ], + ) + action_play_movie = Action.objects.create( + team=self.team, + name="watched movie", + steps_json=[ + { + "event": "$autocapture", + "tag_name": "a", + "href": "/movie", + } + ], + ) + + # events + person_factory(distinct_ids=["stopped_after_signup"], team_id=self.team.pk) + self._signup_event(distinct_id="stopped_after_signup") + + person_factory(distinct_ids=["stopped_after_pay"], team_id=self.team.pk) + self._signup_event(distinct_id="stopped_after_pay") + self._pay_event(distinct_id="stopped_after_pay") + + person_factory( + distinct_ids=["had_anonymous_id", "completed_movie"], + team_id=self.team.pk, + ) + self._signup_event(distinct_id="had_anonymous_id") + self._pay_event(distinct_id="completed_movie") + self._movie_event(distinct_id="completed_movie") + + person_factory(distinct_ids=["just_did_movie"], team_id=self.team.pk) + self._movie_event(distinct_id="just_did_movie") + + person_factory(distinct_ids=["wrong_order"], team_id=self.team.pk) + self._pay_event(distinct_id="wrong_order") + self._signup_event(distinct_id="wrong_order") + self._movie_event(distinct_id="wrong_order") + + # somewhere in the past + self._movie_event(distinct_id="completed_movie", timestamp="2020-01-01") + + query = FunnelsQuery( + series=[ + EventsNode(event="user signed up"), + ActionsNode(id=action_credit_card.pk), + ActionsNode(id=action_play_movie.pk, math=BaseMathType.FIRST_TIME_FOR_USER), + ], + dateRange=InsightDateRange( + date_from="-14d", + ), + ) + result = FunnelsQueryRunner(query=query, team=self.team).calculate().results + + self.assertEqual(result[0]["name"], "user signed up") + self.assertEqual(result[0]["count"], 4) + + self.assertEqual(result[1]["name"], "paid") + self.assertEqual(result[1]["count"], 2) + self.assertEqual(result[2]["name"], "watched movie") + self.assertEqual(result[2]["count"], 0) + + def test_first_time_for_user_funnel_filters(self): + _create_person( + distinct_ids=[f"user_1"], + team=self.team, + ) + + events_by_person = { + "user_1": [ + { + "event": "$pageview", + "timestamp": datetime(2024, 3, 22, 13, 46), + "properties": {"$browser": "Chrome"}, + }, + { + "event": "$pageview", + "timestamp": datetime(2024, 3, 22, 13, 47), + "properties": {"$browser": "Chrome"}, + }, + ], + } + journeys_for(events_by_person, self.team) + + query = FunnelsQuery( + series=[ + EventsNode(event="$pageview"), + EventsNode(event="$pageview", math=BaseMathType.FIRST_TIME_FOR_USER), + ], + dateRange=InsightDateRange( + date_from="2024-03-22", + date_to="2024-03-22", + ), + ) + results = FunnelsQueryRunner(query=query, team=self.team).calculate().results + + self.assertEqual(results[0]["count"], 1) + self.assertEqual(results[1]["count"], 0) + + query = FunnelsQuery( + series=[ + EventsNode( + event="$pageview", + properties=[ + EventPropertyFilter(key="$browser", operator=PropertyOperator.EXACT, value="Chrome"), + ], + math=BaseMathType.FIRST_TIME_FOR_USER, + ), + EventsNode(event="$pageview"), + ], + dateRange=InsightDateRange( + date_from="2024-03-22", + date_to="2024-03-22", + ), + ) + results = FunnelsQueryRunner(query=query, team=self.team).calculate().results + + self.assertEqual(results[0]["count"], 1) + self.assertEqual(results[1]["count"], 1) + + def test_first_time_for_user_funnel_multiple_ids(self): + _create_person( + distinct_ids=["user_1", "anon_1"], + team=self.team, + ) + _create_person( + distinct_ids=["anon_2", "user_2"], + team=self.team, + ) + _create_person( + distinct_ids=["anon_3"], + team=self.team, + ) + + # person 1 + _create_event( + team=self.team, + event="$pageview", + distinct_id="user_1", + timestamp="2024-03-22T13:00:00Z", + ) + _create_event( + team=self.team, + event="$pageview", + distinct_id="user_1", + timestamp="2024-03-22T14:00:00Z", + ) + _create_event( + team=self.team, + event="$pageview", + distinct_id="anon_1", + timestamp="2023-03-22T13:00:00Z", + ) + + # person 2 + _create_event( + team=self.team, + event="$pageview", + distinct_id="anon_2", + timestamp="2024-03-22T13:00:00Z", + ) + _create_event( + team=self.team, + event="$pageview", + distinct_id="user_2", + timestamp="2024-03-22T14:00:00Z", + ) + + # person 3 + _create_event( + team=self.team, + event="$pageview", + distinct_id="anon_3", + timestamp="2024-03-22T15:00:00Z", + ) + + query = FunnelsQuery( + series=[ + EventsNode(event="$pageview", math=BaseMathType.FIRST_TIME_FOR_USER), + EventsNode(event="$pageview"), + ], + dateRange=InsightDateRange( + date_from="2024-03-22", + date_to="2024-03-22", + ), + ) + results = FunnelsQueryRunner(query=query, team=self.team).calculate().results + + self.assertEqual(results[0]["count"], 2) + self.assertEqual(results[1]["count"], 1) + + query = FunnelsQuery( + series=[ + EventsNode(event="$pageview", math=BaseMathType.FIRST_TIME_FOR_USER), + EventsNode(event="$pageview"), + ], + dateRange=InsightDateRange( + date_from="2023-03-22", + date_to="2024-03-22", + ), + ) + results = FunnelsQueryRunner(query=query, team=self.team).calculate().results + + self.assertEqual(results[0]["count"], 3) + self.assertEqual(results[1]["count"], 1) + return TestGetFunnel diff --git a/posthog/hogql_queries/insights/funnels/test/test_funnel_aggregation_operations.py b/posthog/hogql_queries/insights/funnels/test/test_funnel_aggregation_operations.py new file mode 100644 index 0000000000000..1049b487ebcbb --- /dev/null +++ b/posthog/hogql_queries/insights/funnels/test/test_funnel_aggregation_operations.py @@ -0,0 +1,218 @@ +from datetime import datetime +from typing import cast +from zoneinfo import ZoneInfo + +from freezegun import freeze_time + +from posthog.hogql import ast +from posthog.hogql.parser import parse_expr +from posthog.hogql_queries.insights.funnels.funnel_aggregation_operations import FirstTimeForUserAggregationQuery +from posthog.hogql_queries.insights.funnels.funnel_query_context import FunnelQueryContext +from posthog.schema import EventsNode, FunnelsFilter, FunnelsQuery, InsightDateRange +from posthog.test.base import APIBaseTest, ClickhouseTestMixin + + +class TestFunnelAggregationOperations(ClickhouseTestMixin, APIBaseTest): + def test_first_time_for_user_aggregation_outer_query(self): + funnels_query = FunnelsQuery( + series=[EventsNode(event="$pageview")], + funnelsFilter=FunnelsFilter(funnelWindowInterval=14), + dateRange=InsightDateRange(date_from="-14d"), + ) + ctx = FunnelQueryContext(funnels_query, self.team) + filters = parse_expr("1 = 1") + event_filter = parse_expr("2 = 2") + + builder = FirstTimeForUserAggregationQuery(context=ctx, filters=filters, event_or_action_filter=event_filter) + query = builder.to_query() + + assert isinstance(query.select[0], ast.Field) + assert query.select[0].chain == ["uuid"] + assert query.select_from is not None + assert isinstance(query.select_from.table, ast.SelectQuery) + + def test_first_time_for_user_aggregation_query_select(self): + funnels_query = FunnelsQuery( + series=[EventsNode(event="$pageview")], + funnelsFilter=FunnelsFilter(funnelWindowInterval=14), + dateRange=InsightDateRange(date_from="-14d"), + ) + + with freeze_time("2024-07-31"): + ctx = FunnelQueryContext(funnels_query, self.team) + filters = parse_expr("1 = 1") + event_filter = parse_expr("2 = 2") + + builder = FirstTimeForUserAggregationQuery( + context=ctx, filters=filters, event_or_action_filter=event_filter + ) + query = builder.to_query() + + assert query.select_from is not None + query = cast(ast.SelectQuery, query.select_from.table) + + first = query.select[0] + assert isinstance(first, ast.Alias) + assert first.alias == "min_timestamp" + assert isinstance(first.expr, ast.Call) + assert first.expr.name == "min" + assert isinstance(first.expr.args[0], ast.Field) + assert first.expr.args[0].chain == ["timestamp"] + + second = query.select[1] + assert isinstance(second, ast.Alias) + assert second.alias == "min_timestamp_with_condition" + assert isinstance(second.expr, ast.Call) + assert second.expr.name == "minIf" + assert isinstance(second.expr.args[0], ast.Field) + assert second.expr.args[0].chain == ["timestamp"] + assert isinstance(second.expr.args[1], ast.And) + assert len(second.expr.args[1].exprs) == 2 + assert isinstance(second.expr.args[1].exprs[0], ast.CompareOperation) + date_from = second.expr.args[1].exprs[0].right + assert isinstance(date_from, ast.Constant) + assert date_from.value == datetime(2024, 7, 17, tzinfo=ZoneInfo(key="UTC")) + assert second.expr.args[1].exprs[1] == filters + + third = query.select[2] + assert isinstance(third, ast.Alias) + assert third.alias == "uuid" + assert isinstance(third.expr, ast.Call) + assert third.expr.name == "argMin" + assert isinstance(third.expr.args[0], ast.Field) + assert third.expr.args[0].chain == ["uuid"] + assert isinstance(third.expr.args[1], ast.Field) + assert third.expr.args[1].chain == ["timestamp"] + + def test_first_time_for_user_aggregation_query_filter(self): + funnels_query = FunnelsQuery( + series=[EventsNode(event="$pageview")], + funnelsFilter=FunnelsFilter(funnelWindowInterval=14), + dateRange=InsightDateRange(date_from="-14d"), + ) + + with freeze_time("2024-07-31"): + ctx = FunnelQueryContext(funnels_query, self.team) + filters = parse_expr("1 = 1") + event_filter = parse_expr("2 = 2") + + builder = FirstTimeForUserAggregationQuery( + context=ctx, filters=filters, event_or_action_filter=event_filter + ) + query = builder.to_query() + + assert query.select_from is not None + query = cast(ast.SelectQuery, query.select_from.table) + + assert isinstance(query.where, ast.And) + assert isinstance(query.where.exprs[0], ast.CompareOperation) + date_from = query.where.exprs[0].right + assert isinstance(date_from, ast.Constant) + assert date_from.value == datetime(2024, 7, 31, 23, 59, 59, 999999, tzinfo=ZoneInfo(key="UTC")) + assert query.where.exprs[1] == event_filter + + def test_first_time_for_user_aggregation_query_no_filters(self): + funnels_query = FunnelsQuery( + series=[EventsNode(event="$pageview")], + funnelsFilter=FunnelsFilter(funnelWindowInterval=14), + dateRange=InsightDateRange(date_from="-14d"), + ) + + with freeze_time("2024-07-31"): + ctx = FunnelQueryContext(funnels_query, self.team) + builder = FirstTimeForUserAggregationQuery(context=ctx) + query = builder.to_query() + + assert query.select_from is not None + query = cast(ast.SelectQuery, query.select_from.table) + + second = query.select[1] + assert isinstance(second, ast.Alias) + assert isinstance(second.expr, ast.Call) + assert isinstance(second.expr.args[1], ast.CompareOperation) + date_from = second.expr.args[1].right + assert isinstance(date_from, ast.Constant) + assert date_from.value == datetime(2024, 7, 17, tzinfo=ZoneInfo(key="UTC")) + + assert isinstance(query.where, ast.CompareOperation) + date_from = query.where.right + assert isinstance(date_from, ast.Constant) + assert date_from.value == datetime(2024, 7, 31, 23, 59, 59, 999999, tzinfo=ZoneInfo(key="UTC")) + + def test_first_time_for_user_aggregation_query_group_by(self): + funnels_query = FunnelsQuery( + series=[EventsNode(event="$pageview")], + funnelsFilter=FunnelsFilter(funnelWindowInterval=14), + dateRange=InsightDateRange(date_from="-14d"), + ) + ctx = FunnelQueryContext(funnels_query, self.team) + + builder = FirstTimeForUserAggregationQuery(context=ctx) + query = builder.to_query() + + assert query.select_from is not None + query = cast(ast.SelectQuery, query.select_from.table) + + assert query.group_by is not None + assert isinstance(query.group_by[0], ast.Field) + assert query.group_by[0].chain == ["person_id"] + + def test_first_time_for_user_aggregation_query_having(self): + funnels_query = FunnelsQuery( + series=[EventsNode(event="$pageview")], + funnelsFilter=FunnelsFilter(funnelWindowInterval=14), + dateRange=InsightDateRange(date_from="-14d"), + ) + ctx = FunnelQueryContext(funnels_query, self.team) + + builder = FirstTimeForUserAggregationQuery(context=ctx) + query = builder.to_query() + + assert query.select_from is not None + query = cast(ast.SelectQuery, query.select_from.table) + + assert query.having is not None + assert isinstance(query.having, ast.CompareOperation) + assert query.having.op == ast.CompareOperationOp.Eq + assert isinstance(query.having.left, ast.Field) + assert query.having.left.chain == ["min_timestamp"] + assert isinstance(query.having.right, ast.Field) + assert query.having.right.chain == ["min_timestamp_with_condition"] + + def test_first_time_for_user_aggregation_query_sampling_factor(self): + funnels_query = FunnelsQuery( + series=[EventsNode(event="$pageview")], + funnelsFilter=FunnelsFilter(funnelWindowInterval=14), + dateRange=InsightDateRange(date_from="-14d"), + samplingFactor=0.1, + ) + ctx = FunnelQueryContext(funnels_query, self.team) + + builder = FirstTimeForUserAggregationQuery(context=ctx) + query = builder.to_query() + + assert query.select_from is not None + query = cast(ast.SelectQuery, query.select_from.table) + + assert query.select_from is not None + assert query.select_from.sample is not None + assert query.select_from.sample.sample_value == ast.RatioExpr(left=ast.Constant(value=0.1)) + + def test_first_time_for_user_aggregation_query_select_from(self): + funnels_query = FunnelsQuery( + series=[EventsNode(event="$pageview")], + funnelsFilter=FunnelsFilter(funnelWindowInterval=14), + dateRange=InsightDateRange(date_from="-14d"), + ) + ctx = FunnelQueryContext(funnels_query, self.team) + + builder = FirstTimeForUserAggregationQuery(context=ctx) + query = builder.to_query() + + assert query.select_from is not None + query = cast(ast.SelectQuery, query.select_from.table) + + assert query.select_from is not None + assert query.select_from.sample is None + assert isinstance(query.select_from.table, ast.Field) + assert query.select_from.table.chain == ["events"] diff --git a/posthog/hogql_queries/insights/funnels/test/test_funnel_persons.py b/posthog/hogql_queries/insights/funnels/test/test_funnel_persons.py index 4f1268c784dc4..e240e54f3f963 100644 --- a/posthog/hogql_queries/insights/funnels/test/test_funnel_persons.py +++ b/posthog/hogql_queries/insights/funnels/test/test_funnel_persons.py @@ -1,11 +1,10 @@ from datetime import datetime, timedelta -from typing import Optional, cast, Any +from typing import Any, Optional, cast from uuid import UUID from django.utils import timezone from freezegun import freeze_time - from posthog.constants import INSIGHT_FUNNELS from posthog.hogql_queries.actors_query_runner import ActorsQueryRunner from posthog.hogql_queries.legacy_compatibility.filter_to_query import filter_to_query @@ -13,7 +12,7 @@ from posthog.models.event.util import bulk_create_events from posthog.models.person.util import bulk_create_persons from posthog.models.team.team import Team -from posthog.schema import ActorsQuery, FunnelsActorsQuery, FunnelsQuery +from posthog.schema import ActorsQuery, BaseMathType, FunnelsActorsQuery, FunnelsQuery from posthog.session_recordings.queries.test.session_replay_sql import produce_replay_summary from posthog.test.base import ( APIBaseTest, @@ -669,3 +668,144 @@ def test_parses_step_breakdown_correctly(self): results = get_actors(filters, self.team, funnel_step=1, funnel_step_breakdown=["test'123"]) self.assertCountEqual([results[0][0]], [person1.uuid]) + + def test_first_time_math_basic(self): + person1 = _create_person( + distinct_ids=["person1"], + team_id=self.team.pk, + ) + journeys_for( + { + "person1": [ + { + "event": "sign up", + "timestamp": datetime(2020, 1, 1, 12), + }, + { + "event": "sign up", + "timestamp": datetime(2020, 1, 2, 12), + }, + { + "event": "play movie", + "timestamp": datetime(2020, 1, 1, 13), + }, + { + "event": "play movie", + "timestamp": datetime(2020, 1, 2, 13), + }, + ], + }, + self.team, + create_people=False, + ) + + filters = { + "insight": INSIGHT_FUNNELS, + "date_from": "2020-01-01", + "date_to": "2020-01-08", + "interval": "day", + "funnel_window_days": 7, + "events": [ + {"id": "sign up", "order": 0, "math": BaseMathType.FIRST_TIME_FOR_USER}, + {"id": "play movie", "order": 1}, + ], + "breakdown_type": "event", + "breakdown": "$browser", + } + + results = get_actors(filters, self.team, funnel_step=1) + self.assertCountEqual([results[0][0]], [person1.uuid]) + + filters = { + "insight": INSIGHT_FUNNELS, + "date_from": "2020-01-02", + "date_to": "2020-01-08", + "interval": "day", + "funnel_window_days": 7, + "events": [ + {"id": "sign up", "order": 0, "math": BaseMathType.FIRST_TIME_FOR_USER}, + {"id": "play movie", "order": 1}, + ], + } + + results = get_actors(filters, self.team, funnel_step=1) + self.assertEqual(len(results), 0) + + def test_first_time_math_multiple_ids(self): + _create_person( + distinct_ids=["anon1", "person1"], + team_id=self.team.pk, + ) + _create_person( + distinct_ids=["anon2", "person2"], + team_id=self.team.pk, + ) + journeys_for( + { + "anon1": [ + { + "event": "sign up", + "timestamp": datetime(2020, 1, 1, 12), + }, + ], + "person1": [ + { + "event": "play movie", + "timestamp": datetime(2020, 1, 1, 13), + }, + ], + "anon2": [ + { + "event": "sign up", + "timestamp": datetime(2019, 1, 1, 12), + }, + { + "event": "sign up", + "timestamp": datetime(2020, 1, 1, 12), + }, + ], + "person2": [ + { + "event": "play movie", + "timestamp": datetime(2020, 1, 1, 13), + }, + ], + }, + self.team, + create_people=False, + ) + + filters = { + "insight": INSIGHT_FUNNELS, + "date_from": "2020-01-01", + "date_to": "2020-01-08", + "interval": "day", + "funnel_window_days": 7, + "events": [ + {"id": "sign up", "order": 0, "math": BaseMathType.FIRST_TIME_FOR_USER}, + {"id": "play movie", "order": 1}, + ], + } + + results = get_actors(filters, self.team, funnel_step=1) + self.assertEqual(len(results), 1) + self.assertCountEqual(set(results[0][1]["distinct_ids"]), {"person1", "anon1"}) + + filters = { + "insight": INSIGHT_FUNNELS, + "date_from": "2019-01-01", + "date_to": "2020-01-08", + "interval": "day", + "funnel_window_days": 7, + "events": [ + {"id": "sign up", "order": 0, "math": BaseMathType.FIRST_TIME_FOR_USER}, + {"id": "play movie", "order": 1}, + ], + "breakdown_type": "event", + "breakdown": "$browser", + } + + results = get_actors(filters, self.team, funnel_step=1) + self.assertEqual(len(results), 2) + self.assertCountEqual(set(results[0][1]["distinct_ids"]), {"person1", "anon1"}) + self.assertCountEqual(set(results[1][1]["distinct_ids"]), {"person2", "anon2"}) diff --git a/posthog/hogql_queries/insights/retention_query_runner.py b/posthog/hogql_queries/insights/retention_query_runner.py index d4fcf9d4ee9be..f5d817e2eb7f8 100644 --- a/posthog/hogql_queries/insights/retention_query_runner.py +++ b/posthog/hogql_queries/insights/retention_query_runner.py @@ -368,6 +368,16 @@ def _refresh_frequency(self): return refresh_frequency + def get_date(self, first_interval): + date = self.query_date_range.date_from() + self.query_date_range.determine_time_delta( + first_interval, self.query_date_range.interval_name.title() + ) + if self.query_date_range.interval_type == IntervalType.HOUR: + utfoffset = self.team.timezone_info.utcoffset(date) + if utfoffset is not None: + date = date + utfoffset + return date + def calculate(self) -> RetentionQueryResponse: query = self.to_query() hogql = to_printed_hogql(query, self.team) @@ -388,7 +398,6 @@ def calculate(self) -> RetentionQueryResponse: } for (breakdown_values, intervals_from_base, count) in response.results } - results = [ { "values": [ @@ -396,12 +405,7 @@ def calculate(self) -> RetentionQueryResponse: for return_interval in range(self.query_date_range.total_intervals - first_interval) ], "label": f"{self.query_date_range.interval_name.title()} {first_interval}", - "date": ( - self.query_date_range.date_from() - + self.query_date_range.determine_time_delta( - first_interval, self.query_date_range.interval_name.title() - ) - ), + "date": self.get_date(first_interval), } for first_interval in range(self.query_date_range.total_intervals) ] diff --git a/posthog/hogql_queries/insights/test/__snapshots__/test_insight_actors_query_runner.ambr b/posthog/hogql_queries/insights/test/__snapshots__/test_insight_actors_query_runner.ambr index 7da32ae06082c..052afc663b683 100644 --- a/posthog/hogql_queries/insights/test/__snapshots__/test_insight_actors_query_runner.ambr +++ b/posthog/hogql_queries/insights/test/__snapshots__/test_insight_actors_query_runner.ambr @@ -60,48 +60,19 @@ (SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'name'), ''), 'null'), '^"|"$', '') AS properties___name FROM person - WHERE and(equals(person.team_id, 2), in(tuple(person.id, person.version), - (SELECT person.id AS id, max(person.version) AS version - FROM person - WHERE and(equals(person.team_id, 2), in(person.id, - (SELECT source.actor_id AS actor_id - FROM - (SELECT aggregation_target AS actor_id - FROM - (SELECT aggregation_target AS aggregation_target, steps AS steps, avg(step_1_conversion_time) AS step_1_average_conversion_time_inner, median(step_1_conversion_time) AS step_1_median_conversion_time_inner - FROM - (SELECT aggregation_target AS aggregation_target, steps AS steps, max(steps) OVER (PARTITION BY aggregation_target) AS max_steps, step_1_conversion_time AS step_1_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, latest_1 AS latest_1, if(and(ifNull(less(latest_0, latest_1), 0), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), 2, 1) AS steps, if(and(isNotNull(latest_1), ifNull(lessOrEquals(latest_1, plus(toTimeZone(latest_0, 'UTC'), toIntervalDay(14))), 0)), dateDiff('second', latest_0, latest_1), NULL) AS step_1_conversion_time - FROM - (SELECT aggregation_target AS aggregation_target, timestamp AS timestamp, step_0 AS step_0, latest_0 AS latest_0, step_1 AS step_1, min(latest_1) OVER (PARTITION BY aggregation_target - ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) AS latest_1 - FROM - (SELECT toTimeZone(e.timestamp, 'US/Pacific') AS timestamp, e__pdi.person_id AS aggregation_target, if(equals(e.event, '$pageview'), 1, 0) AS step_0, if(ifNull(equals(step_0, 1), 0), timestamp, NULL) AS latest_0, if(equals(e.event, '$pageview'), 1, 0) AS step_1, if(ifNull(equals(step_1, 1), 0), timestamp, NULL) AS latest_1 - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 2) - GROUP BY person_distinct_id2.distinct_id - HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'US/Pacific'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'US/Pacific')), lessOrEquals(toTimeZone(e.timestamp, 'US/Pacific'), toDateTime64('2020-01-19 23:59:59.999999', 6, 'US/Pacific'))), in(e.event, tuple('$pageview'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0))))) - WHERE ifNull(equals(step_0, 1), 0))) - GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) - and isNull(max(max_steps)))) - WHERE ifNull(in(steps, [2]), 0) - ORDER BY aggregation_target ASC) AS source))) - GROUP BY person.id - HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1))), 0))))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) + WHERE and(equals(person.team_id, 2), ifNull(in(tuple(person.id, person.version), + (SELECT person.id AS id, max(person.version) AS version + FROM person + WHERE equals(person.team_id, 2) + GROUP BY person.id + HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'US/Pacific'), person.version), plus(now64(6, 'US/Pacific'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, source.actor_id) ORDER BY persons.properties___name ASC) LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -189,9 +160,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -222,9 +192,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -279,9 +248,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -313,9 +281,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -381,9 +348,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -458,9 +424,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/hogql_queries/insights/test/__snapshots__/test_lifecycle_query_runner.ambr b/posthog/hogql_queries/insights/test/__snapshots__/test_lifecycle_query_runner.ambr index 0bd87128f34ad..24b6d55a4c7ce 100644 --- a/posthog/hogql_queries/insights/test/__snapshots__/test_lifecycle_query_runner.ambr +++ b/posthog/hogql_queries/insights/test/__snapshots__/test_lifecycle_query_runner.ambr @@ -93,9 +93,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -170,9 +169,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -247,9 +245,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -324,9 +321,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/hogql_queries/insights/test/__snapshots__/test_paths_query_runner_ee.ambr b/posthog/hogql_queries/insights/test/__snapshots__/test_paths_query_runner_ee.ambr index 116dc151cba73..d4975a5c677b7 100644 --- a/posthog/hogql_queries/insights/test/__snapshots__/test_paths_query_runner_ee.ambr +++ b/posthog/hogql_queries/insights/test/__snapshots__/test_paths_query_runner_ee.ambr @@ -77,9 +77,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -161,9 +160,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -245,9 +243,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -329,9 +326,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -412,9 +408,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -495,9 +490,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -578,9 +572,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -661,9 +654,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -744,9 +736,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -827,9 +818,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -910,9 +900,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -1001,9 +990,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -1085,9 +1073,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -1169,9 +1156,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -1319,9 +1305,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1467,9 +1452,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1615,9 +1599,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1765,9 +1748,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1913,9 +1895,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2061,9 +2042,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2211,9 +2191,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2359,9 +2338,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2507,9 +2485,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2599,9 +2576,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -2751,9 +2727,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2766,9 +2741,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2920,9 +2894,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3074,9 +3047,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3089,9 +3061,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3241,9 +3212,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3256,9 +3226,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3418,9 +3387,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3433,9 +3401,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3516,9 +3483,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -3604,9 +3570,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -3762,9 +3727,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3850,9 +3814,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -4008,9 +3971,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4096,9 +4058,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -4254,9 +4215,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4342,9 +4302,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -4500,9 +4459,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4584,9 +4542,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -4667,9 +4624,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -4750,9 +4706,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -4898,9 +4853,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5046,9 +5000,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5129,9 +5082,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -5277,9 +5229,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5360,9 +5311,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -5508,9 +5458,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5656,9 +5605,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5804,9 +5752,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5887,9 +5834,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -5975,9 +5921,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- diff --git a/posthog/hogql_queries/insights/test/__snapshots__/test_retention_query_runner.ambr b/posthog/hogql_queries/insights/test/__snapshots__/test_retention_query_runner.ambr index 518a99bc726f3..f4d2059bf0fff 100644 --- a/posthog/hogql_queries/insights/test/__snapshots__/test_retention_query_runner.ambr +++ b/posthog/hogql_queries/insights/test/__snapshots__/test_retention_query_runner.ambr @@ -22,9 +22,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -68,9 +67,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -97,9 +95,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -126,9 +123,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -172,9 +168,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -201,9 +196,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -237,9 +231,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -282,9 +275,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -318,9 +310,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -365,9 +356,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -401,9 +391,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -437,9 +426,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -473,9 +461,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- @@ -509,9 +496,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=23622320128 ''' # --- diff --git a/posthog/hogql_queries/insights/test/test_retention_query_runner.py b/posthog/hogql_queries/insights/test/test_retention_query_runner.py index 99700be28a414..7e096d7a9ab64 100644 --- a/posthog/hogql_queries/insights/test/test_retention_query_runner.py +++ b/posthog/hogql_queries/insights/test/test_retention_query_runner.py @@ -660,6 +660,100 @@ def test_hour_interval(self): ], ) + def test_hour_interval_team_timezone(self): + self.team.timezone = "US/Pacific" + self.team.save() + + _create_person( + team=self.team, + distinct_ids=["person1", "alias1"], + properties={"email": "person1@test.com"}, + ) + _create_person( + team=self.team, + distinct_ids=["person2"], + properties={"email": "person2@test.com"}, + ) + + _create_events( + self.team, + [ + ("person1", _date(day=0, hour=6)), + ("person2", _date(day=0, hour=6)), + ("person1", _date(day=0, hour=7)), + ("person2", _date(day=0, hour=7)), + ("person1", _date(day=0, hour=8)), + ("person2", _date(day=0, hour=8)), + ("person1", _date(day=0, hour=10)), + ("person1", _date(day=0, hour=11)), + ("person2", _date(day=0, hour=11)), + ("person2", _date(day=0, hour=12)), + ("person1", _date(day=0, hour=14)), + ("person2", _date(day=0, hour=16)), + ], + ) + + result = self.run_query( + query={ + "dateRange": {"date_to": _date(0, hour=16, minute=13)}, + "retentionFilter": { + "period": "Hour", + "totalIntervals": 11, + }, + } + ) + + self.assertEqual( + pluck(result, "label"), + [ + "Hour 0", + "Hour 1", + "Hour 2", + "Hour 3", + "Hour 4", + "Hour 5", + "Hour 6", + "Hour 7", + "Hour 8", + "Hour 9", + "Hour 10", + ], + ) + + self.assertEqual( + pluck(result, "values", "count"), + [ + [2, 2, 2, 0, 1, 2, 1, 0, 1, 0, 1], + [2, 2, 0, 1, 2, 1, 0, 1, 0, 1], + [2, 0, 1, 2, 1, 0, 1, 0, 1], + [0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 0, 0, 1, 0, 0], + [2, 1, 0, 1, 0, 1], + [1, 0, 0, 0, 1], + [0, 0, 0, 0], + [1, 0, 0], + [0, 0], + [1], + ], + ) + + self.assertEqual( + pluck(result, "date"), + [ + datetime(2020, 6, 10, 6, tzinfo=ZoneInfo("UTC")), + datetime(2020, 6, 10, 7, tzinfo=ZoneInfo("UTC")), + datetime(2020, 6, 10, 8, tzinfo=ZoneInfo("UTC")), + datetime(2020, 6, 10, 9, tzinfo=ZoneInfo("UTC")), + datetime(2020, 6, 10, 10, tzinfo=ZoneInfo("UTC")), + datetime(2020, 6, 10, 11, tzinfo=ZoneInfo("UTC")), + datetime(2020, 6, 10, 12, tzinfo=ZoneInfo("UTC")), + datetime(2020, 6, 10, 13, tzinfo=ZoneInfo("UTC")), + datetime(2020, 6, 10, 14, tzinfo=ZoneInfo("UTC")), + datetime(2020, 6, 10, 15, tzinfo=ZoneInfo("UTC")), + datetime(2020, 6, 10, 16, tzinfo=ZoneInfo("UTC")), + ], + ) + # ensure that the first interval is properly rounded according to the specified period def test_interval_rounding(self): _create_person( diff --git a/posthog/hogql_queries/insights/trends/aggregation_operations.py b/posthog/hogql_queries/insights/trends/aggregation_operations.py index 908f3b7464cae..16c9d7bf028b5 100644 --- a/posthog/hogql_queries/insights/trends/aggregation_operations.py +++ b/posthog/hogql_queries/insights/trends/aggregation_operations.py @@ -6,6 +6,10 @@ from posthog.hogql_queries.insights.data_warehouse_mixin import ( DataWarehouseInsightQueryMixin, ) +from posthog.hogql_queries.insights.utils.aggregations import ( + FirstTimeForUserEventsQueryAlternator, + QueryAlternator, +) from posthog.hogql_queries.utils.query_date_range import QueryDateRange from posthog.models.team.team import Team from posthog.schema import ( @@ -17,134 +21,6 @@ ) -class QueryAlternator: - """Allows query_builder to modify the query without having to expose the whole AST interface""" - - _query: ast.SelectQuery - _selects: list[ast.Expr] - _group_bys: list[ast.Expr] - _select_from: ast.JoinExpr | None - - def __init__(self, query: ast.SelectQuery | ast.SelectUnionQuery): - assert isinstance(query, ast.SelectQuery) - - self._query = query - self._selects = [] - self._group_bys = [] - self._select_from = None - - def build(self) -> ast.SelectQuery | ast.SelectUnionQuery: - if len(self._selects) > 0: - self._query.select.extend(self._selects) - - if len(self._group_bys) > 0: - if self._query.group_by is None: - self._query.group_by = self._group_bys - else: - self._query.group_by.extend(self._group_bys) - - if self._select_from is not None: - self._query.select_from = self._select_from - - return self._query - - def append_select(self, expr: ast.Expr) -> None: - self._selects.append(expr) - - def extend_select(self, exprs: list[ast.Expr]) -> None: - self._selects.extend(exprs) - - def append_group_by(self, expr: ast.Expr) -> None: - self._group_bys.append(expr) - - def extend_group_by(self, exprs: list[ast.Expr]) -> None: - self._group_bys.extend(exprs) - - def replace_select_from(self, join_expr: ast.JoinExpr) -> None: - self._select_from = join_expr - - -class FirstTimeForUserEventsQueryAlternator(QueryAlternator): - """ - A specialized QueryAlternator for building queries that identify the first time an event or action occurs for each user. - - This class extends the base QueryAlternator to build a query that: - - Finds the minimum timestamp for `person_id` filtered by the event/action and right date range. - - Compares it with the minimum timestamp that satisfies general conditions like event/person properties and the left date range. - - Selects only those events where these two timestamps match. - """ - - def __init__( - self, - query: ast.SelectQuery, - date_from: ast.Expr, - date_to: ast.Expr, - filters: ast.Expr | None = None, - event_or_action_filter: ast.Expr | None = None, - ratio: ast.RatioExpr | None = None, - ): - query.select = self._select_expr(date_from, filters) - query.select_from = self._select_from_expr(ratio) - query.where = self._where_expr(date_to, event_or_action_filter) - query.group_by = [ast.Field(chain=["person_id"])] - query.having = ast.CompareOperation( - op=ast.CompareOperationOp.Eq, - left=ast.Field(chain=["min_timestamp"]), - right=ast.Field(chain=["min_timestamp_with_condition"]), - ) - - super().__init__(query) - - def _select_expr(self, date_from: ast.Expr, filters: ast.Expr | None = None): - aggregation_filters = date_from if filters is None else ast.And(exprs=[date_from, filters]) - return [ - ast.Alias( - alias="min_timestamp", - expr=ast.Call(name="min", args=[ast.Field(chain=["timestamp"])]), - ), - ast.Alias( - alias="min_timestamp_with_condition", - expr=ast.Call( - name="minIf", - args=[ast.Field(chain=["timestamp"]), aggregation_filters], - ), - ), - ] - - def _select_from_expr(self, ratio: ast.RatioExpr | None = None) -> ast.JoinExpr: - sample_value = ast.SampleExpr(sample_value=ratio) if ratio is not None else None - return ast.JoinExpr(table=ast.Field(chain=["events"]), alias="e", sample=sample_value) - - def _where_expr(self, date_to: ast.Expr, event_or_action_filter: ast.Expr | None = None) -> ast.Expr: - where_filters = [date_to] - if event_or_action_filter is not None: - where_filters.append(event_or_action_filter) - - if len(where_filters) > 1: - where_filters_expr = cast(ast.Expr, ast.And(exprs=where_filters)) - else: - where_filters_expr = where_filters[0] - return where_filters_expr - - def _transform_column(self, column: ast.Expr): - return ast.Call( - name="argMin", - args=[column, ast.Field(chain=["timestamp"])], - ) - - def append_select(self, expr: ast.Expr, aggregate: bool = False): - if aggregate: - if isinstance(expr, ast.Alias): - expr = ast.Alias(expr=self._transform_column(expr.expr), alias=expr.alias) - else: - expr = self._transform_column(expr) - super().append_select(expr) - - def extend_select(self, exprs: list[ast.Expr], aggregate: bool = False) -> None: - for expr in exprs: - self.append_select(expr, aggregate) - - class AggregationOperations(DataWarehouseInsightQueryMixin): team: Team series: Union[EventsNode, ActionsNode, DataWarehouseNode] diff --git a/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr b/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr index a30c0d235550c..e6896e9910b67 100644 --- a/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr +++ b/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr @@ -91,9 +91,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -178,9 +177,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -227,9 +225,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -286,9 +283,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -301,9 +297,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -350,9 +345,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -391,9 +385,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -432,9 +425,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -473,9 +465,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -514,9 +505,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -575,9 +565,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -636,9 +625,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -734,9 +722,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -783,9 +770,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -848,9 +834,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -896,9 +881,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -944,9 +928,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -992,9 +975,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1040,9 +1022,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1125,9 +1106,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1192,9 +1172,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1235,9 +1214,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1307,9 +1285,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1322,9 +1299,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1357,9 +1333,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1433,9 +1408,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1509,9 +1483,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1573,9 +1546,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1637,9 +1609,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1664,9 +1635,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1735,9 +1705,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1806,9 +1775,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1851,9 +1819,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1896,9 +1863,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1923,9 +1889,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1968,9 +1933,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1995,9 +1959,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2040,9 +2003,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2076,9 +2038,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2110,9 +2071,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2153,9 +2113,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2196,9 +2155,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2239,9 +2197,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2266,9 +2223,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2300,9 +2256,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2347,9 +2302,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2374,9 +2328,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2422,9 +2375,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2449,9 +2401,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2483,9 +2434,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2530,9 +2480,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2557,9 +2506,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2605,9 +2553,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2632,9 +2579,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2666,9 +2612,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2713,9 +2658,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2740,9 +2684,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2788,9 +2731,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2822,9 +2764,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2849,9 +2790,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2883,9 +2823,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2910,9 +2849,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2944,9 +2882,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2971,9 +2908,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2998,9 +2934,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3025,9 +2960,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3052,9 +2986,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3079,9 +3012,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3106,9 +3038,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3133,9 +3064,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3194,9 +3124,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3255,9 +3184,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3282,9 +3210,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3327,9 +3254,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3386,9 +3312,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3445,9 +3370,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3485,9 +3409,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3525,9 +3448,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3566,9 +3488,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3593,9 +3514,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3620,9 +3540,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3674,9 +3593,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3728,9 +3646,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3784,9 +3701,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3831,9 +3747,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3878,9 +3793,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3925,9 +3839,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3972,9 +3885,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3999,9 +3911,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4026,9 +3937,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4053,9 +3963,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4080,9 +3989,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4107,9 +4015,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4157,9 +4064,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4199,9 +4105,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4241,9 +4146,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4268,9 +4172,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4300,9 +4203,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4332,9 +4234,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4371,9 +4272,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4436,9 +4336,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4501,9 +4400,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4528,9 +4426,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4554,9 +4451,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4580,9 +4476,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4620,9 +4515,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4660,9 +4554,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4716,9 +4609,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4772,9 +4664,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4828,9 +4719,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4884,9 +4774,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4921,9 +4810,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4958,9 +4846,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4995,9 +4882,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5042,9 +4928,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5089,9 +4974,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5136,9 +5020,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5194,9 +5077,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5252,9 +5134,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5299,9 +5180,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5346,9 +5226,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5393,9 +5272,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -5440,9 +5318,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends_data_warehouse_query.ambr b/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends_data_warehouse_query.ambr index 0912ca865eb33..e7519a92714c5 100644 --- a/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends_data_warehouse_query.ambr +++ b/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends_data_warehouse_query.ambr @@ -34,9 +34,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -75,9 +74,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -102,9 +100,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -129,9 +126,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -156,9 +152,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/hogql_queries/insights/trends/test/test_aggregation_operations.py b/posthog/hogql_queries/insights/trends/test/test_aggregation_operations.py index 3ae50b503359c..ddc4379b37320 100644 --- a/posthog/hogql_queries/insights/trends/test/test_aggregation_operations.py +++ b/posthog/hogql_queries/insights/trends/test/test_aggregation_operations.py @@ -1,14 +1,11 @@ from datetime import datetime -from typing import Literal, Union, cast +from typing import Literal, Union import pytest from posthog.hogql import ast -from posthog.hogql.parser import parse_expr, parse_select from posthog.hogql_queries.insights.trends.aggregation_operations import ( AggregationOperations, - FirstTimeForUserEventsQueryAlternator, - QueryAlternator, ) from posthog.hogql_queries.utils.query_date_range import QueryDateRange from posthog.models.team.team import Team @@ -21,62 +18,6 @@ ) -class TestQueryAlternator: - def test_select(self): - query = cast(ast.SelectQuery, parse_select("SELECT event from events")) - - query_modifier = QueryAlternator(query) - query_modifier.append_select(ast.Field(chain=["test"])) - query_modifier.build() - - assert len(query.select) == 2 - assert cast(ast.Field, query.select[1]).chain == ["test"] - - query = cast(ast.SelectQuery, parse_select("SELECT event from events")) - - query_modifier = QueryAlternator(query) - query_modifier.extend_select([ast.Field(chain=["test1"]), ast.Field(chain=["test2"])]) - query_modifier.build() - - assert len(query.select) == 3 - assert cast(ast.Field, query.select[1]).chain == ["test1"] - assert cast(ast.Field, query.select[2]).chain == ["test2"] - - def test_group_no_pre_existing(self): - query = cast(ast.SelectQuery, parse_select("SELECT event from events")) - - query_modifier = QueryAlternator(query) - query_modifier.append_group_by(ast.Field(chain=["event"])) - query_modifier.build() - - assert query.group_by is not None - assert len(query.group_by) == 1 - assert cast(ast.Field, query.group_by[0]).chain == ["event"] - - def test_group_with_pre_existing(self): - query = cast(ast.SelectQuery, parse_select("SELECT event from events GROUP BY uuid")) - - query_modifier = QueryAlternator(query) - query_modifier.append_group_by(ast.Field(chain=["event"])) - query_modifier.build() - - assert query.group_by is not None - assert len(query.group_by) == 2 - assert cast(ast.Field, query.group_by[0]).chain == ["uuid"] - assert cast(ast.Field, query.group_by[1]).chain == ["event"] - - def test_replace_select_from(self): - query = cast(ast.SelectQuery, parse_select("SELECT event from events")) - - query_modifier = QueryAlternator(query) - query_modifier.replace_select_from(ast.JoinExpr(table=ast.Field(chain=["groups"]))) - query_modifier.build() - - assert isinstance(query.select_from, ast.JoinExpr) - assert isinstance(query.select_from.table, ast.Field) - assert query.select_from.table.chain == ["groups"] - - @pytest.mark.parametrize( "math,math_property", [ @@ -168,159 +109,3 @@ def test_requiring_query_orchestration( agg_ops = AggregationOperations(team, series, ChartDisplayType.ACTIONS_LINE_GRAPH, query_date_range, False) res = agg_ops.requires_query_orchestration() assert res == result - - -class TestFirstTimeForUserEventsQueryAlternator: - def test_query(self): - query = ast.SelectQuery(select=[]) - date_from, date_to = parse_expr("1 = 1"), parse_expr("2 = 2") - - builder = FirstTimeForUserEventsQueryAlternator(query, date_from, date_to) - builder.build() - - assert len(query.select) == 2 - - assert isinstance(query.select[0], ast.Alias) - assert query.select[0].alias == "min_timestamp" - assert isinstance(query.select[0].expr, ast.Call) - assert query.select[0].expr.name == "min" - assert query.select[0].expr.args == [ast.Field(chain=["timestamp"])] - - assert isinstance(query.select[1], ast.Alias) - assert query.select[1].alias == "min_timestamp_with_condition" - assert isinstance(query.select[1].expr, ast.Call) - assert query.select[1].expr.name == "minIf" - assert query.select[1].expr.args == [ast.Field(chain=["timestamp"]), date_from] - - assert isinstance(query.select_from, ast.JoinExpr) - assert query.select_from.alias == "e" - assert isinstance(query.select_from.table, ast.Field) - assert query.select_from.table.chain == ["events"] - assert query.select_from.sample is None - - assert query.where == date_to - - assert isinstance(query.group_by, list) - assert isinstance(query.group_by[0], ast.Field) - assert query.group_by[0].chain == ["person_id"] - - assert isinstance(query.having, ast.CompareOperation) - assert query.having.op == ast.CompareOperationOp.Eq - assert isinstance(query.having.left, ast.Field) - assert query.having.left.chain == ["min_timestamp"] - assert isinstance(query.having.right, ast.Field) - assert query.having.right.chain == ["min_timestamp_with_condition"] - - def test_query_with_filters(self): - query = ast.SelectQuery(select=[]) - date_from, date_to, filters = parse_expr("1 = 1"), parse_expr("2 = 2"), parse_expr("3 = 3") - - builder = FirstTimeForUserEventsQueryAlternator(query, date_from, date_to, filters=filters) - builder.build() - - assert len(query.select) == 2 - - assert isinstance(query.select[0], ast.Alias) - assert query.select[0].alias == "min_timestamp" - assert isinstance(query.select[0].expr, ast.Call) - assert query.select[0].expr.name == "min" - assert query.select[0].expr.args == [ast.Field(chain=["timestamp"])] - - assert isinstance(query.select[1], ast.Alias) - assert query.select[1].alias == "min_timestamp_with_condition" - assert isinstance(query.select[1].expr, ast.Call) - assert query.select[1].expr.name == "minIf" - assert query.select[1].expr.args == [ast.Field(chain=["timestamp"]), ast.And(exprs=[date_from, filters])] - - def test_query_with_event_or_action_filter(self): - query = ast.SelectQuery(select=[]) - date_from, date_to, event_filter = parse_expr("1 = 1"), parse_expr("2 = 2"), parse_expr("3 = 3") - - builder = FirstTimeForUserEventsQueryAlternator(query, date_from, date_to, event_or_action_filter=event_filter) - builder.build() - - assert isinstance(query.where, ast.And) - assert len(query.where.exprs) == 2 - assert query.where.exprs[0] == date_to - assert query.where.exprs[1] == event_filter - - def test_query_with_ratio_expr(self): - query = ast.SelectQuery(select=[]) - date_from, date_to, ratio_expr = ( - parse_expr("1 = 1"), - parse_expr("2 = 2"), - ast.RatioExpr(left=ast.Constant(value=1)), - ) - - builder = FirstTimeForUserEventsQueryAlternator(query, date_from, date_to, ratio=ratio_expr) - builder.build() - - assert isinstance(query.select_from, ast.JoinExpr) - assert query.select_from.alias == "e" - assert isinstance(query.select_from.table, ast.Field) - assert query.select_from.table.chain == ["events"] - assert isinstance(query.select_from.sample, ast.SampleExpr) - assert query.select_from.sample.sample_value == ratio_expr - - def test_append_select(self): - query = ast.SelectQuery(select=[]) - date_from, date_to = parse_expr("1 = 1"), parse_expr("2 = 2") - builder = FirstTimeForUserEventsQueryAlternator(query, date_from, date_to) - - builder.append_select(ast.Field(chain=["test"])) - builder.append_select(ast.Alias(alias="test2", expr=ast.Field(chain=["test2"]))) - builder.append_select(ast.Field(chain=["test3"]), aggregate=True) - builder.append_select(ast.Alias(alias="test4", expr=ast.Field(chain=["test4"])), aggregate=True) - builder.build() - - assert len(query.select) == 6 - - assert cast(ast.Field, query.select[2]).chain == ["test"] - assert isinstance(query.select[3], ast.Alias) - assert query.select[3].alias == "test2" - assert cast(ast.Field, query.select[3].expr).chain == ["test2"] - - assert isinstance(query.select[4], ast.Call) - assert query.select[4].name == "argMin" - assert query.select[4].args == [ast.Field(chain=["test3"]), ast.Field(chain=["timestamp"])] - assert isinstance(query.select[5], ast.Alias) - assert query.select[5].alias == "test4" - assert isinstance(query.select[5].expr, ast.Call) - assert query.select[5].expr.name == "argMin" - assert query.select[5].expr.args == [ast.Field(chain=["test4"]), ast.Field(chain=["timestamp"])] - - def test_extend_select(self): - query = ast.SelectQuery(select=[]) - date_from, date_to = parse_expr("1 = 1"), parse_expr("2 = 2") - builder = FirstTimeForUserEventsQueryAlternator(query, date_from, date_to) - - builder.extend_select( - [ - ast.Field(chain=["test"]), - ast.Alias(alias="test2", expr=ast.Field(chain=["test2"])), - ] - ) - builder.extend_select( - [ - ast.Field(chain=["test3"]), - ast.Alias(alias="test4", expr=ast.Field(chain=["test4"])), - ], - aggregate=True, - ) - builder.build() - - assert len(query.select) == 6 - - assert cast(ast.Field, query.select[2]).chain == ["test"] - assert isinstance(query.select[3], ast.Alias) - assert query.select[3].alias == "test2" - assert cast(ast.Field, query.select[3].expr).chain == ["test2"] - - assert isinstance(query.select[4], ast.Call) - assert query.select[4].name == "argMin" - assert query.select[4].args == [ast.Field(chain=["test3"]), ast.Field(chain=["timestamp"])] - assert isinstance(query.select[5], ast.Alias) - assert query.select[5].alias == "test4" - assert isinstance(query.select[5].expr, ast.Call) - assert query.select[5].expr.name == "argMin" - assert query.select[5].expr.args == [ast.Field(chain=["test4"]), ast.Field(chain=["timestamp"])] diff --git a/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py b/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py index 20b1cd0a92efa..af0a35160cf6c 100644 --- a/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py +++ b/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py @@ -4735,3 +4735,60 @@ def test_trends_math_first_time_for_user_actions(self): assert len(response.results) == 1 assert response.results[0]["count"] == 2 assert response.results[0]["data"] == [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] + + def test_multiple_breakdowns_work_with_formula(self): + self._create_test_events() + flush_persons_and_events() + + response = self._run_trends_query( + "2020-01-09", + "2020-01-20", + IntervalType.DAY, + [EventsNode(event="$pageview")], + TrendsFilter(display=ChartDisplayType.ACTIONS_LINE_GRAPH, formula="A*10"), + BreakdownFilter(breakdowns=[Breakdown(property="$browser", type=MultipleBreakdownType.EVENT)]), + ) + + breakdown_labels = [result["breakdown_value"] for result in response.results] + + assert len(response.results) == 4 + assert breakdown_labels == [["Chrome"], ["Firefox"], ["Edge"], ["Safari"]] + assert [result["data"] for result in response.results] == [ + [0, 0, 10, 10, 10, 0, 10, 0, 10, 0, 10, 0], + [10, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0], + ] + + def test_multiple_series_and_multiple_breakdowns_work_with_formula(self): + self._create_test_events() + flush_persons_and_events() + + response = self._run_trends_query( + "2020-01-09", + "2020-01-20", + IntervalType.DAY, + [EventsNode(event="$pageview"), EventsNode(event="$pageview")], + TrendsFilter(display=ChartDisplayType.ACTIONS_LINE_GRAPH, formula="A/B*100"), + BreakdownFilter( + breakdowns=[ + Breakdown(property="$browser", type=MultipleBreakdownType.EVENT), + Breakdown(property="prop", type=MultipleBreakdownType.EVENT, histogram_bin_count=2), + ] + ), + ) + + breakdown_labels = [result["breakdown_value"] for result in response.results] + assert len(response.results) == 4 + assert breakdown_labels == [ + ["Chrome", "[10,25]"], + ["Firefox", "[10,25]"], + ["Edge", "[25,40.01]"], + ["Safari", "[25,40.01]"], + ] + assert [result["data"] for result in response.results] == [ + [0, 0, 100, 100, 100, 0, 100, 0, 100, 0, 100, 0], + [100, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0], + ] diff --git a/posthog/hogql_queries/insights/trends/trends_query_runner.py b/posthog/hogql_queries/insights/trends/trends_query_runner.py index 201cd6fe4a140..d4223a975875f 100644 --- a/posthog/hogql_queries/insights/trends/trends_query_runner.py +++ b/posthog/hogql_queries/insights/trends/trends_query_runner.py @@ -1,26 +1,25 @@ -from natsort import natsorted, ns +import threading from copy import deepcopy from datetime import timedelta from math import ceil from operator import itemgetter -import threading -from typing import Optional, Any, Union -from django.conf import settings +from typing import Any, Optional, Union +from django.conf import settings from django.utils.timezone import datetime +from natsort import natsorted, ns + from posthog.caching.insights_api import ( BASE_MINIMUM_INSIGHT_REFRESH_INTERVAL, - REDUCED_MINIMUM_INSIGHT_REFRESH_INTERVAL, REAL_TIME_INSIGHT_REFRESH_INTERVAL, + REDUCED_MINIMUM_INSIGHT_REFRESH_INTERVAL, ) from posthog.clickhouse import query_tagging - from posthog.hogql import ast -from posthog.hogql.constants import LimitContext, MAX_SELECT_RETURNED_ROWS, BREAKDOWN_VALUES_LIMIT +from posthog.hogql.constants import BREAKDOWN_VALUES_LIMIT, MAX_SELECT_RETURNED_ROWS, LimitContext from posthog.hogql.printer import to_printed_hogql from posthog.hogql.query import execute_hogql_query from posthog.hogql.timings import HogQLTimings -from posthog.hogql_queries.insights.trends.display import TrendsDisplay from posthog.hogql_queries.insights.trends.breakdown import ( BREAKDOWN_NULL_DISPLAY, BREAKDOWN_NULL_STRING_LABEL, @@ -28,9 +27,10 @@ BREAKDOWN_OTHER_DISPLAY, BREAKDOWN_OTHER_STRING_LABEL, ) -from posthog.hogql_queries.insights.trends.trends_query_builder import TrendsQueryBuilder -from posthog.hogql_queries.insights.trends.trends_actors_query_builder import TrendsActorsQueryBuilder +from posthog.hogql_queries.insights.trends.display import TrendsDisplay from posthog.hogql_queries.insights.trends.series_with_extras import SeriesWithExtras +from posthog.hogql_queries.insights.trends.trends_actors_query_builder import TrendsActorsQueryBuilder +from posthog.hogql_queries.insights.trends.trends_query_builder import TrendsQueryBuilder from posthog.hogql_queries.query_runner import QueryRunner from posthog.hogql_queries.utils.formula_ast import FormulaAST from posthog.hogql_queries.utils.query_compare_to_date_range import QueryCompareToDateRange @@ -47,30 +47,30 @@ from posthog.schema import ( ActionsNode, BreakdownItem, + BreakdownType, CachedTrendsQueryResponse, ChartDisplayType, Compare, CompareItem, DashboardFilter, + DataWarehouseEventsModifier, + DataWarehouseNode, DayItem, EventsNode, - DataWarehouseNode, + HogQLQueryModifiers, HogQLQueryResponse, InCohortVia, InsightActorsQueryOptionsResponse, + IntervalType, MultipleBreakdownOptions, MultipleBreakdownType, QueryTiming, Series, TrendsQuery, TrendsQueryResponse, - HogQLQueryModifiers, - DataWarehouseEventsModifier, - BreakdownType, - IntervalType, ) -from posthog.warehouse.models import DataWarehouseTable from posthog.utils import format_label_date, multisort +from posthog.warehouse.models import DataWarehouseTable class TrendsQueryRunner(QueryRunner): @@ -782,13 +782,19 @@ def apply_formula( for result in results: if isinstance(result, list): for item in result: - all_breakdown_values.add(itemgetter(*keys)(item)) + data = itemgetter(*keys)(item) + all_breakdown_values.add(tuple(data) if isinstance(data, list) else data) # sort the results so that the breakdown values are in the correct order sorted_breakdown_values = natsorted(list(all_breakdown_values), alg=ns.IGNORECASE) computed_results = [] - for breakdown_value in sorted_breakdown_values: + for single_or_multiple_breakdown_value in sorted_breakdown_values: + breakdown_value = ( + list(single_or_multiple_breakdown_value) + if isinstance(single_or_multiple_breakdown_value, tuple) + else single_or_multiple_breakdown_value + ) any_result: Optional[dict[str, Any]] = None for result in results: matching_result = [item for item in result if itemgetter(*keys)(item) == breakdown_value] diff --git a/posthog/hogql_queries/insights/utils/aggregations.py b/posthog/hogql_queries/insights/utils/aggregations.py new file mode 100644 index 0000000000000..084ee58905c20 --- /dev/null +++ b/posthog/hogql_queries/insights/utils/aggregations.py @@ -0,0 +1,136 @@ +from typing import cast + +from posthog.hogql import ast + + +class QueryAlternator: + """Allows query_builder to modify the query without having to expose the whole AST interface""" + + _query: ast.SelectQuery + _selects: list[ast.Expr] + _group_bys: list[ast.Expr] + _select_from: ast.JoinExpr | None + + def __init__(self, query: ast.SelectQuery | ast.SelectUnionQuery): + assert isinstance(query, ast.SelectQuery) + + self._query = query + self._selects = [] + self._group_bys = [] + self._select_from = None + + def build(self) -> ast.SelectQuery | ast.SelectUnionQuery: + if len(self._selects) > 0: + self._query.select.extend(self._selects) + + if len(self._group_bys) > 0: + if self._query.group_by is None: + self._query.group_by = self._group_bys + else: + self._query.group_by.extend(self._group_bys) + + if self._select_from is not None: + self._query.select_from = self._select_from + + return self._query + + def append_select(self, expr: ast.Expr) -> None: + self._selects.append(expr) + + def extend_select(self, exprs: list[ast.Expr]) -> None: + self._selects.extend(exprs) + + def append_group_by(self, expr: ast.Expr) -> None: + self._group_bys.append(expr) + + def extend_group_by(self, exprs: list[ast.Expr]) -> None: + self._group_bys.extend(exprs) + + def replace_select_from(self, join_expr: ast.JoinExpr) -> None: + self._select_from = join_expr + + +class FirstTimeForUserEventsQueryAlternator(QueryAlternator): + """ + A specialized QueryAlternator for building queries that identify the first time an event or action occurs for each user. + + This class extends the base QueryAlternator to build a query that: + - Finds the minimum timestamp for `person_id` filtered by the event/action and right date range. + - Compares it with the minimum timestamp that satisfies general conditions like event/person properties and the left date range. + - Selects only those events where these two timestamps match. + """ + + def __init__( + self, + query: ast.SelectQuery, + date_from: ast.Expr, + date_to: ast.Expr, + filters: ast.Expr | None = None, + event_or_action_filter: ast.Expr | None = None, + ratio: ast.RatioExpr | None = None, + ): + query.select = self._select_expr(date_from, filters) + query.select_from = self._select_from_expr(ratio) + query.where = self._where_expr(date_to, event_or_action_filter) + query.group_by = self._group_by_expr() + query.having = self._having_expr() + super().__init__(query) + + def _select_expr(self, date_from: ast.Expr, filters: ast.Expr | None = None): + aggregation_filters = date_from if filters is None else ast.And(exprs=[date_from, filters]) + return [ + ast.Alias( + alias="min_timestamp", + expr=ast.Call(name="min", args=[ast.Field(chain=["timestamp"])]), + ), + ast.Alias( + alias="min_timestamp_with_condition", + expr=ast.Call( + name="minIf", + args=[ast.Field(chain=["timestamp"]), aggregation_filters], + ), + ), + ] + + def _select_from_expr(self, ratio: ast.RatioExpr | None = None) -> ast.JoinExpr: + sample_value = ast.SampleExpr(sample_value=ratio) if ratio is not None else None + return ast.JoinExpr(table=ast.Field(chain=["events"]), alias="e", sample=sample_value) + + def _where_expr(self, date_to: ast.Expr, event_or_action_filter: ast.Expr | None = None) -> ast.Expr: + where_filters = [date_to] + if event_or_action_filter is not None: + where_filters.append(event_or_action_filter) + + if len(where_filters) > 1: + where_filters_expr = cast(ast.Expr, ast.And(exprs=where_filters)) + else: + where_filters_expr = where_filters[0] + return where_filters_expr + + def _group_by_expr(self) -> list[ast.Expr]: + return [ast.Field(chain=["person_id"])] + + def _having_expr(self) -> ast.Expr: + return ast.CompareOperation( + op=ast.CompareOperationOp.Eq, + left=ast.Field(chain=["min_timestamp"]), + right=ast.Field(chain=["min_timestamp_with_condition"]), + ) + + def _transform_column(self, column: ast.Expr): + return ast.Call( + name="argMin", + args=[column, ast.Field(chain=["timestamp"])], + ) + + def append_select(self, expr: ast.Expr, aggregate: bool = False): + if aggregate: + if isinstance(expr, ast.Alias): + expr = ast.Alias(expr=self._transform_column(expr.expr), alias=expr.alias) + else: + expr = self._transform_column(expr) + super().append_select(expr) + + def extend_select(self, exprs: list[ast.Expr], aggregate: bool = False) -> None: + for expr in exprs: + self.append_select(expr, aggregate) diff --git a/posthog/hogql_queries/insights/utils/test/test_aggregations.py b/posthog/hogql_queries/insights/utils/test/test_aggregations.py new file mode 100644 index 0000000000000..4f84afabc0dcc --- /dev/null +++ b/posthog/hogql_queries/insights/utils/test/test_aggregations.py @@ -0,0 +1,220 @@ +from typing import cast + +from posthog.hogql import ast +from posthog.hogql.parser import parse_expr, parse_select +from posthog.hogql_queries.insights.utils.aggregations import ( + FirstTimeForUserEventsQueryAlternator, + QueryAlternator, +) + + +class TestQueryAlternator: + def test_select(self): + query = cast(ast.SelectQuery, parse_select("SELECT event from events")) + + query_modifier = QueryAlternator(query) + query_modifier.append_select(ast.Field(chain=["test"])) + query_modifier.build() + + assert len(query.select) == 2 + assert cast(ast.Field, query.select[1]).chain == ["test"] + + query = cast(ast.SelectQuery, parse_select("SELECT event from events")) + + query_modifier = QueryAlternator(query) + query_modifier.extend_select([ast.Field(chain=["test1"]), ast.Field(chain=["test2"])]) + query_modifier.build() + + assert len(query.select) == 3 + assert cast(ast.Field, query.select[1]).chain == ["test1"] + assert cast(ast.Field, query.select[2]).chain == ["test2"] + + def test_group_no_pre_existing(self): + query = cast(ast.SelectQuery, parse_select("SELECT event from events")) + + query_modifier = QueryAlternator(query) + query_modifier.append_group_by(ast.Field(chain=["event"])) + query_modifier.build() + + assert query.group_by is not None + assert len(query.group_by) == 1 + assert cast(ast.Field, query.group_by[0]).chain == ["event"] + + def test_group_with_pre_existing(self): + query = cast(ast.SelectQuery, parse_select("SELECT event from events GROUP BY uuid")) + + query_modifier = QueryAlternator(query) + query_modifier.append_group_by(ast.Field(chain=["event"])) + query_modifier.build() + + assert query.group_by is not None + assert len(query.group_by) == 2 + assert cast(ast.Field, query.group_by[0]).chain == ["uuid"] + assert cast(ast.Field, query.group_by[1]).chain == ["event"] + + def test_replace_select_from(self): + query = cast(ast.SelectQuery, parse_select("SELECT event from events")) + + query_modifier = QueryAlternator(query) + query_modifier.replace_select_from(ast.JoinExpr(table=ast.Field(chain=["groups"]))) + query_modifier.build() + + assert isinstance(query.select_from, ast.JoinExpr) + assert isinstance(query.select_from.table, ast.Field) + assert query.select_from.table.chain == ["groups"] + + +class TestFirstTimeForUserEventsQueryAlternator: + def test_query(self): + query = ast.SelectQuery(select=[]) + date_from, date_to = parse_expr("1 = 1"), parse_expr("2 = 2") + + builder = FirstTimeForUserEventsQueryAlternator(query, date_from, date_to) + builder.build() + + assert len(query.select) == 2 + + assert isinstance(query.select[0], ast.Alias) + assert query.select[0].alias == "min_timestamp" + assert isinstance(query.select[0].expr, ast.Call) + assert query.select[0].expr.name == "min" + assert query.select[0].expr.args == [ast.Field(chain=["timestamp"])] + + assert isinstance(query.select[1], ast.Alias) + assert query.select[1].alias == "min_timestamp_with_condition" + assert isinstance(query.select[1].expr, ast.Call) + assert query.select[1].expr.name == "minIf" + assert query.select[1].expr.args == [ast.Field(chain=["timestamp"]), date_from] + + assert isinstance(query.select_from, ast.JoinExpr) + assert query.select_from.alias == "e" + assert isinstance(query.select_from.table, ast.Field) + assert query.select_from.table.chain == ["events"] + assert query.select_from.sample is None + + assert query.where == date_to + + assert isinstance(query.group_by, list) + assert isinstance(query.group_by[0], ast.Field) + assert query.group_by[0].chain == ["person_id"] + + assert isinstance(query.having, ast.CompareOperation) + assert query.having.op == ast.CompareOperationOp.Eq + assert isinstance(query.having.left, ast.Field) + assert query.having.left.chain == ["min_timestamp"] + assert isinstance(query.having.right, ast.Field) + assert query.having.right.chain == ["min_timestamp_with_condition"] + + def test_query_with_filters(self): + query = ast.SelectQuery(select=[]) + date_from, date_to, filters = parse_expr("1 = 1"), parse_expr("2 = 2"), parse_expr("3 = 3") + + builder = FirstTimeForUserEventsQueryAlternator(query, date_from, date_to, filters=filters) + builder.build() + + assert len(query.select) == 2 + + assert isinstance(query.select[0], ast.Alias) + assert query.select[0].alias == "min_timestamp" + assert isinstance(query.select[0].expr, ast.Call) + assert query.select[0].expr.name == "min" + assert query.select[0].expr.args == [ast.Field(chain=["timestamp"])] + + assert isinstance(query.select[1], ast.Alias) + assert query.select[1].alias == "min_timestamp_with_condition" + assert isinstance(query.select[1].expr, ast.Call) + assert query.select[1].expr.name == "minIf" + assert query.select[1].expr.args == [ast.Field(chain=["timestamp"]), ast.And(exprs=[date_from, filters])] + + def test_query_with_event_or_action_filter(self): + query = ast.SelectQuery(select=[]) + date_from, date_to, event_filter = parse_expr("1 = 1"), parse_expr("2 = 2"), parse_expr("3 = 3") + + builder = FirstTimeForUserEventsQueryAlternator(query, date_from, date_to, event_or_action_filter=event_filter) + builder.build() + + assert isinstance(query.where, ast.And) + assert len(query.where.exprs) == 2 + assert query.where.exprs[0] == date_to + assert query.where.exprs[1] == event_filter + + def test_query_with_ratio_expr(self): + query = ast.SelectQuery(select=[]) + date_from, date_to, ratio_expr = ( + parse_expr("1 = 1"), + parse_expr("2 = 2"), + ast.RatioExpr(left=ast.Constant(value=1)), + ) + + builder = FirstTimeForUserEventsQueryAlternator(query, date_from, date_to, ratio=ratio_expr) + builder.build() + + assert isinstance(query.select_from, ast.JoinExpr) + assert query.select_from.alias == "e" + assert isinstance(query.select_from.table, ast.Field) + assert query.select_from.table.chain == ["events"] + assert isinstance(query.select_from.sample, ast.SampleExpr) + assert query.select_from.sample.sample_value == ratio_expr + + def test_append_select(self): + query = ast.SelectQuery(select=[]) + date_from, date_to = parse_expr("1 = 1"), parse_expr("2 = 2") + builder = FirstTimeForUserEventsQueryAlternator(query, date_from, date_to) + + builder.append_select(ast.Field(chain=["test"])) + builder.append_select(ast.Alias(alias="test2", expr=ast.Field(chain=["test2"]))) + builder.append_select(ast.Field(chain=["test3"]), aggregate=True) + builder.append_select(ast.Alias(alias="test4", expr=ast.Field(chain=["test4"])), aggregate=True) + builder.build() + + assert len(query.select) == 6 + + assert cast(ast.Field, query.select[2]).chain == ["test"] + assert isinstance(query.select[3], ast.Alias) + assert query.select[3].alias == "test2" + assert cast(ast.Field, query.select[3].expr).chain == ["test2"] + + assert isinstance(query.select[4], ast.Call) + assert query.select[4].name == "argMin" + assert query.select[4].args == [ast.Field(chain=["test3"]), ast.Field(chain=["timestamp"])] + assert isinstance(query.select[5], ast.Alias) + assert query.select[5].alias == "test4" + assert isinstance(query.select[5].expr, ast.Call) + assert query.select[5].expr.name == "argMin" + assert query.select[5].expr.args == [ast.Field(chain=["test4"]), ast.Field(chain=["timestamp"])] + + def test_extend_select(self): + query = ast.SelectQuery(select=[]) + date_from, date_to = parse_expr("1 = 1"), parse_expr("2 = 2") + builder = FirstTimeForUserEventsQueryAlternator(query, date_from, date_to) + + builder.extend_select( + [ + ast.Field(chain=["test"]), + ast.Alias(alias="test2", expr=ast.Field(chain=["test2"])), + ] + ) + builder.extend_select( + [ + ast.Field(chain=["test3"]), + ast.Alias(alias="test4", expr=ast.Field(chain=["test4"])), + ], + aggregate=True, + ) + builder.build() + + assert len(query.select) == 6 + + assert cast(ast.Field, query.select[2]).chain == ["test"] + assert isinstance(query.select[3], ast.Alias) + assert query.select[3].alias == "test2" + assert cast(ast.Field, query.select[3].expr).chain == ["test2"] + + assert isinstance(query.select[4], ast.Call) + assert query.select[4].name == "argMin" + assert query.select[4].args == [ast.Field(chain=["test3"]), ast.Field(chain=["timestamp"])] + assert isinstance(query.select[5], ast.Alias) + assert query.select[5].alias == "test4" + assert isinstance(query.select[5].expr, ast.Call) + assert query.select[5].expr.name == "argMin" + assert query.select[5].expr.args == [ast.Field(chain=["test4"]), ast.Field(chain=["timestamp"])] diff --git a/posthog/hogql_queries/legacy_compatibility/filter_to_query.py b/posthog/hogql_queries/legacy_compatibility/filter_to_query.py index 6bff858aaf130..812af183a36f4 100644 --- a/posthog/hogql_queries/legacy_compatibility/filter_to_query.py +++ b/posthog/hogql_queries/legacy_compatibility/filter_to_query.py @@ -1,7 +1,7 @@ import copy -from enum import StrEnum import json import re +from enum import StrEnum from typing import Any, Literal from posthog.hogql_queries.legacy_compatibility.clean_properties import clean_entity_properties, clean_global_properties @@ -11,6 +11,7 @@ BaseMathType, BreakdownFilter, ChartDisplayType, + CompareFilter, DataWarehouseNode, EventsNode, FunnelExclusionActionsNode, @@ -18,6 +19,7 @@ FunnelPathsFilter, FunnelsFilter, FunnelsQuery, + FunnelVizType, InsightDateRange, LifecycleFilter, LifecycleQuery, @@ -29,8 +31,6 @@ StickinessQuery, TrendsFilter, TrendsQuery, - FunnelVizType, - CompareFilter, ) from posthog.types import InsightQueryNode from posthog.utils import str_to_bool @@ -40,6 +40,7 @@ class MathAvailability(StrEnum): Unavailable = ("Unavailable",) All = ("All",) ActorsOnly = "ActorsOnly" + FunnelsOnly = "FunnelsOnly" actors_only_math_types = [ @@ -50,6 +51,10 @@ class MathAvailability(StrEnum): "hogql", ] +funnels_math_types = [ + BaseMathType.FIRST_TIME_FOR_USER, +] + def clean_display(display: str): if display not in [c.value for c in ChartDisplayType]: @@ -122,7 +127,8 @@ def legacy_entity_to_node( } if math_availability != MathAvailability.Unavailable: - # only trends and stickiness insights support math. + # only trends, funnels, and stickiness insights support math. + # funnels only support a single base math type: first time for user. # transition to then default math for stickiness, when an unsupported math type is encountered. if ( @@ -131,6 +137,10 @@ def legacy_entity_to_node( and entity.math not in actors_only_math_types ): shared = {**shared, "math": BaseMathType.DAU} + elif math_availability == MathAvailability.FunnelsOnly: + # All other math types must be skipped for funnels + if entity.math in funnels_math_types: + shared = {**shared, "math": entity.math} else: shared = { **shared, @@ -235,6 +245,8 @@ def _series(filter: dict): if _insight_type(filter) == "TRENDS": math_availability = MathAvailability.All + if _insight_type(filter) == "FUNNELS": + math_availability = MathAvailability.FunnelsOnly elif _insight_type(filter) == "STICKINESS": math_availability = MathAvailability.ActorsOnly diff --git a/posthog/hogql_queries/legacy_compatibility/test/test_filter_to_query.py b/posthog/hogql_queries/legacy_compatibility/test/test_filter_to_query.py index 310851e70ea9d..084a7791c43f7 100644 --- a/posthog/hogql_queries/legacy_compatibility/test/test_filter_to_query.py +++ b/posthog/hogql_queries/legacy_compatibility/test/test_filter_to_query.py @@ -1,8 +1,9 @@ import pytest + from posthog.hogql_queries.legacy_compatibility.filter_to_query import ( + filter_to_query, hidden_legend_keys_to_breakdowns, hidden_legend_keys_to_indexes, - filter_to_query, ) from posthog.schema import ( ActionsNode, @@ -14,6 +15,7 @@ BreakdownType, ChartDisplayType, CohortPropertyFilter, + CompareFilter, CountPerActorMathType, DataWarehouseNode, ElementPropertyFilter, @@ -22,41 +24,39 @@ FunnelConversionWindowTimeUnit, FunnelExclusionActionsNode, FunnelExclusionEventsNode, - FunnelPathType, FunnelPathsFilter, - FunnelVizType, + FunnelPathType, + FunnelsFilter, FunnelsQuery, + FunnelVizType, GroupPropertyFilter, HogQLPropertyFilter, InsightDateRange, Key, + LifecycleFilter, LifecycleQuery, LifecycleToggle, MathGroupTypeIndex, PathCleaningFilter, - PathType, + PathsFilter, PathsQuery, + PathType, PersonPropertyFilter, PropertyMathType, PropertyOperator, + RetentionFilter, RetentionPeriod, RetentionQuery, RetentionType, SessionPropertyFilter, StepOrderValue, + StickinessFilter, StickinessQuery, TrendsFilter, - FunnelsFilter, - RetentionFilter, - PathsFilter, - StickinessFilter, - LifecycleFilter, TrendsQuery, - CompareFilter, ) from posthog.test.base import BaseTest - insight_0 = { "events": [{"id": "signed_up", "type": "events", "order": 0}], "actions": [], @@ -1705,6 +1705,56 @@ def test_funnels_multiple_breakdowns_no_breakdown_type(self): ), ) + def test_funnels_use_first_time_for_user_math(self): + filter = { + "insight": "FUNNELS", + "events": [ + { + "id": "signed_up", + "name": "signed_up", + "type": "events", + "order": 0, + "math": BaseMathType.FIRST_TIME_FOR_USER, + }, + { + "id": "upgraded_plan", + "name": "upgraded_plan", + "type": "events", + "order": 1, + "math": BaseMathType.DAU, + }, + ], + "actions": [ + { + "id": 1, + "name": "Interacted with file", + "type": "actions", + "order": 2, + "math": BaseMathType.FIRST_TIME_FOR_USER, + }, + { + "id": 1, + "name": "Interacted with file", + "type": "actions", + "order": 3, + "math": BaseMathType.DAU, + }, + ], + } + + query = filter_to_query(filter) + + assert isinstance(query, FunnelsQuery) + self.assertEqual( + query.series, + [ + EventsNode(event="signed_up", name="signed_up", math=BaseMathType.FIRST_TIME_FOR_USER), + EventsNode(event="upgraded_plan", name="upgraded_plan"), + ActionsNode(id=1, name="Interacted with file", math=BaseMathType.FIRST_TIME_FOR_USER), + ActionsNode(id=1, name="Interacted with file"), + ], + ) + class TestHiddenLegendKeysToIndexes(BaseTest): def test_converts_legend_keys(self): diff --git a/posthog/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.ambr b/posthog/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.ambr index 5063b17d2a1c5..25ad854463e1e 100644 --- a/posthog/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.ambr +++ b/posthog/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.ambr @@ -35,9 +35,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -75,9 +74,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -116,9 +114,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -138,9 +135,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -180,9 +176,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -221,9 +216,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/hogql_queries/test/__snapshots__/test_sessions_timeline_query_runner.ambr b/posthog/hogql_queries/test/__snapshots__/test_sessions_timeline_query_runner.ambr index 6a28ce7a3239e..6c80fa6a98319 100644 --- a/posthog/hogql_queries/test/__snapshots__/test_sessions_timeline_query_runner.ambr +++ b/posthog/hogql_queries/test/__snapshots__/test_sessions_timeline_query_runner.ambr @@ -62,9 +62,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -131,9 +130,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -200,9 +198,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -269,9 +266,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -338,9 +334,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -407,9 +402,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -476,9 +470,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr b/posthog/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr index 80de66af059de..efdf25db926cb 100644 --- a/posthog/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr +++ b/posthog/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr @@ -31,9 +31,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -69,9 +68,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -107,9 +105,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -145,9 +142,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -191,9 +187,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -229,9 +224,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -267,9 +261,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -305,9 +298,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -343,9 +335,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -381,9 +372,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -419,9 +409,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -452,9 +441,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -485,9 +473,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -518,9 +505,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -551,9 +537,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -584,9 +569,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -617,9 +601,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -650,9 +633,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -683,9 +665,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -716,9 +697,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -749,9 +729,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -782,9 +761,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -815,9 +793,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -848,9 +825,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -881,9 +857,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -914,9 +889,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -947,9 +921,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -980,9 +953,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1013,9 +985,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1046,9 +1017,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1084,9 +1054,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1122,9 +1091,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1160,9 +1128,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1193,9 +1160,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1231,9 +1197,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1269,9 +1234,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1312,9 +1276,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1350,9 +1313,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1420,9 +1382,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1490,9 +1451,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1528,9 +1488,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1598,9 +1557,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1668,9 +1626,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1721,9 +1678,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1774,9 +1730,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1812,9 +1767,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1850,9 +1804,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1888,9 +1841,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1926,9 +1878,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -1964,9 +1915,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2002,9 +1952,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2040,9 +1989,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2078,9 +2026,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2116,9 +2063,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2154,9 +2100,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2192,9 +2137,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2230,9 +2174,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2268,9 +2211,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2306,9 +2248,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2376,9 +2317,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2414,9 +2354,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2484,9 +2423,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2522,9 +2460,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2560,9 +2497,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2599,9 +2535,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2638,9 +2573,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2677,9 +2611,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2716,9 +2649,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2749,9 +2681,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2782,9 +2713,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2821,9 +2751,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2860,9 +2789,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2899,9 +2827,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2938,9 +2865,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -2977,9 +2903,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3016,9 +2941,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3055,9 +2979,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3094,9 +3017,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3132,9 +3054,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3170,9 +3091,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3233,9 +3153,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3301,9 +3220,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3349,9 +3267,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3399,9 +3316,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3449,9 +3365,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3487,9 +3402,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3525,9 +3439,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3563,9 +3476,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3601,9 +3513,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3640,9 +3551,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3679,9 +3589,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3725,9 +3634,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3771,9 +3679,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3809,9 +3716,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3847,9 +3753,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3897,9 +3802,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3947,9 +3851,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -3988,9 +3891,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4026,9 +3928,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4064,9 +3965,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4102,9 +4002,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4140,9 +4039,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4178,9 +4076,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4216,9 +4113,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4254,9 +4150,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4292,9 +4187,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4330,9 +4224,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4368,9 +4261,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4406,9 +4298,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4444,9 +4335,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4482,9 +4372,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4532,9 +4421,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4570,9 +4458,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4620,9 +4507,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4658,9 +4544,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4708,9 +4593,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4746,9 +4630,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- @@ -4796,9 +4679,8 @@ max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, - max_ast_elements=2000000, - max_expanded_ast_elements=2000000, - max_query_size=1048576, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0 ''' # --- diff --git a/posthog/tasks/tasks.py b/posthog/tasks/tasks.py index e192aa2932bec..5c4b085072287 100644 --- a/posthog/tasks/tasks.py +++ b/posthog/tasks/tasks.py @@ -45,7 +45,7 @@ def redis_heartbeat() -> None: ), retry_backoff=1, retry_backoff_max=10, - max_retries=3, + max_retries=10, expires=60 * 10, # Do not run queries that got stuck for more than this reject_on_worker_lost=True, )