diff --git a/docs/en/sql-reference/functions/type-conversion-functions.md b/docs/en/sql-reference/functions/type-conversion-functions.md index 5a733f6be23..4f1a2d49d23 100644 --- a/docs/en/sql-reference/functions/type-conversion-functions.md +++ b/docs/en/sql-reference/functions/type-conversion-functions.md @@ -1436,16 +1436,17 @@ dateTimeToSnowflake(value) Query: ``` sql -SELECT dateTimeToSnowflake(CAST('2021-08-15 18:57:56', 'DateTime')); +WITH toDateTime('2021-08-15 18:57:56', 'Asia/Shanghai') AS dt +SELECT dateTimeToSnowflake(dt); ``` Result: ``` text -┌─dateTimeToSnowflake(CAST('2021-08-15 18:57:56', 'DateTime'))─┐ -│ 1426860702823350272 │ -└──────────────────────────────────────────────────────────────┘ +┌─dateTimeToSnowflake(dt)─┐ +│ 1426860702823350272 │ +└─────────────────────────┘ ``` @@ -1473,13 +1474,14 @@ dateTime64ToSnowflake(value) Query: ``` sql -SELECT dateTime64ToSnowflake(CAST('2021-08-15 18:57:56.073', 'DateTime64')); +WITH toDateTime64('2021-08-15 18:57:56.492', 3, 'Asia/Shanghai') AS dt64 +SELECT dateTime64ToSnowflake(dt64); ``` Result: ``` text -┌─dateTime64ToSnowflake(CAST('2021-08-15 18:57:56.073', 'DateTime64'))─┐ -│ 1426860703129534464 │ -└──────────────────────────────────────────────────────────────────────┘ +┌─dateTime64ToSnowflake(dt64)─┐ +│ 1426860704886947840 │ +└─────────────────────────────┘ ``` \ No newline at end of file diff --git a/tests/queries/0_stateless/01942_dateTimeToSnowflake.sql b/tests/queries/0_stateless/01942_dateTimeToSnowflake.sql index e5895db7004..047d8be7be5 100644 --- a/tests/queries/0_stateless/01942_dateTimeToSnowflake.sql +++ b/tests/queries/0_stateless/01942_dateTimeToSnowflake.sql @@ -9,15 +9,15 @@ SELECT dateTimeToSnowflake('abc', 123); -- {serverError 42} SELECT dateTime64ToSnowflake('abc', 123); -- {serverError 42} SELECT 'const column'; -WITH toDateTime('2021-08-15 18:57:56') AS dt +WITH toDateTime('2021-08-15 18:57:56', 'Asia/Shanghai') AS dt SELECT dt, dateTimeToSnowflake(dt); -WITH toDateTime64('2021-08-15 18:57:56.492', 3) AS dt64 +WITH toDateTime64('2021-08-15 18:57:56.492', 3, 'Asia/Shanghai') AS dt64 SELECT dt64, dateTime64ToSnowflake(dt64); SELECT 'non-const column'; -WITH toDateTime('2021-08-15 18:57:56') AS x +WITH toDateTime('2021-08-15 18:57:56', 'Asia/Shanghai') AS x SELECT materialize(x) as dt, dateTimeToSnowflake(dt);; -WITH toDateTime64('2021-08-15 18:57:56.492', 3) AS x +WITH toDateTime64('2021-08-15 18:57:56.492', 3, 'Asia/Shanghai') AS x SELECT materialize(x) as dt64, dateTime64ToSnowflake(dt64);