Updated the tests for better debugging.

This commit is contained in:
Vasily Nemkov 2019-10-08 07:57:31 +03:00
parent 77ac67eba8
commit f1afc98e0c
3 changed files with 20 additions and 16 deletions

View File

@ -7,11 +7,15 @@ SELECT CAST(1 as DateTime64(100)); -- { serverError 69 } # too big scale
SELECT CAST(1 as DateTime64(-1)); -- { serverError 43 } # signed scale parameter type
SELECT CAST(1 as DateTime64(3, 'qqq')); -- { serverError 1000 } # invalid timezone
SELECT ignore(now64());
CREATE TABLE A(t DateTime64(3, 'UTC')) ENGINE = MergeTree() ORDER BY t;
INSERT INTO A(t) VALUES (1556879125123456789), ('2019-05-03 11:25:25.123456789'), (now64(3)), (now64(6)), (now64(0));
INSERT INTO A(t) VALUES (1556879125123456789), ('2019-05-03 11:25:25.123456789');
SELECT toString(t, 'UTC'), toDate(t), toStartOfDay(t), toStartOfQuarter(t), toTime(t), toStartOfMinute(t) FROM A ORDER BY t;
INSERT INTO A(t) VALUES (now64(3)), (now64(6)), (now64(0));
DROP TABLE A;
-- issue toDate does a reinterpret_cast of the datetime64 which is incorrect
-- for the example above, it returns 2036-08-23 which is 0x5F15 days after epoch

View File

@ -98,7 +98,7 @@ extra_ops =\
[
'- ', # does not work, but should it?
'+ ', # does not work, but should it?
'!=', '==', # how do we expect this to work?
'!=', '==', # equality and inequality supposed to take sub-second part in account
'< ',
'<=',
'> ',
@ -116,7 +116,7 @@ extra_ops =\
'op':
[
'-', # does not work, but should it?
'!=', '==', # how do we expect this to work?
'!=', '==',
# these are naturally expected to work, but they don't:
'< ',
'<=',
@ -158,8 +158,8 @@ extra_ops =\
# Expand extra_ops here
for funcs, args in extra_ops:
args_keys = args.keys()
for func in funcs:
for args_vals in itertools.product(*args.values()):
for func in funcs:
result_func = func.format(**dict(zip(args_keys, args_vals)))
functions.append(result_func)
@ -177,11 +177,11 @@ def escape_string(s):
# TODO: use string.Template here to allow lines that do not contain type, like: SELECT CAST(toDateTime64(1234567890), 'DateTime64')
for func in functions:
for dt in datetime64_args:
f32 = func.format(datetime='now()')
f64 = func.format(datetime=dt)
f = "({f32}) == ({f64})".format(f32=f32, f64=f64)
print("""SELECT '{f64}';""".format(f64=escape_string(f64)))
print("""SELECT {f32};""".format(f32=f32))
print("""SELECT {f64};""".format(f64=f64))
# print("""SELECT {f};""".format(f=f))
print("""SELECT '-----------------------------------------------------------------------------------';""")
dt32 = func.format(datetime='now()')
dt64 = func.format(datetime=dt)
f = "'values match:', ({dt32}) == ({dt64}), 'types match:', toTypeName({dt32}) == toTypeName({dt64})".format(dt32=dt32, dt64=dt64)
print("""SELECT 'SELECT {dt64}';""".format(dt64=escape_string(dt64))) # for debug only
print("""SELECT toTypeName({dt32}), {dt32};""".format(dt32=dt32)) # for debug only
print("""SELECT toTypeName({dt64}), {dt64};""".format(dt64=dt64)) # for debug only
print("""SELECT {f};""".format(f=f))
print("""SELECT '------------------------------------------';""") # for debug only

View File

@ -1,8 +1,8 @@
#!/usr/bin/env bash
# We should have correct env vars from shell_config.sh to run this test
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
# We should have correct env vars from shell_config.sh to run this test
python $CURDIR/00921_datetime64_compatibility.python | ${CLICKHOUSE_CLIENT} -nm
# in order to check queries individually (does not stop on the first one that fails):
IFS=$'\n'; for I in $($CURDIR/00921_datetime64_compatibility.python) ; do "${CLICKHOUSE_CLIENT}" -nm -q "$I"; echo ; done # 2>&1 | tee datetime64_compat.log