Skip to content

Commit db5eb81

Browse files
alexey-milovidovabyss7
authored andcommitted
Merge pull request #9227 from ClickHouse/simplier_alter_prepare
Simplier alter prepare (cherry picked from commit 4433947)
1 parent 4090921 commit db5eb81

16 files changed

+248
-225
lines changed

dbms/src/Interpreters/InterpreterAlterQuery.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ BlockIO InterpreterAlterQuery::execute()
105105
auto table_lock_holder = table->lockAlterIntention(context.getCurrentQueryId());
106106
StorageInMemoryMetadata metadata = table->getInMemoryMetadata();
107107
alter_commands.validate(metadata, context);
108-
alter_commands.prepare(metadata, context);
108+
alter_commands.prepare(metadata);
109109
table->checkAlterIsPossible(alter_commands, context.getSettingsRef());
110110
table->alter(alter_commands, context, table_lock_holder);
111111
}

dbms/src/Interpreters/evaluateMissingDefaults.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <Interpreters/ExpressionActions.h>
88
#include <Parsers/ASTExpressionList.h>
99
#include <Parsers/ASTWithAlias.h>
10+
#include <Parsers/ASTLiteral.h>
11+
#include <Parsers/ASTFunction.h>
1012
#include <utility>
1113
#include <DataTypes/DataTypesNumber.h>
1214

@@ -27,8 +29,10 @@ static ASTPtr requiredExpressions(Block & block, const NamesAndTypesList & requi
2729

2830
/// expressions must be cloned to prevent modification by the ExpressionAnalyzer
2931
if (it != column_defaults.end())
30-
default_expr_list->children.emplace_back(
31-
setAlias(it->second.expression->clone(), it->first));
32+
{
33+
auto cast_func = makeASTFunction("CAST", it->second.expression->clone(), std::make_shared<ASTLiteral>(column.type->getName()));
34+
default_expr_list->children.emplace_back(setAlias(cast_func, it->first));
35+
}
3236
}
3337

3438
if (default_expr_list->children.empty())

dbms/src/Storages/AlterCommands.cpp

Lines changed: 106 additions & 169 deletions
Large diffs are not rendered by default.

dbms/src/Storages/AlterCommands.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <Core/NamesAndTypes.h>
55
#include <Storages/IStorage_fwd.h>
66
#include <Storages/StorageInMemoryMetadata.h>
7-
7+
#include <Storages/ColumnsDescription.h>
88

99
#include <Common/SettingsChanges.h>
1010

