2017-02-09 18:42:27 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2017-12-15 19:34:19 +00:00
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
2020-08-01 00:51:12 +00:00
|
|
|
. "$CURDIR"/../shell_config.sh
|
2017-12-15 19:34:19 +00:00
|
|
|
|
2017-02-09 18:42:27 +00:00
|
|
|
function perform()
|
|
|
|
{
|
2017-04-05 11:52:23 +00:00
|
|
|
local query=$1
|
2017-12-15 19:34:19 +00:00
|
|
|
TZ=UTC $CLICKHOUSE_CLIENT \
|
2017-04-05 11:52:23 +00:00
|
|
|
--use_client_time_zone=1 \
|
|
|
|
--input_format_values_interpret_expressions=0 \
|
|
|
|
--query "$query" 2>/dev/null
|
|
|
|
if [ "$?" -ne 0 ]; then
|
|
|
|
echo "query failed"
|
|
|
|
fi
|
2017-02-09 18:42:27 +00:00
|
|
|
}
|
|
|
|
|
2019-06-03 17:36:27 +00:00
|
|
|
perform "DROP TABLE IF EXISTS alter_00427"
|
|
|
|
perform "CREATE TABLE alter_00427 (d Date, a Enum8('foo'=1), b DateTime, c DateTime) ENGINE=MergeTree(d, (a, b, toTime(c)), 8192)"
|
2017-02-09 18:42:27 +00:00
|
|
|
|
2019-06-03 17:36:27 +00:00
|
|
|
perform "INSERT INTO alter_00427 VALUES ('2017-02-09', 'foo', '2017-02-09 00:00:00', '2017-02-09 00:00:00')"
|
2017-02-09 18:42:27 +00:00
|
|
|
|
|
|
|
# Must fail because d is used as as a date column in MergeTree
|
2019-06-03 17:36:27 +00:00
|
|
|
perform "ALTER TABLE alter_00427 MODIFY COLUMN d UInt16"
|
2017-02-09 18:42:27 +00:00
|
|
|
|
2019-06-03 17:36:27 +00:00
|
|
|
perform "ALTER TABLE alter_00427 MODIFY COLUMN a Enum8('foo'=1, 'bar'=2)"
|
|
|
|
perform "ALTER TABLE alter_00427 MODIFY COLUMN b UInt32"
|
2017-02-09 18:42:27 +00:00
|
|
|
|
|
|
|
# Must fail because column c is used in primary key via an expression.
|
2019-06-03 17:36:27 +00:00
|
|
|
perform "ALTER TABLE alter_00427 MODIFY COLUMN c UInt32"
|
2017-02-09 18:42:27 +00:00
|
|
|
|
2019-06-03 17:36:27 +00:00
|
|
|
perform "INSERT INTO alter_00427 VALUES ('2017-02-09', 'bar', 1486598400, '2017-02-09 00:00:00')"
|
2017-02-09 18:42:27 +00:00
|
|
|
|
2019-06-03 17:36:27 +00:00
|
|
|
perform "SELECT d FROM alter_00427 WHERE a = 'bar'"
|
2017-02-20 18:41:03 +00:00
|
|
|
|
2019-06-03 17:36:27 +00:00
|
|
|
perform "SELECT a, b, b = toUnixTimestamp(c) FROM alter_00427 ORDER BY a FORMAT TSV"
|
2017-02-09 18:42:27 +00:00
|
|
|
|
2019-06-03 17:36:27 +00:00
|
|
|
perform "DROP TABLE alter_00427"
|