From 66501c80266533ca148e76e50924631f43692b56 Mon Sep 17 00:00:00 2001 From: Alexey Zatelepin Date: Thu, 9 Feb 2017 21:42:27 +0300 Subject: [PATCH] ALTER primary key tests [#CLICKHOUSE-2027] --- .../00427_alter_primary_key.reference | 4 +++ .../0_stateless/00427_alter_primary_key.sh | 33 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00427_alter_primary_key.reference create mode 100755 dbms/tests/queries/0_stateless/00427_alter_primary_key.sh diff --git a/dbms/tests/queries/0_stateless/00427_alter_primary_key.reference b/dbms/tests/queries/0_stateless/00427_alter_primary_key.reference new file mode 100644 index 00000000000..dc092bd7600 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00427_alter_primary_key.reference @@ -0,0 +1,4 @@ +query failed +query failed +foo 1486598400 1 +bar 1486598400 1 diff --git a/dbms/tests/queries/0_stateless/00427_alter_primary_key.sh b/dbms/tests/queries/0_stateless/00427_alter_primary_key.sh new file mode 100755 index 00000000000..2046aa97199 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00427_alter_primary_key.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +function perform() +{ + local query=$1 + TZ=UTC clickhouse-client \ + --use_client_time_zone=1 \ + --input_format_values_interpret_expressions=0 \ + --query "$query" 2>/dev/null + if [ "$?" -ne 0 ]; then + echo "query failed" + fi +} + +perform "DROP TABLE IF EXISTS test.alter" +perform "CREATE TABLE test.alter (d Date, a Enum8('foo'=1), b DateTime, c DateTime) ENGINE=MergeTree(d, (a, b, toTime(c)), 8192)" + +perform "INSERT INTO test.alter VALUES ('2017-02-09', 'foo', '2017-02-09 00:00:00', '2017-02-09 00:00:00')" + +# Must fail because d is used as as a date column in MergeTree +perform "ALTER TABLE test.alter MODIFY COLUMN d UInt16" + +perform "ALTER TABLE test.alter MODIFY COLUMN a Enum8('foo'=1, 'bar'=2)" +perform "ALTER TABLE test.alter MODIFY COLUMN b UInt32" + +# Must fail because column c is used in primary key via an expression. +perform "ALTER TABLE test.alter MODIFY COLUMN c UInt32" + +perform "INSERT INTO test.alter VALUES ('2017-02-09', 'bar', 1486598400, '2017-02-09 00:00:00')" + +perform "SELECT a, b, b = toUnixTimestamp(c) FROM test.alter ORDER BY a FORMAT TSV" + +perform "DROP TABLE test.alter"