@@ -113,16 +113,27 @@ class AlterCommands : public std::vector<AlterCommand>
113113
{
114114
private:
115115
bool prepared = false;
116+
private:
117+
118+
/// Validate that default expression and type are compatible, i.e. default
119+
/// expression result can be casted to column_type
120+
void validateDefaultExpressionForColumn(
121+
const ASTPtr default_expression,
122+
const String & column_name,
123+
const DataTypePtr column_type,
124+
const ColumnsDescription & all_columns,
125+
const Context & context) const;
126+
116127
public:
117128
/// Validate that commands can be applied to metadata.
118129
/// Checks that all columns exist and dependecies between them.
119130
/// This check is lightweight and base only on metadata.
120131
/// More accurate check have to be performed with storage->checkAlterIsPossible.
121132
void validate(const StorageInMemoryMetadata & metadata, const Context & context) const;
122133

123-
/// Prepare alter commands. Set ignore flag to some of them
124-
/// and additional commands for dependent columns.
125-
void prepare(const StorageInMemoryMetadata & metadata, const Context & context);
134+
/// Prepare alter commands. Set ignore flag to some of them and set some
135+
/// parts to commands from storage's metadata (for example, absent default)
136+
void prepare(const StorageInMemoryMetadata & metadata);
126137

127138
/// Apply all alter command in sequential order to storage metadata.
128139
/// Commands have to be prepared before apply.

dbms/tests/queries/0_stateless/00061_merge_tree_alter.reference

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ k UInt64
3838
i32 Int32
3939
n.ui8 Array(UInt8)
4040
n.s Array(String)
41-
s Int64
42-
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.ui8` Array(UInt8), `n.s` Array(String), `s` Int64) ENGINE = MergeTree(d, k, 8192)
41+
s Int64 DEFAULT \'0\'
42+
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.ui8` Array(UInt8), `n.s` Array(String), `s` Int64 DEFAULT \'0\') ENGINE = MergeTree(d, k, 8192)
4343
2015-01-01 6 38 [10,20,30] ['asd','qwe','qwe'] 100500
4444
2015-01-01 7 39 [10,20,30] ['120','130','140'] 0
4545
2015-01-01 8 40 [1,2,3] ['12','13','14'] 0
@@ -49,9 +49,9 @@ k UInt64
4949
i32 Int32
5050
n.ui8 Array(UInt8)
5151
n.s Array(String)
52-
s UInt32
52+
s UInt32 DEFAULT \'0\'
5353
n.d Array(Date)
54-
CREATE TABLE default.alter_00061 (`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)
54+
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.ui8` Array(UInt8), `n.s` Array(String), `s` UInt32 DEFAULT \'0\', `n.d` Array(Date)) ENGINE = MergeTree(d, k, 8192)
5555
2015-01-01 6 38 [10,20,30] ['asd','qwe','qwe'] 100500 ['0000-00-00','0000-00-00','0000-00-00']
5656
2015-01-01 7 39 [10,20,30] ['120','130','140'] 0 ['0000-00-00','0000-00-00','0000-00-00']
5757
2015-01-01 8 40 [1,2,3] ['12','13','14'] 0 ['0000-00-00','0000-00-00','0000-00-00']
@@ -64,37 +64,37 @@ d Date
6464
k UInt64
6565
i32 Int32
6666
n.s Array(String)
67-
s UInt32
68-
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.s` Array(String), `s` UInt32) ENGINE = MergeTree(d, k, 8192)
67+
s UInt32 DEFAULT \'0\'
68+
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.s` Array(String), `s` UInt32 DEFAULT \'0\') ENGINE = MergeTree(d, k, 8192)
6969
2015-01-01 6 38 ['asd','qwe','qwe'] 100500
7070
2015-01-01 7 39 ['120','130','140'] 0
7171
2015-01-01 8 40 ['12','13','14'] 0
7272
2015-01-01 10 42 [] 0
7373
d Date
7474
k UInt64
7575
i32 Int32
76-
s UInt32
77-
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `s` UInt32) ENGINE = MergeTree(d, k, 8192)
76+
s UInt32 DEFAULT \'0\'
77+
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `s` UInt32 DEFAULT \'0\') ENGINE = MergeTree(d, k, 8192)
7878
2015-01-01 6 38 100500
7979
2015-01-01 7 39 0
8080
2015-01-01 8 40 0
8181
2015-01-01 10 42 0
8282
d Date
8383
k UInt64
8484
i32 Int32
85-
s UInt32
85+
s UInt32 DEFAULT \'0\'
8686
n.s Array(String)
8787
n.d Array(Date)
88-
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `s` UInt32, `n.s` Array(String), `n.d` Array(Date)) ENGINE = MergeTree(d, k, 8192)
88+
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `s` UInt32 DEFAULT \'0\', `n.s` Array(String), `n.d` Array(Date)) ENGINE = MergeTree(d, k, 8192)
8989
2015-01-01 6 38 100500 [] []
9090
2015-01-01 7 39 0 [] []
9191
2015-01-01 8 40 0 [] []
9292
2015-01-01 10 42 0 [] []
9393
d Date
9494
k UInt64
9595
i32 Int32
96-
s UInt32
97-
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `s` UInt32) ENGINE = MergeTree(d, k, 8192)
96+
s UInt32 DEFAULT \'0\'
97+
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `s` UInt32 DEFAULT \'0\') ENGINE = MergeTree(d, k, 8192)
9898
2015-01-01 6 38 100500
9999
2015-01-01 7 39 0
100100
2015-01-01 8 40 0

