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.4k stars 5.73k forks source link

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

Closed ti-chi-bot closed 1 month ago

ti-chi-bot commented 1 month 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` 可以用作窗口函数。
codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

:exclamation: No coverage uploaded for pull request base (release-8.1@d774c73). Click here to learn what that means.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## release-8.1 #53288 +/- ## ================================================ Coverage ? 71.1541% ================================================ Files ? 1465 Lines ? 421221 Branches ? 0 ================================================ Hits ? 299716 Misses ? 101029 Partials ? 20476 ``` | [Flag](https://app.codecov.io/gh/pingcap/tidb/pull/53288/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | Coverage Δ | | |---|---|---| | [unit](https://app.codecov.io/gh/pingcap/tidb/pull/53288/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `71.1541% <100.0000%> (?)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap#carryforward-flags-in-the-pull-request-comment) to find out more. | [Components](https://app.codecov.io/gh/pingcap/tidb/pull/53288/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | Coverage Δ | | |---|---|---| | [dumpling](https://app.codecov.io/gh/pingcap/tidb/pull/53288/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `53.9957% <0.0000%> (?)` | | | [parser](https://app.codecov.io/gh/pingcap/tidb/pull/53288/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `∅ <0.0000%> (?)` | | | [br](https://app.codecov.io/gh/pingcap/tidb/pull/53288/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `40.9772% <0.0000%> (?)` | |
ti-chi-bot[bot] commented 1 month ago

[LGTM Timeline notifier]

Timeline:

tangenta commented 1 month ago

/approve

easonn7 commented 1 month ago

/approve

ti-chi-bot[bot] commented 1 month ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: easonn7, hawkingrei, hi-rustin, 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-8.1/OWNERS)~~ [hawkingrei,hi-rustin,tangenta] - ~~[pkg/parser/OWNERS](https://github.com/pingcap/tidb/blob/release-8.1/pkg/parser/OWNERS)~~ [easonn7,tangenta] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment