PostHog / posthog

🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
https://posthog.com
Other
19.45k stars 1.14k forks source link

Bug Report: Funnel queries fail after enabling the experimental analyzer #23452

Closed sentry-io[bot] closed 4 days ago

sentry-io[bot] commented 4 days ago

Bug Description

Sentry Issue: POSTHOG-1DNM

ServerException: DB::Exception: Cannot find column `if(and(equals(event_4, 'onramps-web ready'_String), ifNull(equals(transform(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(properties_5, 'has_onramped_before'_String), ''_String), 'null'_String), '^"|"$'_String, ''_String), ['true', 'false']_Array(String), [1, 0]_Array(Bool), NULL_Nullable(Nothing)), 0_Bool), 0_UInt8)), 1_UInt8, 0_UInt8)` in source stream, there are only columns: [array(ifNull(toString(nullIf(nullIf(mat_ramp_6, ''_String), 'null'_String)), ''_String)), toTimezone(timestamp_0, 'UTC'_String), notEmpty(arrayFilter(__lambda_12508571411162645967_17909235918787688987, array(ifNull(toString(nullIf(nullIf(mat_ramp_6, ''_String), 'null'_String)), ''_String)))), if(not(empty(distinct_id_1)), person_id_2, person_id_3), if(and(equals(event_4, 'onramps-web ready'_String), ifNull(equals(transform(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(properties_5, 'has_onramped_before'_String), ''_String), 'null'_String), '^"|"$'_String, ''_String), ['true', 'false']_Array(String), [1, 0]_Array(Bool), NULL_Nullable(Nothing)), 0_UInt8), 0_UInt8)), 1_UInt8, 0_UInt8), ifNull(equals(if(and(equals(event_4, 'onramps-web ready'_String), ifNull(equals(transform(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(properties_5, 'has_onramped_before'_String), ''_String), 'null'_String), '^"|"$'_String, ''_String), ['true', 'false']_Array(String), [1, 0]_Array(Bool), NULL_Nullable(Nothing)), 0_UInt8), 0_UInt8)), 1_UInt8, 0_UInt8), 1_UInt8), 0_UInt8), ifNull(equals(if(equals(event_4, 'onramps-web continued to ramp'_String), 1_UInt8, 0_UInt8), 1_UInt8), 0_UInt8), ifNull(equals(if(equals(event_4, 'onramping completed'_String), 1_UInt8, 0_UInt8), 1_UInt8), 0_UInt8)]. Stack trace:

