fixed couple of mistakes.

This commit is contained in:
Sabyanin Maxim 2018-11-12 18:45:35 +03:00
parent f8f2779f7b
commit b869cfed9a
17 changed files with 176 additions and 188 deletions

View File

@ -45,7 +45,6 @@ Block InterpreterDescribeQuery::getSampleBlock()
col.name = "default_expression";
block.insert(col);
// TODO: may be it unneeded
col.name = "comment_expression";
block.insert(col);

View File

@ -143,7 +143,7 @@ void ASTAlterCommand::formatImpl(
}
else if (type == ASTAlterCommand::COMMENT_COLUMN)
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << "COMMENT COLUMN " << (settings.hilite ? hilite_identifier : "");
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << "COMMENT COLUMN " << (settings.hilite ? hilite_none : "");
column->formatImpl(settings, state, frame);
settings.ostr << " " << (settings.hilite ? hilite_none : "");
comment->formatImpl(settings, state, frame);

View File

@ -65,7 +65,7 @@ public:
if (comment)
{
settings.ostr << ' ' << (settings.hilite ? hilite_keyword : "") << "COMMENT " << (settings.hilite ? hilite_none : "") << ' ';
settings.ostr << ' ' << (settings.hilite ? hilite_keyword : "") << "COMMENT" << (settings.hilite ? hilite_none : "") << ' ';
comment->formatImpl(settings, state, frame);
}
}

View File

@ -1,13 +0,0 @@
#pragma once
#include <Core/Types.h>
#include <string>
#include <unordered_map>
namespace DB
{
using ColumnComments = std::unordered_map<std::string, String>;
}

View File

@ -2,7 +2,6 @@
#include <Core/NamesAndTypes.h>
#include <Core/Names.h>
#include <Storages/ColumnComment.h>
#include <Storages/ColumnDefault.h>
#include <Core/Block.h>
@ -10,6 +9,8 @@
namespace DB
{
using ColumnComments = std::unordered_map<std::string, String>;
struct ColumnsDescription
{
NamesAndTypesList ordinary;
@ -24,8 +25,8 @@ struct ColumnsDescription
NamesAndTypesList ordinary_,
NamesAndTypesList materialized_,
NamesAndTypesList aliases_,
ColumnDefaults defaults_ = {},
ColumnComments comments_ = {})
ColumnDefaults defaults_,
ColumnComments comments_)
: ordinary(std::move(ordinary_))
, materialized(std::move(materialized_))
, aliases(std::move(aliases_))

View File

@ -1,3 +1,4 @@
#include <Storages/ColumnsDescription.h>
#include <Storages/System/StorageSystemPartsBase.h>
#include <Common/escapeForFileName.h>
#include <Columns/ColumnString.h>
@ -306,7 +307,7 @@ StorageSystemPartsBase::StorageSystemPartsBase(std::string name_, NamesAndTypesL
add_alias("bytes", "bytes_on_disk");
add_alias("marks_size", "marks_bytes");
setColumns(ColumnsDescription(std::move(columns_), {}, std::move(aliases), std::move(defaults)));
setColumns(ColumnsDescription(std::move(columns_), {}, std::move(aliases), std::move(defaults), ColumnComments{}));
}
}

View File

@ -1,27 +1,27 @@
CounterID UInt32
StartDate Date
UserID UInt32
VisitID UInt32
NestedColumn.A Array(UInt8)
NestedColumn.S Array(String)
ToDrop UInt32
Added0 UInt32
Added1 UInt32
Added2 UInt32
AddedNested1.A Array(UInt32)
AddedNested1.B Array(UInt64)
AddedNested1.C Array(String)
AddedNested2.A Array(UInt32)
AddedNested2.B Array(UInt64)
CounterID UInt32
StartDate Date
UserID UInt32
VisitID UInt32
Added0 String
Added1 UInt32
Added2 UInt32
AddedNested1.A Array(UInt32)
AddedNested1.C Array(String)
AddedNested2.A Array(UInt32)
AddedNested2.B Array(UInt64)
CounterID UInt32
StartDate Date
UserID UInt32
VisitID UInt32
NestedColumn.A Array(UInt8)
NestedColumn.S Array(String)
ToDrop UInt32
Added0 UInt32
Added1 UInt32
Added2 UInt32
AddedNested1.A Array(UInt32)
AddedNested1.B Array(UInt64)
AddedNested1.C Array(String)
AddedNested2.A Array(UInt32)
AddedNested2.B Array(UInt64)
CounterID UInt32
StartDate Date
UserID UInt32
VisitID UInt32
Added0 String
Added1 UInt32
Added2 UInt32
AddedNested1.A Array(UInt32)
AddedNested1.C Array(String)
AddedNested2.A Array(UInt32)
AddedNested2.B Array(UInt64)
1 2014-01-01 2 3 0 0 [] [] [] []

