pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
36.32k stars 5.72k forks source link

planner: make `var_samp` can be used as a window function (#53130) #53286

Open ti-chi-bot opened 2 weeks ago

ti-chi-bot commented 2 weeks ago

This is an automated cherry-pick of #53130

What problem does this PR solve?

Issue Number: close https://github.com/pingcap/tidb/issues/52933

Problem Summary:

What changed and how does it work?

From the MySQL plan:

mysql> explain analyze select var_samp(c1) over (partition by c1) from t1;
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| EXPLAIN                                                                                                                                                                                                                                                                                                                |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -> Window aggregate with buffering: var_samp(t1.c1) OVER (PARTITION BY t1.c1 )   (cost=0 rows=1) (actual time=0.139..0.139 rows=0 loops=1)
    -> Sort: t1.c1  (cost=0.35 rows=1) (actual time=0.133..0.133 rows=0 loops=1)
        -> Table scan on t1  (cost=0.35 rows=1) (actual time=0.116..0.116 rows=0 loops=1)
 |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

Check List

Tests

Side effects

Documentation

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Make `var_samp` can be used as a window function.
使 `var_samp` 可以用作窗口函数。
ti-chi-bot[bot] commented 2 weeks ago

@ti-chi-bot: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/build a0ee23f9509147ca357bfaa5f256201f18fad2b4 link true /test build
idc-jenkins-ci-tidb/unit-test a0ee23f9509147ca357bfaa5f256201f18fad2b4 link true /test unit-test
idc-jenkins-ci-tidb/check_dev a0ee23f9509147ca357bfaa5f256201f18fad2b4 link true /test check-dev

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
ti-chi-bot[bot] commented 2 weeks ago

[LGTM Timeline notifier]

Timeline:

easonn7 commented 2 weeks ago

/approve

ti-chi-bot[bot] commented 2 weeks ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: easonn7, tangenta

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/pingcap/tidb/blob/release-7.1/OWNERS)~~ [tangenta] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment