This is an automated email from the ASF dual-hosted git repository.
zclll pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push:
new ca6a4c4297f [Enhancement](function) Support two args versions of
TIMESTAMP (#3130)
ca6a4c4297f is described below
commit ca6a4c4297fd2ae42ee104086e4e6d109fc897f7
Author: linrrarity <[email protected]>
AuthorDate: Thu Jan 22 18:29:52 2026 +0800
[Enhancement](function) Support two args versions of TIMESTAMP (#3130)
## Versions
- [x] dev
- [x] 4.x
- [ ] 3.x
- [ ] 2.1
## Languages
- [x] Chinese
- [x] English
## Docs Checklist
- [ ] Checked by AI
- [ ] Test Cases Built
---
.../date-time-functions/timestamp.md | 39 +++++++++++++++++---
.../scalar-functions/string-functions/timestamp.md | 11 ------
.../date-time-functions/timestamp.md | 38 ++++++++++++++++---
.../date-time-functions/timestamp.md | 42 ++++++++++++++++++---
.../date-time-functions/timestamp.md | 43 +++++++++++++++++++---
.../scalar-functions/string-functions/timestamp.md | 11 ------
6 files changed, 142 insertions(+), 42 deletions(-)
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
index 64402b73348..bebd0378e4a 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
@@ -12,29 +12,34 @@
## Description
The TIMESTAMP function converts a datetime format string to DATETIME type.
+If a second time parameter exists, it calculates the sum of the two parameters
and returns the result in DATETIME format.
For specific datetime formats, please refer to [datetime
conversion](../../../../sql-manual/basic-element/sql-data-types/conversion/datetime-conversion).
-This function differs from the [timestamp
function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_timestamp)
in MySQL. Doris currently does not support a second time parameter for
datetime addition/subtraction.
+This function behaves the same way as the [timestamp
function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_timestamp)
in MySQL.
## Syntax
```sql
-TIMESTAMP(string)
+TIMESTAMP(<date_or_datetime_string>[, <time_string>])
```
## Parameters
| Parameter | Description |
|-----------|-------------------------------------------------------|
-| `string` | Datetime string type |
+| `date_or_datetime_string` | Date or datetime string type |
+| `time_string` | Time string type |
## Return Value
Returns a value of type DATETIME.
-- If the input is a date string, the time is set to 00:00:00
-- If input is NULL, returns NULL
+When one parameter is provided, returns the result of converting the first
parameter to DATETIME type.
+When two parameters are provided, returns the sum of the two parameters.
+
+- If the first parameter is a date string, the time is set to 00:00:00
+- If any parameter is NULL or parameter type does not match, returns NULL
## Examples
@@ -63,5 +68,29 @@ SELECT TIMESTAMP(NULL);
+-----------------+
| NULL |
+-----------------+
+
+-- Two parameters, returns the sum of the two parameters (Date/DateTime + Time)
+SELECT TIMESTAMP('2025-11-30 23:45:12', '12:34:56');
++----------------------------------------------+
+| TIMESTAMP('2025-11-30 23:45:12', '12:34:56') |
++----------------------------------------------+
+| 2025-12-01 12:20:08 |
++----------------------------------------------+
+
+-- The first parameter only accepts Date/Datetime type, the second parameter
only accepts Time type
+SELECT TIMESTAMP('12:34:56', '12:34:56');
++-----------------------------------+
+| TIMESTAMP('12:34:56', '12:34:56') |
++-----------------------------------+
+| NULL |
++-----------------------------------+
+
+-- If any parameter is NULL, returns NULL
+SELECT TIMESTAMP('2025-12-01', NULL);
++-------------------------------+
+| TIMESTAMP('2025-12-01', NULL) |
++-------------------------------+
+| NULL |
++-------------------------------+
```
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/timestamp.md
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/timestamp.md
deleted file mode 100644
index 97ba218a117..00000000000
---
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/timestamp.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-{
- "title": "TIMESTAMP | String Functions",
- "language": "zh-CN",
- "draft": true,
- "sidebar_label": "TIMESTAMP"
-}
----
-
-# TIMESTAMP
-
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
index e51c64fe5ba..8638db543d8 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
@@ -9,29 +9,34 @@
## 描述
TIMESTAMP 将 符合 datetime 格式的字符串转换为 DATETIME 类型
+如果存在第二个时间类型的参数,则计算两参数相加的结果,然后以DATETIME类型的格式返回。
具体 datetime 格式请查看 [datetime
的转换](../../../../../current/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion).
-该函数与 mysql 中的 [timestamp
函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_timestamp)
有些差异,doris 暂不支持带有第二个 time 参数进行日期时间增减。
+该函数与 mysql 中的 [timestamp
函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_timestamp)
行为相同。
## 语法
```sql
-TIMESTAMP(string)
+TIMESTAMP(<date_or_datetime_string>[, <time_string>])
```
## 参数
| 参数 | 说明 |
| ---- | ---- |
-| `string` | 日期时间字符串类型 |
+| `date_or_datetime_string` | 日期时间字符串类型 |
+| `time_string` | 时间字符串类型 |
## 返回值
返回类型为 DATETIME。
-- 若输入为 date 字符串,则时间被设置为 00:00:00
-- 输入 NULL,返回 NULL
+当输入参数数量为 1 时,返回将第一个参数转换为 DATETIME 类型的结果。
+当输入参数数量为 2 时,返回两参数相加的结果
+
+- 若第一个参数输入为 date 字符串,则时间被设置为 00:00:00
+- 任一参数为 NULL或参数类型不匹配时,返回 NULL
## 举例
```sql
@@ -60,4 +65,27 @@ SELECT TIMESTAMP(NULL);
| NULL |
+-----------------+
+-- 两个参数,返回两个参数相加的结果(Date/DateTime + Time)
+SELECT TIMESTAMP('2025-11-30 23:45:12', '12:34:56');
++----------------------------------------------+
+| TIMESTAMP('2025-11-30 23:45:12', '12:34:56') |
++----------------------------------------------+
+| 2025-12-01 12:20:08 |
++----------------------------------------------+
+
+-- 第一个参数仅接受Date/Datetime类型,第二个参数仅接受 Time 类型
+SELECT TIMESTAMP('12:34:56', '12:34:56');
++-----------------------------------+
+| TIMESTAMP('12:34:56', '12:34:56') |
++-----------------------------------+
+| NULL |
++-----------------------------------+
+
+-- 任一参数为 NULL, 返回 NULL
+SELECT TIMESTAMP('2025-12-01', NULL);
++-------------------------------+
+| TIMESTAMP('2025-12-01', NULL) |
++-------------------------------+
+| NULL |
++-------------------------------+
```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
index e51c64fe5ba..c07ce2618e8 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
@@ -9,29 +9,38 @@
## 描述
TIMESTAMP 将 符合 datetime 格式的字符串转换为 DATETIME 类型
+如果存在第二个时间类型的参数,则计算两参数相加的结果,然后以DATETIME类型的格式返回。
具体 datetime 格式请查看 [datetime
的转换](../../../../../current/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion).
-该函数与 mysql 中的 [timestamp
函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_timestamp)
有些差异,doris 暂不支持带有第二个 time 参数进行日期时间增减。
+该函数与 mysql 中的 [timestamp
函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_timestamp)
行为相同。
+
+:::note
+两个参数版本从4.0.3开始支持
+:::
## 语法
```sql
-TIMESTAMP(string)
+TIMESTAMP(<date_or_datetime_string>[, <time_string>])
```
## 参数
| 参数 | 说明 |
| ---- | ---- |
-| `string` | 日期时间字符串类型 |
+| `date_or_datetime_string` | 日期时间字符串类型 |
+| `time_string` | 时间字符串类型 |
## 返回值
返回类型为 DATETIME。
-- 若输入为 date 字符串,则时间被设置为 00:00:00
-- 输入 NULL,返回 NULL
+当输入参数数量为 1 时,返回将第一个参数转换为 DATETIME 类型的结果。
+当输入参数数量为 2 时,返回两参数相加的结果
+
+- 若第一个参数输入为 date 字符串,则时间被设置为 00:00:00
+- 任一参数为 NULL或参数类型不匹配时,返回 NULL
## 举例
```sql
@@ -60,4 +69,27 @@ SELECT TIMESTAMP(NULL);
| NULL |
+-----------------+
+-- 两个参数,返回两个参数相加的结果(Date/DateTime + Time)
+SELECT TIMESTAMP('2025-11-30 23:45:12', '12:34:56');
++----------------------------------------------+
+| TIMESTAMP('2025-11-30 23:45:12', '12:34:56') |
++----------------------------------------------+
+| 2025-12-01 12:20:08 |
++----------------------------------------------+
+
+-- 第一个参数仅接受Date/Datetime类型,第二个参数仅接受 Time 类型
+SELECT TIMESTAMP('12:34:56', '12:34:56');
++-----------------------------------+
+| TIMESTAMP('12:34:56', '12:34:56') |
++-----------------------------------+
+| NULL |
++-----------------------------------+
+
+-- 任一参数为 NULL, 返回 NULL
+SELECT TIMESTAMP('2025-12-01', NULL);
++-------------------------------+
+| TIMESTAMP('2025-12-01', NULL) |
++-------------------------------+
+| NULL |
++-------------------------------+
```
diff --git
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
index 64402b73348..bf8b3523990 100644
---
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp.md
@@ -12,29 +12,38 @@
## Description
The TIMESTAMP function converts a datetime format string to DATETIME type.
+If a second time parameter exists, it calculates the sum of the two parameters
and returns the result in DATETIME format.
For specific datetime formats, please refer to [datetime
conversion](../../../../sql-manual/basic-element/sql-data-types/conversion/datetime-conversion).
-This function differs from the [timestamp
function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_timestamp)
in MySQL. Doris currently does not support a second time parameter for
datetime addition/subtraction.
+This function behaves the same way as the [timestamp
function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_timestamp)
in MySQL.
+
+:::note
+Two parameter versions are supported from 4.0.3
+:::
## Syntax
```sql
-TIMESTAMP(string)
+TIMESTAMP(<date_or_datetime_string>[, <time_string>])
```
## Parameters
| Parameter | Description |
|-----------|-------------------------------------------------------|
-| `string` | Datetime string type |
+| `date_or_datetime_string` | Date or datetime string type |
+| `time_string` | Time string type |
## Return Value
Returns a value of type DATETIME.
-- If the input is a date string, the time is set to 00:00:00
-- If input is NULL, returns NULL
+When one parameter is provided, returns the result of converting the first
parameter to DATETIME type.
+When two parameters are provided, returns the sum of the two parameters.
+
+- If the first parameter is a date string, the time is set to 00:00:00
+- If any parameter is NULL or parameter type does not match, returns NULL
## Examples
@@ -63,5 +72,29 @@ SELECT TIMESTAMP(NULL);
+-----------------+
| NULL |
+-----------------+
+
+-- Two parameters, returns the sum of the two parameters (Date/DateTime + Time)
+SELECT TIMESTAMP('2025-11-30 23:45:12', '12:34:56');
++----------------------------------------------+
+| TIMESTAMP('2025-11-30 23:45:12', '12:34:56') |
++----------------------------------------------+
+| 2025-12-01 12:20:08 |
++----------------------------------------------+
+
+-- The first parameter only accepts Date/Datetime type, the second parameter
only accepts Time type
+SELECT TIMESTAMP('12:34:56', '12:34:56');
++-----------------------------------+
+| TIMESTAMP('12:34:56', '12:34:56') |
++-----------------------------------+
+| NULL |
++-----------------------------------+
+
+-- If any parameter is NULL, returns NULL
+SELECT TIMESTAMP('2025-12-01', NULL);
++-------------------------------+
+| TIMESTAMP('2025-12-01', NULL) |
++-------------------------------+
+| NULL |
++-------------------------------+
```
diff --git
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/timestamp.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/timestamp.md
deleted file mode 100644
index 97ba218a117..00000000000
---
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/timestamp.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-{
- "title": "TIMESTAMP | String Functions",
- "language": "zh-CN",
- "draft": true,
- "sidebar_label": "TIMESTAMP"
-}
----
-
-# TIMESTAMP
-
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]