0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000c6cf19b in /usr/bin/clickhouse
1. DB::Exception::Exception<String const&, String>(int, FormatStringHelperImpl<std::type_identity<String const&>::type, std::type_identity<String>::type>, String const&, String&&) @ 0x0000000007b694a7 in /usr/bin/clickhouse
2. DB::ActionsDAG::makeConvertingActions(std::vector<DB::ColumnWithTypeAndName, std::allocator<DB::ColumnWithTypeAndName>> const&, std::vector<DB::ColumnWithTypeAndName, std::allocator<DB::ColumnWithTypeAndName>> const&, DB::ActionsDAG::MatchColumnsMode, bool, bool, std::unordered_map<String, String, std::hash<String>, std::equal_to<String>, std::allocator<std::pair<String const, String>>>*) @ 0x000000001088a3c9 in /usr/bin/clickhouse
3. DB::createLocalPlan(std::shared_ptr<DB::IAST> const&, DB::Block const&, std::shared_ptr<DB::Context const>, DB::QueryProcessingStage::Enum, unsigned long, unsigned long) @ 0x0000000012ad3b0b in /usr/bin/clickhouse
4. DB::ClusterProxy::SelectStreamFactory::createForShard(DB::Cluster::ShardInfo const&, std::shared_ptr<DB::IAST> const&, DB::StorageID const&, std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context const>, std::vector<std::unique_ptr<DB::QueryPlan, std::default_delete<DB::QueryPlan>>, std::allocator<std::unique_ptr<DB::QueryPlan, std::default_delete<DB::QueryPlan>>>>&, std::vector<DB::ClusterProxy::SelectStreamFactory::Shard, std::allocator<DB::ClusterProxy::SelectStreamFactory::Shard>>&, unsigned int, bool)::$_0::operator()() const @ 0x0000000011affdac in /usr/bin/clickhouse
5. DB::ClusterProxy::SelectStreamFactory::createForShard(DB::Cluster::ShardInfo const&, std::shared_ptr<DB::IAST> const&, DB::StorageID const&, std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context const>, std::vector<std::unique_ptr<DB::QueryPlan, std::default_delete<DB::QueryPlan>>, std::allocator<std::unique_ptr<DB::QueryPlan, std::default_delete<DB::QueryPlan>>>>&, std::vector<DB::ClusterProxy::SelectStreamFactory::Shard, std::allocator<DB::ClusterProxy::SelectStreamFactory::Shard>>&, unsigned int, bool) @ 0x0000000011afeef9 in /usr/bin/clickhouse
6. DB::ClusterProxy::executeQuery(DB::QueryPlan&, DB::Block const&, DB::QueryProcessingStage::Enum, DB::StorageID const&, std::shared_ptr<DB::IAST> const&, DB::ClusterProxy::SelectStreamFactory&, Poco::Logger*, std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context const>, DB::SelectQueryInfo const&, std::shared_ptr<DB::ExpressionActions> const&, String const&, std::shared_ptr<DB::Cluster> const&, DB::DistributedSettings const&, std::function<std::shared_ptr<DB::IAST> (unsigned long)>) @ 0x0000000011b03ecd in /usr/bin/clickhouse
7. DB::StorageDistributed::read(DB::QueryPlan&, std::vector<String, std::allocator<String>> const&, std::shared_ptr<DB::StorageSnapshot> const&, DB::SelectQueryInfo&, std::shared_ptr<DB::Context const>, DB::QueryProcessingStage::Enum, unsigned long, unsigned long) @ 0x0000000011ae8551 in /usr/bin/clickhouse
8. DB::(anonymous namespace)::buildQueryPlanForTableExpression(std::shared_ptr<DB::IQueryTreeNode>, DB::SelectQueryInfo const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::PlannerContext>&, bool, bool) @ 0x000000001135bd0c in /usr/bin/clickhouse
9. DB::buildJoinTreeQueryPlan(std::shared_ptr<DB::IQueryTreeNode> const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions&, std::unordered_set<String, std::hash<String>, std::equal_to<String>, std::allocator<String>> const&, std::shared_ptr<DB::PlannerContext>&) @ 0x00000000113505c7 in /usr/bin/clickhouse
10. DB::Planner::buildPlanForQueryNode() @ 0x0000000011331a45 in /usr/bin/clickhouse
11. DB::Planner::buildQueryPlanIfNeeded() @ 0x000000001132e2ad in /usr/bin/clickhouse
12. DB::(anonymous namespace)::buildQueryPlanForTableExpression(std::shared_ptr<DB::IQueryTreeNode>, DB::SelectQueryInfo const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::PlannerContext>&, bool, bool) @ 0x0000000011356482 in /usr/bin/clickhouse
13. DB::buildJoinTreeQueryPlan(std::shared_ptr<DB::IQueryTreeNode> const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions&, std::unordered_set<String, std::hash<String>, std::equal_to<String>, std::allocator<String>> const&, std::shared_ptr<DB::PlannerContext>&) @ 0x00000000113505c7 in /usr/bin/clickhouse
14. DB::Planner::buildPlanForQueryNode() @ 0x0000000011331a45 in /usr/bin/clickhouse
15. DB::Planner::buildQueryPlanIfNeeded() @ 0x000000001132e2ad in /usr/bin/clickhouse
16. DB::(anonymous namespace)::buildQueryPlanForTableExpression(std::shared_ptr<DB::IQueryTreeNode>, DB::SelectQueryInfo const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::PlannerContext>&, bool, bool) @ 0x0000000011356482 in /usr/bin/clickhouse
17. DB::buildJoinTreeQueryPlan(std::shared_ptr<DB::IQueryTreeNode> const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions&, std::unordered_set<String, std::hash<String>, std::equal_to<String>, std::allocator<String>> const&, std::shared_ptr<DB::PlannerContext>&) @ 0x00000000113505c7 in /usr/bin/clickhouse
18. DB::Planner::buildPlanForQueryNode() @ 0x0000000011331a45 in /usr/bin/clickhouse
19. DB::Planner::buildQueryPlanIfNeeded() @ 0x000000001132e2ad in /usr/bin/clickhouse
20. DB::(anonymous namespace)::buildQueryPlanForTableExpression(std::shared_ptr<DB::IQueryTreeNode>, DB::SelectQueryInfo const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::PlannerContext>&, bool, bool) @ 0x0000000011356482 in /usr/bin/clickhouse
21. DB::buildJoinTreeQueryPlan(std::shared_ptr<DB::IQueryTreeNode> const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions&, std::unordered_set<String, std::hash<String>, std::equal_to<String>, std::allocator<String>> const&, std::shared_ptr<DB::PlannerContext>&) @ 0x00000000113505c7 in /usr/bin/clickhouse
22. DB::Planner::buildPlanForQueryNode() @ 0x0000000011331a45 in /usr/bin/clickhouse
23. DB::Planner::buildQueryPlanIfNeeded() @ 0x000000001132e2ad in /usr/bin/clickhouse
24. DB::(anonymous namespace)::buildQueryPlanForTableExpression(std::shared_ptr<DB::IQueryTreeNode>, DB::SelectQueryInfo const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::PlannerContext>&, bool, bool) @ 0x0000000011356482 in /usr/bin/clickhouse
25. DB::buildJoinTreeQueryPlan(std::shared_ptr<DB::IQueryTreeNode> const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions&, std::unordered_set<String, std::hash<String>, std::equal_to<String>, std::allocator<String>> const&, std::shared_ptr<DB::PlannerContext>&) @ 0x000...
(2 additional frame(s) were not displayed)
...
  File "posthog/clickhouse/client/execute.py", line 119, in sync_execute
    result = client.execute(

CHQueryErrorThereIsNoColumn: DB::Exception: Cannot find column `if(and(equals(event_4, 'onramps-web ready'_String), ifNull(equals(transform(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(properties_5, 'has_onramped_before'_String), ''_String), 'null'_String), '^"|"$'_String, ''_String), ['true', 'false']_Array(String), [1, 0]_Array(Bool), NULL_Nullable(Nothing)), 0_Bool), 0_UInt8)), 1_UInt8, 0_UInt8)` in source stream, there are only columns: [array(ifNull(toString(nullIf(nullIf(mat_ramp_6, ''_String), 'null'_String)), ''_String)), toTimezone(timestamp_0, 'UTC'_String), notEmpty(arrayFilter(__lambda_12508571411162645967_17909235918787688987, array(ifNull(toString(nullIf(nullIf(mat_ramp_6, ''_String), 'null'_String)), ''_String)))), if(not(empty(distinct_id_1)), person_id_2, person_id_3), if(and(equals(event_4, 'onramps-web ready'_String), ifNull(equals(transform(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(properties_5, 'has_onramped_before'_String), ''_String), 'null'_String), '^"|"$'_String, ''_String), ['true', 'false']_Array(String), [1, 0]_Array(Bool), NULL_Nullable(Nothing)), 0_UInt8), 0_UInt8)), 1_UInt8, 0_UInt8), ifNull(equals(if(and(equals(event_4, 'onramps-web ready'_String), ifNull(equals(transform(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(properties_5, 'has_onramped_before'_String), ''_String), 'null'_String), '^"|"$'_String, ''_String), ['true', 'false']_Array(String), [1, 0]_Array(Bool), NULL_Nullable(Nothing)), 0_UInt8), 0_UInt8)), 1_UInt8, 0_UInt8), 1_UInt8), 0_UInt8), ifNull(equals(if(equals(event_4, 'onramps-web continued to ramp'_String), 1_UInt8, 0_UInt8), 1_UInt8), 0_UInt8), ifNull(equals(if(equals(event_4, 'onramping completed'_String), 1_UInt8, 0_UInt8), 1_UInt8), 0_UInt8)]. Stack trace:

