From f1afc98e0ceda3ad7adf296cd2f87e31a29ed658 Mon Sep 17 00:00:00 2001 From: Vasily Nemkov Date: Tue, 8 Oct 2019 07:57:31 +0300 Subject: [PATCH] Updated the tests for better debugging. --- .../queries/0_stateless/00921_datetime64.sql | 6 ++++- .../00921_datetime64_compatibility.python | 24 +++++++++---------- .../00921_datetime64_compatibility.sh | 6 ++--- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/dbms/tests/queries/0_stateless/00921_datetime64.sql b/dbms/tests/queries/0_stateless/00921_datetime64.sql index 7d94b5fb457..2576a2b1b98 100644 --- a/dbms/tests/queries/0_stateless/00921_datetime64.sql +++ b/dbms/tests/queries/0_stateless/00921_datetime64.sql @@ -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 diff --git a/dbms/tests/queries/0_stateless/00921_datetime64_compatibility.python b/dbms/tests/queries/0_stateless/00921_datetime64_compatibility.python index 409ed472781..0cfbe4f28cb 100755 --- a/dbms/tests/queries/0_stateless/00921_datetime64_compatibility.python +++ b/dbms/tests/queries/0_stateless/00921_datetime64_compatibility.python @@ -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 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 '-----------------------------------------------------------------------------------';""") \ No newline at end of file + 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 \ No newline at end of file diff --git a/dbms/tests/queries/0_stateless/00921_datetime64_compatibility.sh b/dbms/tests/queries/0_stateless/00921_datetime64_compatibility.sh index 1ac0fe8035a..7cacbc2c165 100755 --- a/dbms/tests/queries/0_stateless/00921_datetime64_compatibility.sh +++ b/dbms/tests/queries/0_stateless/00921_datetime64_compatibility.sh @@ -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 \ No newline at end of file +# 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