zclllyybb commented on code in PR #3032:
URL: https://github.com/apache/doris-website/pull/3032#discussion_r2483826615
##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/numeric-functions/interval.md:
##########
@@ -0,0 +1,99 @@
+---
+{
+ "title": "INTERVAL",
+ "language": "zh-CN"
+}
+---
+
+## 描述
+
+INTERVAL 函数使用二分查找返回第一个严格大于 N 的阈值位置索引。该函数要求阈值参数按升序排列(N1 ≤ N2 ≤ N3 ≤ ... ≤
Nn)才能正确使用二分查找算法,从而获得最佳性能。
+
+- 所有参数都被视为整数类型(TINYINT、SMALLINT、INT、BIGINT、LARGEINT)。
+- 使用二分查找算法,时间复杂度为 O(log n),性能优异。
+- 如果所有阈值都小于等于 N,则返回阈值数量。
+
+该函数与 MySQL 中的 [interval
函数](https://dev.mysql.com/doc/refman/8.4/en/string-functions.html#function_interval)
行为一致。
+
+## 语法
+
+```sql
+INTERVAL(N, N1, N2, N3, ...)
+```
+
+## 参数
+
+| 参数 | 说明 |
+| -- | -- |
+| `N` | 待查找的值,整数类型(TINYINT、SMALLINT、INT、BIGINT、LARGEINT) |
+| `N1, N2, N3, ...` | 阈值列表,必须与 N 的类型相同,且要求按升序排列(N1 ≤ N2 ≤ N3 ≤ ... ≤
Nn)。至少需要一个阈值参数 |
+
+## 返回值
+
+返回 INT32 类型的结果:
+- 返回第一个严格大于 N 的阈值位置索引(从 0 开始计数)。
+- 如果所有阈值都小于等于 N,返回阈值数量。
+- 如果 N 为 NULL,返回 NULL。
+
+**返回规则:**
+- 如果 N < N1,返回 0
+- 如果 N < N2,返回 1
+- 如果 N < N3,返回 2
+- 以此类推...
+- 如果所有阈值都 ≤ N,返回阈值数量
+
+特殊情况:
+- 任何参数为 NULL 时,返回 NULL。
+- 如果阈值参数未按升序排列,函数仍会执行二分查找,但可能返回不正确的结果。
+
+## 举例
+
+```sql
+-- 基本用法
+SELECT INTERVAL(23, 1, 15, 17, 30, 44, 200);
Review Comment:
what if only one input?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]