diff --git a/planner/core/casetest/integration_test.go b/planner/core/casetest/integration_test.go index 78516e161f422..4b47fa6383140 100644 --- a/planner/core/casetest/integration_test.go +++ b/planner/core/casetest/integration_test.go @@ -3588,3 +3588,11 @@ func TestFixControl44262(t *testing.T) { testJoin(`select /*+ TIDB_INLJ(t2_part@sel_2) */ * from t1 where t1.b<10 and not exists (select 1 from t2_part where t1.a=t2_part.a and t2_part.b<20)`, "IndexJoin") tk.MustQuery(`show warnings`).Sort().Check(testkit.Rows()) // no warning } + +func TestIssue41957(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + tk.MustExec(`use test`) + tk.MustExec("CREATE TABLE `github_events` (\n `id` bigint(20) NOT NULL DEFAULT '0',\n `type` varchar(29) NOT NULL DEFAULT 'Event',\n `created_at` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',\n `repo_id` bigint(20) NOT NULL DEFAULT '0',\n `repo_name` varchar(140) NOT NULL DEFAULT '',\n `actor_id` bigint(20) NOT NULL DEFAULT '0',\n `actor_login` varchar(40) NOT NULL DEFAULT '',\n `language` varchar(26) NOT NULL DEFAULT '',\n `additions` bigint(20) NOT NULL DEFAULT '0',\n `deletions` bigint(20) NOT NULL DEFAULT '0',\n `action` varchar(11) NOT NULL DEFAULT '',\n `number` int(11) NOT NULL DEFAULT '0',\n `commit_id` varchar(40) NOT NULL DEFAULT '',\n `comment_id` bigint(20) NOT NULL DEFAULT '0',\n `org_login` varchar(40) NOT NULL DEFAULT '',\n `org_id` bigint(20) NOT NULL DEFAULT '0',\n `state` varchar(6) NOT NULL DEFAULT '',\n `closed_at` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',\n `comments` int(11) NOT NULL DEFAULT '0',\n `pr_merged_at` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',\n `pr_merged` tinyint(1) NOT NULL DEFAULT '0',\n `pr_changed_files` int(11) NOT NULL DEFAULT '0',\n `pr_review_comments` int(11) NOT NULL DEFAULT '0',\n `pr_or_issue_id` bigint(20) NOT NULL DEFAULT '0',\n `event_day` date NOT NULL,\n `event_month` date NOT NULL,\n `event_year` int(11) NOT NULL,\n `push_size` int(11) NOT NULL DEFAULT '0',\n `push_distinct_size` int(11) NOT NULL DEFAULT '0',\n `creator_user_login` varchar(40) NOT NULL DEFAULT '',\n `creator_user_id` bigint(20) NOT NULL DEFAULT '0',\n `pr_or_issue_created_at` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',\n KEY `index_github_events_on_id` (`id`),\n KEY `index_github_events_on_created_at` (`created_at`),\n KEY `index_github_events_on_repo_id_type_action_month_actor_login` (`repo_id`,`type`,`action`,`event_month`,`actor_login`),\n KEY `index_ge_on_repo_id_type_action_pr_merged_created_at_add_del` (`repo_id`,`type`,`action`,`pr_merged`,`created_at`,`additions`,`deletions`),\n KEY `index_ge_on_creator_id_type_action_merged_created_at_add_del` (`creator_user_id`,`type`,`action`,`pr_merged`,`created_at`,`additions`,`deletions`),\n KEY `index_ge_on_actor_id_type_action_created_at_repo_id_commits` (`actor_id`,`type`,`action`,`created_at`,`repo_id`,`push_distinct_size`),\n KEY `index_ge_on_repo_id_type_action_created_at_number_pdsize_psize` (`repo_id`,`type`,`action`,`created_at`,`number`,`push_distinct_size`,`push_size`),\n KEY `index_ge_on_repo_id_type_action_created_at_actor_login` (`repo_id`,`type`,`action`,`created_at`,`actor_login`),\n KEY `index_ge_on_repo_name_type` (`repo_name`,`type`),\n KEY `index_ge_on_actor_login_type` (`actor_login`,`type`),\n KEY `index_ge_on_org_login_type` (`org_login`,`type`),\n KEY `index_ge_on_language` (`language`),\n KEY `index_ge_on_org_id_type` (`org_id`,`type`),\n KEY `index_ge_on_actor_login_lower` ((lower(`actor_login`))),\n KEY `index_ge_on_repo_name_lower` ((lower(`repo_name`))),\n KEY `index_ge_on_language_lower` ((lower(`language`))),\n KEY `index_ge_on_type_action` (`type`,`action`) /*!80000 INVISIBLE */,\n KEY `index_ge_on_repo_id_type_created_at` (`repo_id`,`type`,`created_at`),\n KEY `index_ge_on_repo_id_created_at` (`repo_id`,`created_at`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin\nPARTITION BY LIST COLUMNS(`type`)\n(PARTITION `push_event` VALUES IN ('PushEvent'),\n PARTITION `create_event` VALUES IN ('CreateEvent'),\n PARTITION `pull_request_event` VALUES IN ('PullRequestEvent'),\n PARTITION `watch_event` VALUES IN ('WatchEvent'),\n PARTITION `issue_comment_event` VALUES IN ('IssueCommentEvent'),\n PARTITION `issues_event` VALUES IN ('IssuesEvent'),\n PARTITION `delete_event` VALUES IN ('DeleteEvent'),\n PARTITION `fork_event` VALUES IN ('ForkEvent'),\n PARTITION `pull_request_review_comment_event` VALUES IN ('PullRequestReviewCommentEvent'),\n PARTITION `pull_request_review_event` VALUES IN ('PullRequestReviewEvent'),\n PARTITION `gollum_event` VALUES IN ('GollumEvent'),\n PARTITION `release_event` VALUES IN ('ReleaseEvent'),\n PARTITION `member_event` VALUES IN ('MemberEvent'),\n PARTITION `commit_comment_event` VALUES IN ('CommitCommentEvent'),\n PARTITION `public_event` VALUES IN ('PublicEvent'),\n PARTITION `gist_event` VALUES IN ('GistEvent'),\n PARTITION `follow_event` VALUES IN ('FollowEvent'),\n PARTITION `event` VALUES IN ('Event'),\n PARTITION `download_event` VALUES IN ('DownloadEvent'),\n PARTITION `team_add_event` VALUES IN ('TeamAddEvent'),\n PARTITION `fork_apply_event` VALUES IN ('ForkApplyEvent'))\n") + tk.MustQuery("SELECT\n repo_id, GROUP_CONCAT(\n DISTINCT actor_login\n ORDER BY cnt DESC\n SEPARATOR ','\n ) AS actor_logins\nFROM (\n SELECT\n ge.repo_id AS repo_id,\n ge.actor_login AS actor_login,\n COUNT(*) AS cnt\n FROM github_events ge\n WHERE\n type = 'PullRequestEvent' AND action = 'opened'\n AND (ge.created_at >= DATE_SUB(NOW(), INTERVAL 1 DAY) AND ge.created_at <= NOW())\n GROUP BY ge.repo_id, ge.actor_login\n ORDER BY cnt DESC\n) sub\nGROUP BY repo_id").Check(testkit.Rows()) +}