View File

@ -1,56 +1,56 @@
d Date
k UInt64
i32 Int32
d Date
k UInt64
i32 Int32
CREATE TABLE test.alter ( d Date, k UInt64, i32 Int32) ENGINE = MergeTree(d, k, 8192)
2015-01-01 10 42
d Date
k UInt64
i32 Int32
n.ui8 Array(UInt8)
n.s Array(String)
d Date
k UInt64
i32 Int32
n.ui8 Array(UInt8)
n.s Array(String)
CREATE TABLE test.alter ( d Date, k UInt64, i32 Int32, `n.ui8` Array(UInt8), `n.s` Array(String)) ENGINE = MergeTree(d, k, 8192)
2015-01-01 8 40 [1,2,3] ['12','13','14']
2015-01-01 10 42 [] []
d Date
k UInt64
i32 Int32
n.ui8 Array(UInt8)
n.s Array(String)
n.d Array(Date)
d Date
k UInt64
i32 Int32
n.ui8 Array(UInt8)
n.s Array(String)
n.d Array(Date)
CREATE TABLE test.alter ( d Date, k UInt64, i32 Int32, `n.ui8` Array(UInt8), `n.s` Array(String), `n.d` Array(Date)) ENGINE = MergeTree(d, k, 8192)
2015-01-01 7 39 [10,20,30] ['120','130','140'] ['2000-01-01','2000-01-01','2000-01-03']
2015-01-01 8 40 [1,2,3] ['12','13','14'] ['0000-00-00','0000-00-00','0000-00-00']
2015-01-01 10 42 [] [] []
d Date
k UInt64
i32 Int32
n.ui8 Array(UInt8)
n.s Array(String)
n.d Array(Date)
s String DEFAULT \'0\'
d Date
k UInt64
i32 Int32
n.ui8 Array(UInt8)
n.s Array(String)
n.d Array(Date)
s String DEFAULT \'0\'
CREATE TABLE test.alter ( d Date, k UInt64, i32 Int32, `n.ui8` Array(UInt8), `n.s` Array(String), `n.d` Array(Date), s String DEFAULT \'0\') ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 [10,20,30] ['asd','qwe','qwe'] ['2000-01-01','2000-01-01','2000-01-03'] 100500
2015-01-01 7 39 [10,20,30] ['120','130','140'] ['2000-01-01','2000-01-01','2000-01-03'] 0
2015-01-01 8 40 [1,2,3] ['12','13','14'] ['0000-00-00','0000-00-00','0000-00-00'] 0
2015-01-01 10 42 [] [] [] 0
d Date
k UInt64
i32 Int32
n.ui8 Array(UInt8)
n.s Array(String)
s Int64
d Date
k UInt64
i32 Int32
n.ui8 Array(UInt8)
n.s Array(String)
s Int64
CREATE TABLE test.alter ( d Date, k UInt64, i32 Int32, `n.ui8` Array(UInt8), `n.s` Array(String), s Int64) ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 [10,20,30] ['asd','qwe','qwe'] 100500
2015-01-01 7 39 [10,20,30] ['120','130','140'] 0
2015-01-01 8 40 [1,2,3] ['12','13','14'] 0
2015-01-01 10 42 [] [] 0
d Date
k UInt64
i32 Int32
n.ui8 Array(UInt8)
n.s Array(String)
s UInt32
n.d Array(Date)
d Date
k UInt64
i32 Int32
n.ui8 Array(UInt8)
n.s Array(String)
s UInt32
n.d Array(Date)
CREATE TABLE test.alter ( d Date, k UInt64, i32 Int32, `n.ui8` Array(UInt8), `n.s` Array(String), s UInt32, `n.d` Array(Date)) ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 [10,20,30] ['asd','qwe','qwe'] 100500 ['0000-00-00','0000-00-00','0000-00-00']
2015-01-01 7 39 [10,20,30] ['120','130','140'] 0 ['0000-00-00','0000-00-00','0000-00-00']
@ -60,40 +60,40 @@ CREATE TABLE test.alter ( d Date, k UInt64, i32 Int32, `n.ui8` Array(UInt8),
2015-01-01 7 39 [10,20,30] ['120','130','140'] 0 ['0000-00-00','0000-00-00','0000-00-00']
2015-01-01 8 40 [1,2,3] ['12','13','14'] 0 ['0000-00-00','0000-00-00','0000-00-00']
2015-01-01 10 42 [] [] 0 []
d Date
k UInt64
i32 Int32
n.s Array(String)
s UInt32
d Date
k UInt64
i32 Int32
n.s Array(String)
s UInt32
CREATE TABLE test.alter ( d Date, k UInt64, i32 Int32, `n.s` Array(String), s UInt32) ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 ['asd','qwe','qwe'] 100500
2015-01-01 7 39 ['120','130','140'] 0
2015-01-01 8 40 ['12','13','14'] 0
2015-01-01 10 42 [] 0
d Date
k UInt64
i32 Int32
s UInt32
d Date
k UInt64
i32 Int32
s UInt32
CREATE TABLE test.alter ( d Date, k UInt64, i32 Int32, s UInt32) ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 100500
2015-01-01 7 39 0
2015-01-01 8 40 0
2015-01-01 10 42 0
d Date
k UInt64
i32 Int32
s UInt32
n.s Array(String)
n.d Array(Date)
d Date
k UInt64
i32 Int32
s UInt32
n.s Array(String)
n.d Array(Date)
CREATE TABLE test.alter ( d Date, k UInt64, i32 Int32, s UInt32, `n.s` Array(String), `n.d` Array(Date)) ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 100500 [] []
2015-01-01 7 39 0 [] []
2015-01-01 8 40 0 [] []
2015-01-01 10 42 0 [] []
d Date
k UInt64
i32 Int32
s UInt32
d Date
k UInt64
i32 Int32
s UInt32
CREATE TABLE test.alter ( d Date, k UInt64, i32 Int32, s UInt32) ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 100500
2015-01-01 7 39 0

View File

@ -1,42 +1,42 @@
col1 UInt8 DEFAULT 0
col1 UInt32
col2 UInt64 DEFAULT col1 + 1
col3 UInt64 MATERIALIZED col1 + 2
col4 UInt64 ALIAS col1 + 3
col1 UInt8 DEFAULT 0
col1 UInt32
col2 UInt64 DEFAULT col1 + 1
col3 UInt64 MATERIALIZED col1 + 2
col4 UInt64 ALIAS col1 + 3
10 11
12 13
99
payload String
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
payload String
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
hello clickhouse
payload String
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
payload_length UInt64 MATERIALIZED length(payload)
payload String
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
payload_length UInt64 MATERIALIZED length(payload)
hello clickhouse 16
hello clickhouse 16
some string 11
hello clickhouse 16
some string 11
payload String
payload_length UInt64 DEFAULT length(payload)
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
payload String
payload_length UInt64 DEFAULT length(payload)
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
hello clickhouse 16
some string 11
payload String
payload_length UInt16 DEFAULT length(payload) % 65535
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
payload String
payload_length UInt16 DEFAULT length(payload) % 65535
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
hello clickhouse 16
some string 11
payload String
payload_length UInt16 DEFAULT CAST(length(payload), \'UInt16\')
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
payload String
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
payload String
payload_length UInt16 DEFAULT CAST(length(payload), \'UInt16\')
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
payload String
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
hello clickhouse
some string

View File

@ -1,9 +1,9 @@
EventDate Date
UTCEventTime DateTime
MoscowEventDate Date DEFAULT toDate(UTCEventTime)
EventDate Date
UTCEventTime DateTime
MoscowEventDate Date DEFAULT toDate(UTCEventTime)
EventDate Date
UTCEventTime DateTime
MoscowEventDate Date DEFAULT toDate(UTCEventTime)
EventDate Date
UTCEventTime DateTime
MoscowEventDate Date DEFAULT toDate(UTCEventTime)
2015-06-09 2015-06-09 01:02:03 2015-06-09
2015-06-09 2015-06-09 01:02:03 2015-06-09
2015-06-09 2015-06-09 01:02:03 2015-06-09

View File

@ -1,28 +1,28 @@
d Date DEFAULT CAST(\'2015-12-29\', \'Date\')
k UInt8 DEFAULT 0
e Enum8(\'hello\' = 1, \'world\' = 2)
sign Enum8(\'minus\' = -1, \'plus\' = 1)
letter Enum16(\'*\' = -256, \'a\' = 0, \'b\' = 1, \'c\' = 2)
d Date DEFAULT CAST(\'2015-12-29\', \'Date\')
k UInt8 DEFAULT 0
e Enum8(\'hello\' = 1, \'world\' = 2)
sign Enum8(\'minus\' = -1, \'plus\' = 1)
letter Enum16(\'*\' = -256, \'a\' = 0, \'b\' = 1, \'c\' = 2)
2015-12-29 0 hello minus *
d Date DEFAULT CAST(\'2015-12-29\', \'Date\')
k UInt8 DEFAULT 0
e Enum8(\'hello\' = 1, \'world\' = 2, \'!\' = 3)
sign Enum8(\'minus\' = -1, \'plus\' = 1)
letter Enum16(\'*\' = -256, \'a\' = 0, \'b\' = 1, \'c\' = 2)
d Date DEFAULT CAST(\'2015-12-29\', \'Date\')
k UInt8 DEFAULT 0
e Enum8(\'hello\' = 1, \'world\' = 2, \'!\' = 3)
sign Enum8(\'minus\' = -1, \'plus\' = 1)
letter Enum16(\'*\' = -256, \'a\' = 0, \'b\' = 1, \'c\' = 2)
2015-12-29 0 hello minus *
2015-12-29 0 ! plus b
d Date DEFAULT CAST(\'2015-12-29\', \'Date\')
k UInt8 DEFAULT 0
e Enum16(\'hello\' = 1, \'world\' = 2, \'!\' = 3)
sign Enum16(\'minus\' = -1, \'plus\' = 1)
letter Enum16(\'no letter\' = -256, \'a\' = 0, \'b\' = 1, \'c\' = 2)
d Date DEFAULT CAST(\'2015-12-29\', \'Date\')
k UInt8 DEFAULT 0
e Enum16(\'hello\' = 1, \'world\' = 2, \'!\' = 3)
sign Enum16(\'minus\' = -1, \'plus\' = 1)
letter Enum16(\'no letter\' = -256, \'a\' = 0, \'b\' = 1, \'c\' = 2)
2015-12-29 0 hello minus no letter
2015-12-29 0 ! plus b
d Date DEFAULT CAST(\'2015-12-29\', \'Date\')
k UInt8 DEFAULT 0
e Enum8(\'hello\' = 1, \'world\' = 2, \'!\' = 3)
sign Enum8(\'minus\' = -1, \'plus\' = 1)
letter Enum16(\'no letter\' = -256, \'a\' = 0, \'b\' = 1, \'c\' = 2)
d Date DEFAULT CAST(\'2015-12-29\', \'Date\')
k UInt8 DEFAULT 0
e Enum8(\'hello\' = 1, \'world\' = 2, \'!\' = 3)
sign Enum8(\'minus\' = -1, \'plus\' = 1)
letter Enum16(\'no letter\' = -256, \'a\' = 0, \'b\' = 1, \'c\' = 2)
2015-12-29 0 hello minus no letter
2015-12-29 0 ! plus b
2015-12-29 0 world minus c

View File

@ -6,7 +6,7 @@ performing test: union_all
performing test: bad_union_all
query failed
performing test: describe_table
dummy UInt8
dummy UInt8
performing test: clickhouse-local
2 3
performing test: http

View File

@ -1,30 +1,30 @@
date Date
val UInt64
val2 UInt8 DEFAULT 42
val3 UInt8 DEFAULT CAST(val2 + 1, \'UInt8\')
val4 UInt64 ALIAS val
date Date
val UInt64
val2 UInt8 DEFAULT 42
val3 UInt8 DEFAULT CAST(val2 + 1, \'UInt8\')
val4 UInt64 ALIAS val
-
date Date
val UInt64
val2 UInt8 DEFAULT 42
val3 UInt8 DEFAULT CAST(val2 + 1, \'UInt8\')
val4 UInt64 ALIAS val
date Date
val UInt64
val2 UInt8 DEFAULT 42
val3 UInt8 DEFAULT CAST(val2 + 1, \'UInt8\')
val4 UInt64 ALIAS val
-
date Date
val UInt64
val2 UInt8 DEFAULT 42
val3 UInt8 DEFAULT CAST(val2 + 1, \'UInt8\')
val4 UInt64 ALIAS val
date Date
val UInt64
val2 UInt8 DEFAULT 42
val3 UInt8 DEFAULT CAST(val2 + 1, \'UInt8\')
val4 UInt64 ALIAS val
-
date Date
val UInt64
val2 UInt8 DEFAULT 42
val3 UInt8 DEFAULT CAST(val2 + 1, \'UInt8\')
val4 UInt64 ALIAS val
date Date
val UInt64
val2 UInt8 DEFAULT 42
val3 UInt8 DEFAULT CAST(val2 + 1, \'UInt8\')
val4 UInt64 ALIAS val
-
1 UInt8
1 UInt8
-
1 UInt8
1 UInt8
-
number UInt64
number UInt64
-

View File

@ -1,3 +1,3 @@
x UInt8
x Int64 DEFAULT toInt64(y)
y String
x UInt8
x Int64 DEFAULT toInt64(y)
y String

View File

@ -8,6 +8,6 @@ hello
hello
1970-01-01 00:00:01
CREATE TABLE test.cast ( x UInt8, e Enum8('hello' = 1, 'world' = 2) DEFAULT CAST(x, 'Enum8(\'hello\' = 1, \'world\' = 2)')) ENGINE = MergeTree ORDER BY e SETTINGS index_granularity = 8192
x UInt8
e Enum8(\'hello\' = 1, \'world\' = 2) DEFAULT CAST(x, \'Enum8(\\\'hello\\\' = 1, \\\'world\\\' = 2)\')
x UInt8
e Enum8(\'hello\' = 1, \'world\' = 2) DEFAULT CAST(x, \'Enum8(\\\'hello\\\' = 1, \\\'world\\\' = 2)\')
1 hello

View File

@ -1,9 +1,9 @@
a Decimal(9, 4) DEFAULT CAST(0, \'Decimal(9, 4)\')
b Decimal(18, 4) DEFAULT CAST(a / 2, \'Decimal(18, 4)\')
c Decimal(38, 4) DEFAULT CAST(b / 3, \'Decimal(38, 4)\')
d Decimal(9, 4) MATERIALIZED a + toDecimal32(\'0.2\', 1)
e Decimal(18, 4) ALIAS b * 2
f Decimal(38, 4) ALIAS c * 6
a Decimal(9, 4) DEFAULT CAST(0, \'Decimal(9, 4)\')
b Decimal(18, 4) DEFAULT CAST(a / 2, \'Decimal(18, 4)\')
c Decimal(38, 4) DEFAULT CAST(b / 3, \'Decimal(38, 4)\')
d Decimal(9, 4) MATERIALIZED a + toDecimal32(\'0.2\', 1)
e Decimal(18, 4) ALIAS b * 2
f Decimal(38, 4) ALIAS c * 6
0.0000 0.0000 0.0000
1.0000 0.5000 0.1666
2.0000 1.0000 0.3333