add doc for sum_int#23199
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Code Review
This pull request introduces documentation for the new SUM_INT() aggregate function, detailing its usage, argument types, and support as a window and pushdown function. The review feedback provides actionable suggestions to improve the clarity and conciseness of the text, such as explicitly mentioning support for both signed and unsigned integers, removing redundant phrases like 'by default' and 'the TiDB-specific', and making example introductions more direct.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| + `SUM_INT(expr)` | ||
|
|
||
| This function returns the sum of the integer expression `expr`. It works similarly to `SUM(expr)`, but only accepts integer arguments, including `TINYINT`, `SMALLINT`, `MEDIUMINT`, `INT`, and `BIGINT`. For a signed integer argument, the return type is `BIGINT`. For an unsigned integer argument, the return type is `BIGINT UNSIGNED`. If the sum of non-`NULL` values exceeds the range of the return type, TiDB returns an integer overflow error. |
There was a problem hiding this comment.
Clarify that SUM_INT() accepts both signed and unsigned integer arguments to make it consistent with the subsequent sentence explaining the return types for signed and unsigned arguments.
| This function returns the sum of the integer expression `expr`. It works similarly to `SUM(expr)`, but only accepts integer arguments, including `TINYINT`, `SMALLINT`, `MEDIUMINT`, `INT`, and `BIGINT`. For a signed integer argument, the return type is `BIGINT`. For an unsigned integer argument, the return type is `BIGINT UNSIGNED`. If the sum of non-`NULL` values exceeds the range of the return type, TiDB returns an integer overflow error. | |
| This function returns the sum of the integer expression `expr`. It works similarly to `SUM(expr)`, but only accepts integer arguments, including `TINYINT`, `SMALLINT`, `MEDIUMINT`, `INT`, and `BIGINT` (both signed and unsigned). For a signed integer argument, the return type is `BIGINT`. For an unsigned integer argument, the return type is `BIGINT UNSIGNED`. If the sum of non-`NULL` values exceeds the range of the return type, TiDB returns an integer overflow error. |
References
- Clarity, simplicity, completeness, and readability (link)
|
|
||
| This function returns the sum of the integer expression `expr`. It works similarly to `SUM(expr)`, but only accepts integer arguments, including `TINYINT`, `SMALLINT`, `MEDIUMINT`, `INT`, and `BIGINT`. For a signed integer argument, the return type is `BIGINT`. For an unsigned integer argument, the return type is `BIGINT UNSIGNED`. If the sum of non-`NULL` values exceeds the range of the return type, TiDB returns an integer overflow error. | ||
|
|
||
| `SUM_INT()` ignores `NULL` values by default. If there are no non-`NULL` values, it returns `NULL`. `SUM_INT()` supports `DISTINCT` and can be used as a [window function](/functions-and-operators/window-functions.md). |
There was a problem hiding this comment.
Remove "by default" because SUM_INT() always ignores NULL values and there is no option to change this behavior. This avoids unnecessary words and potential confusion.
| `SUM_INT()` ignores `NULL` values by default. If there are no non-`NULL` values, it returns `NULL`. `SUM_INT()` supports `DISTINCT` and can be used as a [window function](/functions-and-operators/window-functions.md). | |
| `SUM_INT()` ignores `NULL` values. If there are no non-`NULL` values, it returns `NULL`. `SUM_INT()` supports `DISTINCT` and can be used as a [window function](/functions-and-operators/window-functions.md). |
References
- Avoid unnecessary words and repetition. (link)
|
|
||
| `SUM_INT()` ignores `NULL` values by default. If there are no non-`NULL` values, it returns `NULL`. `SUM_INT()` supports `DISTINCT` and can be used as a [window function](/functions-and-operators/window-functions.md). | ||
|
|
||
| The following example shows how to use this function: |
There was a problem hiding this comment.
Make the sentence more direct and concise by referring to the function name directly instead of using "this function".
| The following example shows how to use this function: | |
| The following example shows how to use `SUM_INT()`: |
References
- Avoid unnecessary words and repetition. (link)
| The window functions [listed here](/tiflash/tiflash-supported-pushdown-calculations.md) can be pushed down to TiFlash. | ||
|
|
||
| Except for `GROUP_CONCAT()` and `APPROX_PERCENTILE()`, TiDB supports using all [`GROUP BY` aggregate functions](/functions-and-operators/aggregate-group-by-functions.md) as window functions. In addition, TiDB supports the following window functions: | ||
| Except for `GROUP_CONCAT()`, `APPROX_PERCENTILE()`, and `APPROX_COUNT_DISTINCT()`, TiDB supports using all [`GROUP BY` aggregate functions](/functions-and-operators/aggregate-group-by-functions.md) as window functions, including the TiDB-specific `SUM_INT()` function. In addition, TiDB supports the following window functions: |
There was a problem hiding this comment.
Simplify the phrasing by removing "the TiDB-specific" and "function" to avoid unnecessary words and repetition.
| Except for `GROUP_CONCAT()`, `APPROX_PERCENTILE()`, and `APPROX_COUNT_DISTINCT()`, TiDB supports using all [`GROUP BY` aggregate functions](/functions-and-operators/aggregate-group-by-functions.md) as window functions, including the TiDB-specific `SUM_INT()` function. In addition, TiDB supports the following window functions: | |
| Except for `GROUP_CONCAT()`, `APPROX_PERCENTILE()`, and `APPROX_COUNT_DISTINCT()`, TiDB supports using all [`GROUP BY` aggregate functions](/functions-and-operators/aggregate-group-by-functions.md) as window functions, including `SUM_INT()`. In addition, TiDB supports the following window functions: |
References
- Avoid unnecessary words and repetition. (link)
First-time contributors' checklist
What is changed, added or deleted? (Required)
Which TiDB version(s) do your changes apply to? (Required)
Tips for choosing the affected version(s):
By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.
For details, see tips for choosing the affected versions.
What is the related PR or file link(s)?
Do your changes match any of the following descriptions?