dbms/tests/queries/0_stateless/00062_replicated_merge_tree_alter_zookeeper.reference

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ i32 Int32
8585
dt DateTime
8686
n.ui8 Array(UInt8)
8787
n.s Array(String)
88-
s Int64
89-
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `n.ui8` Array(UInt8), `n.s` Array(String), `s` Int64) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
88+
s Int64 DEFAULT \'0\'
89+
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `n.ui8` Array(UInt8), `n.s` Array(String), `s` Int64 DEFAULT \'0\') ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
9090
d Date
9191
k UInt64
9292
i32 Int32
9393
dt DateTime
9494
n.ui8 Array(UInt8)
9595
n.s Array(String)
96-
s Int64
97-
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `n.ui8` Array(UInt8), `n.s` Array(String), `s` Int64) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
96+
s Int64 DEFAULT \'0\'
97+
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `n.ui8` Array(UInt8), `n.s` Array(String), `s` Int64 DEFAULT \'0\') ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
9898
2015-01-01 6 38 2014-07-15 13:26:50 [10,20,30] ['asd','qwe','qwe'] 100500
9999
2015-01-01 7 39 2014-07-14 13:26:50 [10,20,30] ['120','130','140'] 0
100100
2015-01-01 8 40 2012-12-12 12:12:12 [1,2,3] ['12','13','14'] 0
@@ -106,18 +106,18 @@ i32 Int32
106106
dt DateTime
107107
n.ui8 Array(UInt8)
108108
n.s Array(String)
109-
s UInt32
109+
s UInt32 DEFAULT \'0\'
110110
n.d Array(Date)
111-
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `n.ui8` Array(UInt8), `n.s` Array(String), `s` UInt32, `n.d` Array(Date)) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
111+
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `n.ui8` Array(UInt8), `n.s` Array(String), `s` UInt32 DEFAULT \'0\', `n.d` Array(Date)) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
112112
d Date
113113
k UInt64
114114
i32 Int32
115115
dt DateTime
116116
n.ui8 Array(UInt8)
117117
n.s Array(String)
118-
s UInt32
118+
s UInt32 DEFAULT \'0\'
119119
n.d Array(Date)
120-
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `n.ui8` Array(UInt8), `n.s` Array(String), `s` UInt32, `n.d` Array(Date)) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
120+
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `n.ui8` Array(UInt8), `n.s` Array(String), `s` UInt32 DEFAULT \'0\', `n.d` Array(Date)) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
121121
2015-01-01 6 38 2014-07-15 13:26:50 [10,20,30] ['asd','qwe','qwe'] 100500 ['0000-00-00','0000-00-00','0000-00-00']
122122
2015-01-01 7 39 2014-07-14 13:26:50 [10,20,30] ['120','130','140'] 0 ['0000-00-00','0000-00-00','0000-00-00']
123123
2015-01-01 8 40 2012-12-12 12:12:12 [1,2,3] ['12','13','14'] 0 ['0000-00-00','0000-00-00','0000-00-00']
@@ -128,15 +128,15 @@ k UInt64
128128
i32 Int32
129129
dt DateTime
130130
n.s Array(String)
131-
s UInt32
132-
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `n.s` Array(String), `s` UInt32) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
131+
s UInt32 DEFAULT \'0\'
132+
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `n.s` Array(String), `s` UInt32 DEFAULT \'0\') ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
133133
d Date
134134
k UInt64
135135
i32 Int32
136136
dt DateTime
137137
n.s Array(String)
138-
s UInt32
139-
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `n.s` Array(String), `s` UInt32) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
138+
s UInt32 DEFAULT \'0\'
139+
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `n.s` Array(String), `s` UInt32 DEFAULT \'0\') ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
140140
2015-01-01 6 38 2014-07-15 13:26:50 ['asd','qwe','qwe'] 100500
141141
2015-01-01 7 39 2014-07-14 13:26:50 ['120','130','140'] 0
142142
2015-01-01 8 40 2012-12-12 12:12:12 ['12','13','14'] 0
@@ -146,14 +146,14 @@ d Date
146146
k UInt64
147147
i32 Int32
148148
dt DateTime
149-
s UInt32
150-
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `s` UInt32) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
149+
s UInt32 DEFAULT \'0\'
150+
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `s` UInt32 DEFAULT \'0\') ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
151151
d Date
152152
k UInt64
153153
i32 Int32
154154
dt DateTime
155-
s UInt32
156-
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `s` UInt32) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
155+
s UInt32 DEFAULT \'0\'
156+
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `s` UInt32 DEFAULT \'0\') ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
157157
2015-01-01 6 38 2014-07-15 13:26:50 100500
158158
2015-01-01 7 39 2014-07-14 13:26:50 0
159159
2015-01-01 8 40 2012-12-12 12:12:12 0
@@ -163,18 +163,18 @@ d Date
163163
k UInt64
164164
i32 Int32
165165
dt DateTime
166-
s UInt32
166+
s UInt32 DEFAULT \'0\'
167167
n.s Array(String)
168168
n.d Array(Date)
169-
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `s` UInt32, `n.s` Array(String), `n.d` Array(Date)) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
169+
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `s` UInt32 DEFAULT \'0\', `n.s` Array(String), `n.d` Array(Date)) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
170170
d Date
171171
k UInt64
172172
i32 Int32
173173
dt DateTime
174-
s UInt32
174+
s UInt32 DEFAULT \'0\'
175175
n.s Array(String)
176176
n.d Array(Date)
177-
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `s` UInt32, `n.s` Array(String), `n.d` Array(Date)) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
177+
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `s` UInt32 DEFAULT \'0\', `n.s` Array(String), `n.d` Array(Date)) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
178178
2015-01-01 6 38 2014-07-15 13:26:50 100500 [] []
179179
2015-01-01 7 39 2014-07-14 13:26:50 0 [] []
180180
2015-01-01 8 40 2012-12-12 12:12:12 0 [] []
@@ -184,14 +184,14 @@ d Date
184184
k UInt64
185185
i32 Int32
186186
dt DateTime
187-
s UInt32
188-
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `s` UInt32) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
187+
s UInt32 DEFAULT \'0\'
188+
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `s` UInt32 DEFAULT \'0\') ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
189189
d Date
190190
k UInt64
191191
i32 Int32
192192
dt DateTime
193-
s UInt32
194-
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `s` UInt32) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
193+
s UInt32 DEFAULT \'0\'
194+
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` DateTime, `s` UInt32 DEFAULT \'0\') ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
195195
2015-01-01 6 38 2014-07-15 13:26:50 100500
196196
2015-01-01 7 39 2014-07-14 13:26:50 0
197197
2015-01-01 8 40 2012-12-12 12:12:12 0
@@ -201,14 +201,14 @@ d Date
201201
k UInt64
202202
i32 Int32
203203
dt Date
204-
s DateTime
205-
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` Date, `s` DateTime) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
204+
s DateTime DEFAULT \'0000-00-00 00:00:00\'
205+
CREATE TABLE test.replicated_alter1 (`d` Date, `k` UInt64, `i32` Int32, `dt` Date, `s` DateTime DEFAULT \'0000-00-00 00:00:00\') ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r1\', d, k, 8192)
206206
d Date
207207
k UInt64
208208
i32 Int32
209209
dt Date
210-
s DateTime
211-
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` Date, `s` DateTime) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
210+
s DateTime DEFAULT \'0000-00-00 00:00:00\'
211+
CREATE TABLE test.replicated_alter2 (`d` Date, `k` UInt64, `i32` Int32, `dt` Date, `s` DateTime DEFAULT \'0000-00-00 00:00:00\') ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/alter\', \'r2\', d, k, 8192)
212212
2015-01-01 6 38 2014-07-15 1970-01-02 06:55:00
213213
2015-01-01 7 39 2014-07-14 0000-00-00 00:00:00
214214
2015-01-01 8 40 2012-12-12 0000-00-00 00:00:00

dbms/tests/queries/0_stateless/00062_replicated_merge_tree_alter_zookeeper.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ DESC TABLE test.replicated_alter2;
9595
SHOW CREATE TABLE test.replicated_alter2;
9696
SELECT * FROM test.replicated_alter1 ORDER BY k;
9797

98-
ALTER TABLE test.replicated_alter1 MODIFY COLUMN dt Date, MODIFY COLUMN s DateTime;
98+
ALTER TABLE test.replicated_alter1 MODIFY COLUMN dt Date, MODIFY COLUMN s DateTime DEFAULT '0000-00-00 00:00:00';
9999

100100
DESC TABLE test.replicated_alter1;
101101
SHOW CREATE TABLE test.replicated_alter1;

dbms/tests/queries/0_stateless/00079_defaulted_columns.reference

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ some string 11
2828
payload String
2929
date Date MATERIALIZED today()
3030
key UInt64 MATERIALIZED 0 * rand()
31-
payload_length UInt16 DEFAULT length(payload) % 65535
31+
payload_length UInt64 DEFAULT length(payload) % 65535
3232
hello clickhouse 16
3333
some string 11
3434
payload String
3535
date Date MATERIALIZED today()
3636
key UInt64 MATERIALIZED 0 * rand()
37-
payload_length UInt16 DEFAULT CAST(length(payload), \'UInt16\')
37+
payload_length UInt16 DEFAULT length(payload)
3838
payload String
3939
date Date MATERIALIZED today()
4040
key UInt64 MATERIALIZED 0 * rand()

dbms/tests/queries/0_stateless/00079_defaulted_columns.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ create table defaulted (payload String, date materialized today(), key materiali
2020
desc table defaulted;
2121
insert into defaulted (payload) values ('hello clickhouse');
2222
select * from defaulted;
23-
alter table defaulted add column payload_length materialized length(payload);
23+
alter table defaulted add column payload_length UInt64 materialized length(payload);
2424
desc table defaulted;
2525
select *, payload_length from defaulted;
2626
insert into defaulted (payload) values ('some string');

dbms/tests/queries/0_stateless/00229_prewhere_column_missing.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ select *, length(arr) as l from prewhere_column_missing;
1616
select *, length(arr) as l from prewhere_column_missing where l = 0;
1717
select *, length(arr) as l from prewhere_column_missing prewhere l = 0;
1818

19-
alter table prewhere_column_missing add column hash_x default intHash64(x);
19+
alter table prewhere_column_missing add column hash_x UInt64 default intHash64(x);
2020

2121
select * from prewhere_column_missing;
2222
select * from prewhere_column_missing where hash_x = intHash64(x);

0 commit comments

Comments
 (0)