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 8737d19e66f [docs](from-unixtime) add fractional timestamp support
documentation (#3543)
8737d19e66f is described below
commit 8737d19e66f8309f38827dfd05003f676490dfc7
Author: zclllyybb <[email protected]>
AuthorDate: Mon Apr 13 17:26:49 2026 +0800
[docs](from-unixtime) add fractional timestamp support documentation (#3543)
- Document support for DECIMAL type input timestamps with fractional
seconds
- Update parameter description to indicate BIGINT or DECIMAL type
support
- Extend supported timestamp range to include microsecond precision
(253402271999.999999)
- Add three examples demonstrating fractional timestamp conversion with
sub-second precision
## Versions
- [x] dev
- [x] 4.x
- [ ] 3.x
- [ ] 2.1
## Languages
- [x] Chinese
- [x] English
## Docs Checklist
- [x] Checked by AI
- [ ] Test Cases Built
---
.../date-time-functions/from-unixtime.md | 32 +++++++++++++++++++---
.../date-time-functions/from-unixtime.md | 32 +++++++++++++++++++---
.../date-time-functions/from-unixtime.md | 32 +++++++++++++++++++---
.../date-time-functions/from-unixtime.md | 32 +++++++++++++++++++---
4 files changed, 112 insertions(+), 16 deletions(-)
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
index 72600e63bae..df94554f49f 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
@@ -9,7 +9,7 @@
## Description
-The FROM_UNIXTIME function is used to convert a Unix timestamp (in seconds) to
a date-time string or VARCHAR type value in a specified format. The reference
time for Unix timestamps is 1970-01-01 00:00:00 UTC, and the function generates
the corresponding date-time representation based on the input timestamp and
format string.
+The FROM_UNIXTIME function is used to convert a Unix timestamp (in seconds) to
a date-time string or VARCHAR type value in a specified format. The reference
time for Unix timestamps is 1970-01-01 00:00:00 UTC, and the function generates
the corresponding date-time representation based on the input timestamp and
format string. When the input timestamp contains a fractional part, the result
includes sub-second precision up to microseconds (6 decimal places).
This function is consistent with the [from_unixtime
function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_from-unixtime)
in MySQL.
@@ -23,13 +23,13 @@ FROM_UNIXTIME(<unix_timestamp> [, <string_format>])
| Parameter | Description |
| -- | -- |
-| `<unix_timestamp>` | Input Unix timestamp, of integer type BIGINT,
representing the number of seconds from 1970-01-01 00:00:00 UTC |
+| `<unix_timestamp>` | Input Unix timestamp, of type BIGINT or DECIMAL,
representing the number of seconds (with optional fractional seconds) from
1970-01-01 00:00:00 UTC |
| `<string_format>` | Format string, supports varchar and string types,
default is %Y-%m-%d %H:%i:%s. For specific formats, please refer to
[date-format](./date-format) |
## Return Value
-Returns date in specified format, of type VARCHAR, returning the result of
converting the UTC timezone unix timestamp to the current timezone time.
-- Currently supported unix_timestamp range is [0, 253402271999] corresponding
to dates from 1970-01-01 00:00:00 to 9999-12-31 23:59:59, unix_timestamp
outside this range will return an error
+Returns date in specified format, of type VARCHAR, returning the result of
converting the UTC timezone unix timestamp to the current timezone time. When
the input contains a fractional part, the result includes sub-second precision
(e.g., `2007-12-01 00:30:19.500000`).
+- Currently supported unix_timestamp range is [0, 253402271999.999999]
corresponding to dates from 1970-01-01 00:00:00 to 9999-12-31 23:59:59.999999,
unix_timestamp outside this range will return an error
- If string_format is invalid, returns a string that does not meet
expectations.
- If any parameter is NULL, returns NULL
- If the format length is over 128 characters, returns error
@@ -95,6 +95,30 @@ mysql> select from_unixtime(32536799,"gdaskpdp");
| gdaskpdp |
+------------------------------------+
+---Fractional timestamp input, result includes sub-second precision
+mysql> select from_unixtime(1196440219.5);
++-----------------------------+
+| from_unixtime(1196440219.5) |
++-----------------------------+
+| 2007-12-01 00:30:19.500000 |
++-----------------------------+
+
+---Fractional timestamp with microsecond precision
+mysql> select from_unixtime(1196440219.123456);
++----------------------------------+
+| from_unixtime(1196440219.123456) |
++----------------------------------+
+| 2007-12-01 00:30:19.123456 |
++----------------------------------+
+
+---Use %f format specifier to display microseconds explicitly
+mysql> select from_unixtime(1196440219.123456, '%Y-%m-%d %H:%i:%s.%f');
++----------------------------------------------------------+
+| from_unixtime(1196440219.123456, '%Y-%m-%d %H:%i:%s.%f') |
++----------------------------------------------------------+
+| 2007-12-01 00:30:19.123456 |
++----------------------------------------------------------+
+
---Input is NULL, returns NULL
mysql> select from_unixtime(NULL);
+---------------------+
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
index 3a79fd88055..0bd3ad44f15 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
@@ -8,7 +8,7 @@
## 描述
-FROM_UNIXTIME 函数用于将 Unix 时间戳(以秒为单位) 转换为指定格式的日期时间字符串或 VARCHAR 类型值。Unix
时间戳的基准时间为 1970-01-01 00:00:00 UTC,函数会根据输入的时间戳和格式字符串,生成对应的日期时间表示。
+FROM_UNIXTIME 函数用于将 Unix 时间戳(以秒为单位) 转换为指定格式的日期时间字符串或 VARCHAR 类型值。Unix
时间戳的基准时间为 1970-01-01 00:00:00
UTC,函数会根据输入的时间戳和格式字符串,生成对应的日期时间表示。当输入的时间戳包含小数部分时,结果将包含最多微秒精度(6 位小数)的亚秒部分。
该函数与 mysql 中的 [from_unixtime
函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_from-unixtime)
行为一致
@@ -22,13 +22,13 @@ FROM_UNIXTIME(<unix_timestamp> [, <string_format>])
| 参数 | 说明 |
| -- | -- |
-| `<unix_timestamp>` | 输入的 Unix 时间戳,类型为整数 BIGINT,表示从 1970-01-01 00:00:00 UTC
开始的秒数 |
+| `<unix_timestamp>` | 输入的 Unix 时间戳,类型为 BIGINT 或 DECIMAL,表示从 1970-01-01
00:00:00 UTC 开始的秒数(可包含小数秒) |
| `<string_format>` | format 格式,支持类型 varchar 和 string,默认为 %Y-%m-%d
%H:%i:%s,具体格式请查看 [date-format](./date-format)|
## 返回值
-返回指定格式的日期,类型为 VARCHAR,返回的是 UTC 时区下的时间戳的时间戳转换为当前时区的时间。
-- 目前支持的 unix_timestamp 范围为 [0,253402271999] 对应日期为 1970-01-01 00:00:00 至
9999-12-31 23:59:59,超出范围的 unix_timestamp 将返回错误
+返回指定格式的日期,类型为 VARCHAR,返回的是 UTC 时区下的时间戳转换为当前时区的时间。当输入包含小数部分时,结果包含亚秒精度(如
`2007-12-01 00:30:19.500000`)。
+- 目前支持的 unix_timestamp 范围为 [0,253402271999.999999] 对应日期为 1970-01-01 00:00:00 至
9999-12-31 23:59:59.999999,超出范围的 unix_timestamp 将返回错误
- 若 string_format 格式无效,返回不符合预期的字符串。
- 若任意参数为 NULL,则返回 NULL
- 如果 string_format 超过 128 字符长度,返回错误
@@ -93,6 +93,30 @@ mysql> select from_unixtime(32536799,"gdaskpdp");
| gdaskpdp |
+------------------------------------+
+---小数时间戳输入,结果包含亚秒精度
+mysql> select from_unixtime(1196440219.5);
++-----------------------------+
+| from_unixtime(1196440219.5) |
++-----------------------------+
+| 2007-12-01 00:30:19.500000 |
++-----------------------------+
+
+---小数时间戳,微秒精度
+mysql> select from_unixtime(1196440219.123456);
++----------------------------------+
+| from_unixtime(1196440219.123456) |
++----------------------------------+
+| 2007-12-01 00:30:19.123456 |
++----------------------------------+
+
+---使用 %f 格式符显式输出微秒部分
+mysql> select from_unixtime(1196440219.123456, '%Y-%m-%d %H:%i:%s.%f');
++----------------------------------------------------------+
+| from_unixtime(1196440219.123456, '%Y-%m-%d %H:%i:%s.%f') |
++----------------------------------------------------------+
+| 2007-12-01 00:30:19.123456 |
++----------------------------------------------------------+
+
---输入为 NULL,返回 NULL
mysql> select from_unixtime(NULL);
+---------------------+
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
index 3a79fd88055..0bd3ad44f15 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
@@ -8,7 +8,7 @@
## 描述
-FROM_UNIXTIME 函数用于将 Unix 时间戳(以秒为单位) 转换为指定格式的日期时间字符串或 VARCHAR 类型值。Unix
时间戳的基准时间为 1970-01-01 00:00:00 UTC,函数会根据输入的时间戳和格式字符串,生成对应的日期时间表示。
+FROM_UNIXTIME 函数用于将 Unix 时间戳(以秒为单位) 转换为指定格式的日期时间字符串或 VARCHAR 类型值。Unix
时间戳的基准时间为 1970-01-01 00:00:00
UTC,函数会根据输入的时间戳和格式字符串,生成对应的日期时间表示。当输入的时间戳包含小数部分时,结果将包含最多微秒精度(6 位小数)的亚秒部分。
该函数与 mysql 中的 [from_unixtime
函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_from-unixtime)
行为一致
@@ -22,13 +22,13 @@ FROM_UNIXTIME(<unix_timestamp> [, <string_format>])
| 参数 | 说明 |
| -- | -- |
-| `<unix_timestamp>` | 输入的 Unix 时间戳,类型为整数 BIGINT,表示从 1970-01-01 00:00:00 UTC
开始的秒数 |
+| `<unix_timestamp>` | 输入的 Unix 时间戳,类型为 BIGINT 或 DECIMAL,表示从 1970-01-01
00:00:00 UTC 开始的秒数(可包含小数秒) |
| `<string_format>` | format 格式,支持类型 varchar 和 string,默认为 %Y-%m-%d
%H:%i:%s,具体格式请查看 [date-format](./date-format)|
## 返回值
-返回指定格式的日期,类型为 VARCHAR,返回的是 UTC 时区下的时间戳的时间戳转换为当前时区的时间。
-- 目前支持的 unix_timestamp 范围为 [0,253402271999] 对应日期为 1970-01-01 00:00:00 至
9999-12-31 23:59:59,超出范围的 unix_timestamp 将返回错误
+返回指定格式的日期,类型为 VARCHAR,返回的是 UTC 时区下的时间戳转换为当前时区的时间。当输入包含小数部分时,结果包含亚秒精度(如
`2007-12-01 00:30:19.500000`)。
+- 目前支持的 unix_timestamp 范围为 [0,253402271999.999999] 对应日期为 1970-01-01 00:00:00 至
9999-12-31 23:59:59.999999,超出范围的 unix_timestamp 将返回错误
- 若 string_format 格式无效,返回不符合预期的字符串。
- 若任意参数为 NULL,则返回 NULL
- 如果 string_format 超过 128 字符长度,返回错误
@@ -93,6 +93,30 @@ mysql> select from_unixtime(32536799,"gdaskpdp");
| gdaskpdp |
+------------------------------------+
+---小数时间戳输入,结果包含亚秒精度
+mysql> select from_unixtime(1196440219.5);
++-----------------------------+
+| from_unixtime(1196440219.5) |
++-----------------------------+
+| 2007-12-01 00:30:19.500000 |
++-----------------------------+
+
+---小数时间戳,微秒精度
+mysql> select from_unixtime(1196440219.123456);
++----------------------------------+
+| from_unixtime(1196440219.123456) |
++----------------------------------+
+| 2007-12-01 00:30:19.123456 |
++----------------------------------+
+
+---使用 %f 格式符显式输出微秒部分
+mysql> select from_unixtime(1196440219.123456, '%Y-%m-%d %H:%i:%s.%f');
++----------------------------------------------------------+
+| from_unixtime(1196440219.123456, '%Y-%m-%d %H:%i:%s.%f') |
++----------------------------------------------------------+
+| 2007-12-01 00:30:19.123456 |
++----------------------------------------------------------+
+
---输入为 NULL,返回 NULL
mysql> select from_unixtime(NULL);
+---------------------+
diff --git
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
index 72600e63bae..df94554f49f 100644
---
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/from-unixtime.md
@@ -9,7 +9,7 @@
## Description
-The FROM_UNIXTIME function is used to convert a Unix timestamp (in seconds) to
a date-time string or VARCHAR type value in a specified format. The reference
time for Unix timestamps is 1970-01-01 00:00:00 UTC, and the function generates
the corresponding date-time representation based on the input timestamp and
format string.
+The FROM_UNIXTIME function is used to convert a Unix timestamp (in seconds) to
a date-time string or VARCHAR type value in a specified format. The reference
time for Unix timestamps is 1970-01-01 00:00:00 UTC, and the function generates
the corresponding date-time representation based on the input timestamp and
format string. When the input timestamp contains a fractional part, the result
includes sub-second precision up to microseconds (6 decimal places).
This function is consistent with the [from_unixtime
function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_from-unixtime)
in MySQL.
@@ -23,13 +23,13 @@ FROM_UNIXTIME(<unix_timestamp> [, <string_format>])
| Parameter | Description |
| -- | -- |
-| `<unix_timestamp>` | Input Unix timestamp, of integer type BIGINT,
representing the number of seconds from 1970-01-01 00:00:00 UTC |
+| `<unix_timestamp>` | Input Unix timestamp, of type BIGINT or DECIMAL,
representing the number of seconds (with optional fractional seconds) from
1970-01-01 00:00:00 UTC |
| `<string_format>` | Format string, supports varchar and string types,
default is %Y-%m-%d %H:%i:%s. For specific formats, please refer to
[date-format](./date-format) |
## Return Value
-Returns date in specified format, of type VARCHAR, returning the result of
converting the UTC timezone unix timestamp to the current timezone time.
-- Currently supported unix_timestamp range is [0, 253402271999] corresponding
to dates from 1970-01-01 00:00:00 to 9999-12-31 23:59:59, unix_timestamp
outside this range will return an error
+Returns date in specified format, of type VARCHAR, returning the result of
converting the UTC timezone unix timestamp to the current timezone time. When
the input contains a fractional part, the result includes sub-second precision
(e.g., `2007-12-01 00:30:19.500000`).
+- Currently supported unix_timestamp range is [0, 253402271999.999999]
corresponding to dates from 1970-01-01 00:00:00 to 9999-12-31 23:59:59.999999,
unix_timestamp outside this range will return an error
- If string_format is invalid, returns a string that does not meet
expectations.
- If any parameter is NULL, returns NULL
- If the format length is over 128 characters, returns error
@@ -95,6 +95,30 @@ mysql> select from_unixtime(32536799,"gdaskpdp");
| gdaskpdp |
+------------------------------------+
+---Fractional timestamp input, result includes sub-second precision
+mysql> select from_unixtime(1196440219.5);
++-----------------------------+
+| from_unixtime(1196440219.5) |
++-----------------------------+
+| 2007-12-01 00:30:19.500000 |
++-----------------------------+
+
+---Fractional timestamp with microsecond precision
+mysql> select from_unixtime(1196440219.123456);
++----------------------------------+
+| from_unixtime(1196440219.123456) |
++----------------------------------+
+| 2007-12-01 00:30:19.123456 |
++----------------------------------+
+
+---Use %f format specifier to display microseconds explicitly
+mysql> select from_unixtime(1196440219.123456, '%Y-%m-%d %H:%i:%s.%f');
++----------------------------------------------------------+
+| from_unixtime(1196440219.123456, '%Y-%m-%d %H:%i:%s.%f') |
++----------------------------------------------------------+
+| 2007-12-01 00:30:19.123456 |
++----------------------------------------------------------+
+
---Input is NULL, returns NULL
mysql> select from_unixtime(NULL);
+---------------------+
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]