0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000c6cf19b in /usr/bin/clickhouse
1. DB::Exception::Exception<String const&, String>(int, FormatStringHelperImpl<std::type_identity<String const&>::type, std::type_identity<String>::type>, String const&, String&&) @ 0x0000000007b694a7 in /usr/bin/clickhouse
2. DB::ActionsDAG::makeConvertingActions(std::vector<DB::ColumnWithTypeAndName, std::allocator<DB::ColumnWithTypeAndName>> const&, std::vector<DB::ColumnWithTypeAndName, std::allocator<DB::ColumnWithTypeAndName>> const&, DB::ActionsDAG::MatchColumnsMode, bool, bool, std::unordered_map<String, String, std::hash<String>, std::equal_to<String>, std::allocator<std::pair<String const, String>>>*) @ 0x000000001088a3c9 in /usr/bin/clickhouse
3. DB::createLocalPlan(std::shared_ptr<DB::IAST> const&, DB::Block const&, std::shared_ptr<DB::Context const>, DB::QueryProcessingStage::Enum, unsigned long, unsigned long) @ 0x0000000012ad3b0b in /usr/bin/clickhouse
4. DB::ClusterProxy::SelectStreamFactory::createForShard(DB::Cluster::ShardInfo const&, std::shared_ptr<DB::IAST> const&, DB::StorageID const&, std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context const>, std::vector<std::unique_ptr<DB::QueryPlan, std::default_delete<DB::QueryPlan>>, std::allocator<std::unique_ptr<DB::QueryPlan, std::default_delete<DB::QueryPlan>>>>&, std::vector<DB::ClusterProxy::SelectStreamFactory::Shard, std::allocator<DB::ClusterProxy::SelectStreamFactory::Shard>>&, unsigned int, bool)::$_0::operator()() const @ 0x0000000011affdac in /usr/bin/clickhouse
5. DB::ClusterProxy::SelectStreamFactory::createForShard(DB::Cluster::ShardInfo const&, std::shared_ptr<DB::IAST> const&, DB::StorageID const&, std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context const>, std::vector<std::unique_ptr<DB::QueryPlan, std::default_delete<DB::QueryPlan>>, std::allocator<std::unique_ptr<DB::QueryPlan, std::default_delete<DB::QueryPlan>>>>&, std::vector<DB::ClusterProxy::SelectStreamFactory::Shard, std::allocator<DB::ClusterProxy::SelectStreamFactory::Shard>>&, unsigned int, bool) @ 0x0000000011afeef9 in /usr/bin/clickhouse
6. DB::ClusterProxy::executeQuery(DB::QueryPlan&, DB::Block const&, DB::QueryProcessingStage::Enum, DB::StorageID const&, std::shared_ptr<DB::IAST> const&, DB::ClusterProxy::SelectStreamFactory&, Poco::Logger*, std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context const>, DB::SelectQueryInfo const&, std::shared_ptr<DB::ExpressionActions> const&, String const&, std::shared_ptr<DB::Cluster> const&, DB::DistributedSettings const&, std::function<std::shared_ptr<DB::IAST> (unsigned long)>) @ 0x0000000011b03ecd in /usr/bin/clickhouse
7. DB::StorageDistributed::read(DB::QueryPlan&, std::vector<String, std::allocator<String>> const&, std::shared_ptr<DB::StorageSnapshot> const&, DB::SelectQueryInfo&, std::shared_ptr<DB::Context const>, DB::QueryProcessingStage::Enum, unsigned long, unsigned long) @ 0x0000000011ae8551 in /usr/bin/clickhouse
8. DB::(anonymous namespace)::buildQueryPlanForTableExpression(std::shared_ptr<DB::IQueryTreeNode>, DB::SelectQueryInfo const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::PlannerContext>&, bool, bool) @ 0x000000001135bd0c in /usr/bin/clickhouse
9. DB::buildJoinTreeQueryPlan(std::shared_ptr<DB::IQueryTreeNode> const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions&, std::unordered_set<String, std::hash<String>, std::equal_to<String>, std::allocator<String>> const&, std::shared_ptr<DB::PlannerContext>&) @ 0x00000000113505c7 in /usr/bin/clickhouse
10. DB::Planner::buildPlanForQueryNode() @ 0x0000000011331a45 in /usr/bin/clickhouse
11. DB::Planner::buildQueryPlanIfNeeded() @ 0x000000001132e2ad in /usr/bin/clickhouse
12. DB::(anonymous namespace)::buildQueryPlanForTableExpression(std::shared_ptr<DB::IQueryTreeNode>, DB::SelectQueryInfo const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::PlannerContext>&, bool, bool) @ 0x0000000011356482 in /usr/bin/clickhouse
13. DB::buildJoinTreeQueryPlan(std::shared_ptr<DB::IQueryTreeNode> const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions&, std::unordered_set<String, std::hash<String>, std::equal_to<String>, std::allocator<String>> const&, std::shared_ptr<DB::PlannerContext>&) @ 0x00000000113505c7 in /usr/bin/clickhouse
14. DB::Planner::buildPlanForQueryNode() @ 0x0000000011331a45 in /usr/bin/clickhouse
15. DB::Planner::buildQueryPlanIfNeeded() @ 0x000000001132e2ad in /usr/bin/clickhouse
16. DB::(anonymous namespace)::buildQueryPlanForTableExpression(std::shared_ptr<DB::IQueryTreeNode>, DB::SelectQueryInfo const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::PlannerContext>&, bool, bool) @ 0x0000000011356482 in /usr/bin/clickhouse
17. DB::buildJoinTreeQueryPlan(std::shared_ptr<DB::IQueryTreeNode> const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions&, std::unordered_set<String, std::hash<String>, std::equal_to<String>, std::allocator<String>> const&, std::shared_ptr<DB::PlannerContext>&) @ 0x00000000113505c7 in /usr/bin/clickhouse
18. DB::Planner::buildPlanForQueryNode() @ 0x0000000011331a45 in /usr/bin/clickhouse
19. DB::Planner::buildQueryPlanIfNeeded() @ 0x000000001132e2ad in /usr/bin/clickhouse
20. DB::(anonymous namespace)::buildQueryPlanForTableExpression(std::shared_ptr<DB::IQueryTreeNode>, DB::SelectQueryInfo const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::PlannerContext>&, bool, bool) @ 0x0000000011356482 in /usr/bin/clickhouse
21. DB::buildJoinTreeQueryPlan(std::shared_ptr<DB::IQueryTreeNode> const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions&, std::unordered_set<String, std::hash<String>, std::equal_to<String>, std::allocator<String>> const&, std::shared_ptr<DB::PlannerContext>&) @ 0x00000000113505c7 in /usr/bin/clickhouse
22. DB::Planner::buildPlanForQueryNode() @ 0x0000000011331a45 in /usr/bin/clickhouse
23. DB::Planner::buildQueryPlanIfNeeded() @ 0x000000001132e2ad in /usr/bin/clickhouse
24. DB::(anonymous namespace)::buildQueryPlanForTableExpression(std::shared_ptr<DB::IQueryTreeNode>, DB::SelectQueryInfo const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::PlannerContext>&, bool, bool) @ 0x0000000011356482 in /usr/bin/clickhouse
25. DB::buildJoinTreeQueryPlan(std::shared_ptr<DB::IQueryTreeNode> const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions&, std::unordered_set<String, std::hash<String>, std::equal_to<String>, std::allocator<String>> const&, std::shared_ptr<DB::PlannerContext>&) @ 0x000...
(8 additional frame(s) were not displayed)
...
  File "posthog/hogql_queries/query_runner.py", line 490, in run
    **self.calculate().model_dump(),
  File "posthog/hogql_queries/insights/funnels/funnels_query_runner.py", line 86, in calculate
    response = execute_hogql_query(
  File "posthog/hogql/query.py", line 187, in execute_hogql_query
    results, types = sync_execute(
  File "posthog/utils.py", line 1338, in inner
    return inner._impl(*args, **kwargs)  # type: ignore
  File "posthog/clickhouse/client/execute.py", line 133, in sync_execute
    raise err from e
skoob13 commented 4 days ago

Fixed by #23455