mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Fixed error; added test [#CLICKHOUSE-3764]
This commit is contained in:
parent
f71eb36719
commit
8901414ad2
@ -67,9 +67,9 @@ String ColumnsDescription::toString() const
|
||||
{
|
||||
WriteBufferFromOwnString buf;
|
||||
|
||||
writeString("columns format version: 1\n", buf);
|
||||
writeCString("columns format version: 1\n", buf);
|
||||
writeText(ordinary.size() + materialized.size() + aliases.size(), buf);
|
||||
writeString(" columns:\n", buf);
|
||||
writeCString(" columns:\n", buf);
|
||||
|
||||
const auto write_columns = [this, &buf] (const NamesAndTypesList & columns)
|
||||
{
|
||||
@ -79,7 +79,7 @@ String ColumnsDescription::toString() const
|
||||
|
||||
writeBackQuotedString(column.name, buf);
|
||||
writeChar(' ', buf);
|
||||
writeString(column.type->getName(), buf);
|
||||
writeText(column.type->getName(), buf);
|
||||
if (it == std::end(defaults))
|
||||
{
|
||||
writeChar('\n', buf);
|
||||
@ -88,9 +88,9 @@ String ColumnsDescription::toString() const
|
||||
else
|
||||
writeChar('\t', buf);
|
||||
|
||||
writeString(DB::toString(it->second.kind), buf);
|
||||
writeText(DB::toString(it->second.kind), buf);
|
||||
writeChar('\t', buf);
|
||||
writeString(queryToString(it->second.expression), buf);
|
||||
writeText(queryToString(it->second.expression), buf);
|
||||
writeChar('\n', buf);
|
||||
}
|
||||
};
|
||||
@ -123,7 +123,7 @@ ColumnsDescription ColumnsDescription::parse(const String & str)
|
||||
assertChar(' ', buf);
|
||||
|
||||
String type_name;
|
||||
readString(type_name, buf);
|
||||
readText(type_name, buf);
|
||||
auto type = data_type_factory.get(type_name);
|
||||
if (*buf.position() == '\n')
|
||||
{
|
||||
@ -135,7 +135,7 @@ ColumnsDescription ColumnsDescription::parse(const String & str)
|
||||
assertChar('\t', buf);
|
||||
|
||||
String default_kind_str;
|
||||
readString(default_kind_str, buf);
|
||||
readText(default_kind_str, buf);
|
||||
const auto default_kind = columnDefaultKindFromString(default_kind_str);
|
||||
assertChar('\t', buf);
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
CREATE TABLE test.cast1 ( x UInt8, e Enum8('hello' = 1, 'world' = 2) DEFAULT CAST(x, 'Enum8(\'hello\' = 1, \'world\' = 2)')) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_cast', 'r1') ORDER BY e SETTINGS index_granularity = 8192
|
||||
x UInt8
|
||||
e Enum8(\'hello\' = 1, \'world\' = 2) DEFAULT CAST(x, \'Enum8(\\\'hello\\\' = 1, \\\'world\\\' = 2)\')
|
||||
1 hello
|
||||
1 hello
|
38
dbms/tests/queries/0_stateless/00643_cast_zookeeper.sql
Normal file
38
dbms/tests/queries/0_stateless/00643_cast_zookeeper.sql
Normal file
@ -0,0 +1,38 @@
|
||||
DROP TABLE IF EXISTS test.cast1;
|
||||
DROP TABLE IF EXISTS test.cast2;
|
||||
|
||||
CREATE TABLE test.cast1
|
||||
(
|
||||
x UInt8,
|
||||
e Enum8
|
||||
(
|
||||
'hello' = 1,
|
||||
'world' = 2
|
||||
)
|
||||
DEFAULT
|
||||
CAST
|
||||
(
|
||||
x
|
||||
AS
|
||||
Enum8
|
||||
(
|
||||
'hello' = 1,
|
||||
'world' = 2
|
||||
)
|
||||
)
|
||||
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_cast', 'r1') ORDER BY e;
|
||||
|
||||
SHOW CREATE TABLE test.cast1 FORMAT TSVRaw;
|
||||
DESC TABLE test.cast1;
|
||||
|
||||
INSERT INTO test.cast1 (x) VALUES (1);
|
||||
SELECT * FROM test.cast1;
|
||||
|
||||
CREATE TABLE test.cast2 AS test.cast1 ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_cast', 'r2') ORDER BY e;
|
||||
|
||||
SYSTEM SYNC REPLICA test.cast2;
|
||||
|
||||
SELECT * FROM test.cast2;
|
||||
|
||||
DROP TABLE test.cast1;
|
||||
DROP TABLE test.cast2;
|
Loading…
Reference in New Issue
Block a user