|
661 | 661 | join_algorithm = 'auto' |
662 | 662 | ''' |
663 | 663 | # --- |
| 664 | +# name: TestCohortQuery.test_cohort_filter_with_extra.16 |
| 665 | + ''' |
| 666 | + ( |
| 667 | + (SELECT persons.id AS id |
| 668 | + FROM |
| 669 | + (SELECT argMax(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'name'), ''), 'null'), '^"|"$', ''), person.version) AS properties___name, |
| 670 | + person.id AS id |
| 671 | + FROM person |
| 672 | + WHERE and(equals(person.team_id, 99999), in(id, |
| 673 | + (SELECT where_optimization.id AS id |
| 674 | + FROM person AS where_optimization |
| 675 | + WHERE and(equals(where_optimization.team_id, 99999), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(where_optimization.properties, 'name'), ''), 'null'), '^"|"$', ''), 'test'), 0))))) |
| 676 | + GROUP BY person.id |
| 677 | + 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))) AS persons |
| 678 | + WHERE ifNull(equals(persons.properties___name, 'test'), 0) |
| 679 | + ORDER BY persons.id ASC |
| 680 | + LIMIT 1000000000 SETTINGS optimize_aggregation_in_order=1, |
| 681 | + join_algorithm='auto')) |
| 682 | + UNION DISTINCT ( |
| 683 | + (SELECT source.id AS id |
| 684 | + FROM |
| 685 | + (SELECT actor_id AS actor_id, |
| 686 | + count() AS event_count, |
| 687 | + groupUniqArray(distinct_id) AS event_distinct_ids, |
| 688 | + actor_id AS id |
| 689 | + FROM |
| 690 | + (SELECT if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id) AS actor_id, |
| 691 | + toTimeZone(e.timestamp, 'UTC') AS timestamp, |
| 692 | + e.uuid AS uuid, |
| 693 | + e.distinct_id AS distinct_id |
| 694 | + FROM events AS e |
| 695 | + LEFT OUTER JOIN |
| 696 | + (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, |
| 697 | + person_distinct_id_overrides.distinct_id AS distinct_id |
| 698 | + FROM person_distinct_id_overrides |
| 699 | + WHERE equals(person_distinct_id_overrides.team_id, 99999) |
| 700 | + GROUP BY person_distinct_id_overrides.distinct_id |
| 701 | + HAVING ifNull(equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS e__override ON equals(e.distinct_id, e__override.distinct_id) |
| 702 | + WHERE and(equals(e.team_id, 99999), greaterOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), lessOrEquals(timestamp, toDateTime64('today', 6, 'UTC')), equals(e.event, '$pageview'))) |
| 703 | + GROUP BY actor_id) AS source |
| 704 | + ORDER BY source.id ASC |
| 705 | + LIMIT 1000000000 SETTINGS optimize_aggregation_in_order=1, |
| 706 | + join_algorithm='auto')) SETTINGS readonly=2, |
| 707 | + max_execution_time=600, |
| 708 | + allow_experimental_object_type=1, |
| 709 | + format_csv_allow_double_quotes=0, |
| 710 | + max_ast_elements=4000000, |
| 711 | + max_expanded_ast_elements=4000000, |
| 712 | + max_bytes_before_external_group_by=0, |
| 713 | + transform_null_in=1, |
| 714 | + optimize_min_equality_disjunction_chain_length=4294967295, |
| 715 | + allow_experimental_join_condition=1 |
| 716 | + ''' |
| 717 | +# --- |
| 718 | +# name: TestCohortQuery.test_cohort_filter_with_extra.17 |
| 719 | + ''' |
| 720 | + |
| 721 | + SELECT if(behavior_query.person_id = '00000000-0000-0000-0000-000000000000', person.person_id, behavior_query.person_id) AS id |
| 722 | + FROM |
| 723 | + (SELECT if(not(empty(pdi.distinct_id)), pdi.person_id, e.person_id) AS person_id, |
| 724 | + countIf(timestamp > now() - INTERVAL 1 week |
| 725 | + AND timestamp < now() |
| 726 | + AND event = '$pageview' |
| 727 | + AND 1=1) > 0 AS performed_event_condition_None_level_level_0_level_1_level_0_0 |
| 728 | + FROM events e |
| 729 | + LEFT OUTER JOIN |
| 730 | + (SELECT distinct_id, |
| 731 | + argMax(person_id, version) as person_id |
| 732 | + FROM person_distinct_id2 |
| 733 | + WHERE team_id = 99999 |
| 734 | + GROUP BY distinct_id |
| 735 | + HAVING argMax(is_deleted, version) = 0) AS pdi ON e.distinct_id = pdi.distinct_id |
| 736 | + WHERE team_id = 99999 |
| 737 | + AND event IN ['$pageview'] |
| 738 | + AND timestamp <= now() |
| 739 | + AND timestamp >= now() - INTERVAL 1 week |
| 740 | + GROUP BY person_id) behavior_query |
| 741 | + FULL OUTER JOIN |
| 742 | + (SELECT *, |
| 743 | + id AS person_id |
| 744 | + FROM |
| 745 | + (SELECT id, |
| 746 | + argMax(properties, version) as person_props |
| 747 | + FROM person |
| 748 | + WHERE team_id = 99999 |
| 749 | + GROUP BY id |
| 750 | + HAVING max(is_deleted) = 0 SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = behavior_query.person_id |
| 751 | + WHERE 1 = 1 |
| 752 | + AND ((((has(['test'], replaceRegexpAll(JSONExtractRaw(person_props, 'name'), '^"|"$', '')))) |
| 753 | + OR ((coalesce(performed_event_condition_None_level_level_0_level_1_level_0_0, false))))) SETTINGS optimize_aggregation_in_order = 1, |
| 754 | + join_algorithm = 'auto' |
| 755 | + ''' |
| 756 | +# --- |
664 | 757 | # name: TestCohortQuery.test_cohort_filter_with_extra.2 |
665 | 758 | ''' |
666 | 759 |
|
|
0 commit comments