Fix addDays cause an error when used datetime64 (#61561)

* Fix addDays cause an error when used datetime64

* add exception describe

* Update tests/queries/0_stateless/03013_addDays_with_timezone.sql

* remove file be executable

* fix timezone

* fix ci

---------

Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
This commit is contained in:
Shuai li 2024-03-21 21:47:29 +08:00 committed by GitHub
parent 1944162088
commit 48cb228c9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 18 deletions

View File

@ -621,9 +621,9 @@ public:
}
else
{
if (!WhichDataType(arguments[0].type).isDateTime())
if (!WhichDataType(arguments[0].type).isDateTimeOrDateTime64())
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of first argument of function {}. "
"Must be a DateTime", arguments[0].type->getName(), getName());
"Must be a DateTime/DateTime64", arguments[0].type->getName(), getName());
if (!WhichDataType(arguments[2].type).isString())
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of third argument of function {}. "

View File

@ -241,82 +241,82 @@ SELECT toYYYYMMDDhhmmss(N, \'Asia/Istanbul\')
SELECT addYears(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2020-09-16 19:20:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2020-09-16 19:20:11.234"
------------------------------------------
SELECT addMonths(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-10-16 19:20:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-10-16 19:20:11.234"
------------------------------------------
SELECT addWeeks(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-09-23 19:20:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-09-23 19:20:11.234"
------------------------------------------
SELECT addDays(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-09-17 19:20:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-09-17 19:20:11.234"
------------------------------------------
SELECT addHours(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-09-16 20:20:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-09-16 20:20:11.234"
------------------------------------------
SELECT addMinutes(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-09-16 19:21:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-09-16 19:21:11.234"
------------------------------------------
SELECT addSeconds(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-09-16 19:20:12"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-09-16 19:20:12.234"
------------------------------------------
SELECT addQuarters(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-12-16 19:20:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-12-16 19:20:11.234"
------------------------------------------
SELECT subtractYears(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2018-09-16 19:20:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2018-09-16 19:20:11.234"
------------------------------------------
SELECT subtractMonths(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-08-16 19:20:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-08-16 19:20:11.234"
------------------------------------------
SELECT subtractWeeks(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-09-09 19:20:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-09-09 19:20:11.234"
------------------------------------------
SELECT subtractDays(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-09-15 19:20:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-09-15 19:20:11.234"
------------------------------------------
SELECT subtractHours(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-09-16 18:20:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-09-16 18:20:11.234"
------------------------------------------
SELECT subtractMinutes(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-09-16 19:19:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-09-16 19:19:11.234"
------------------------------------------
SELECT subtractSeconds(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-09-16 19:20:10"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-09-16 19:20:10.234"
------------------------------------------
SELECT subtractQuarters(N, 1, \'Asia/Istanbul\')
Code: 43
"DateTime('Asia/Istanbul')","2019-06-16 19:20:11"
Code: 43
"DateTime64(3, 'Asia/Istanbul')","2019-06-16 19:20:11.234"
------------------------------------------
SELECT CAST(N as DateTime(\'Europe/Minsk\'))
"DateTime('Europe/Minsk')","2019-09-16 00:00:00"

View File

@ -0,0 +1 @@
2024-01-11 00:00:00.000000

View File

@ -0,0 +1 @@
select addDays(toDateTime64('2024-01-01', 6, 'Asia/Shanghai'), 10, 'Asia/Shanghai');