mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
Merge pull request #32464 from ClickHouse/fix-31538
Fix crash in case of MATERIALIZE COLUMN with no default expression.
This commit is contained in:
commit
9867d75fec
@ -569,6 +569,12 @@ ASTPtr MutationsInterpreter::prepare(bool dry_run)
|
|||||||
stages.emplace_back(context);
|
stages.emplace_back(context);
|
||||||
|
|
||||||
const auto & column = columns_desc.get(command.column_name);
|
const auto & column = columns_desc.get(command.column_name);
|
||||||
|
|
||||||
|
if (!column.default_desc.expression)
|
||||||
|
throw Exception(
|
||||||
|
ErrorCodes::BAD_ARGUMENTS,
|
||||||
|
"Cannot materialize column `{}` because it doesn't have default expression", column.name);
|
||||||
|
|
||||||
auto materialized_column = makeASTFunction(
|
auto materialized_column = makeASTFunction(
|
||||||
"_CAST", column.default_desc.expression->clone(), std::make_shared<ASTLiteral>(column.type->getName()));
|
"_CAST", column.default_desc.expression->clone(), std::make_shared<ASTLiteral>(column.type->getName()));
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ SET mutations_sync = 2;
|
|||||||
CREATE TABLE tmp (x Int64) ENGINE = MergeTree() ORDER BY tuple() PARTITION BY tuple();
|
CREATE TABLE tmp (x Int64) ENGINE = MergeTree() ORDER BY tuple() PARTITION BY tuple();
|
||||||
INSERT INTO tmp SELECT * FROM system.numbers LIMIT 20;
|
INSERT INTO tmp SELECT * FROM system.numbers LIMIT 20;
|
||||||
|
|
||||||
|
ALTER TABLE tmp MATERIALIZE COLUMN x; -- { serverError 36 }
|
||||||
|
|
||||||
ALTER TABLE tmp ADD COLUMN s String DEFAULT toString(x);
|
ALTER TABLE tmp ADD COLUMN s String DEFAULT toString(x);
|
||||||
SELECT groupArray(x), groupArray(s) FROM tmp;
|
SELECT groupArray(x), groupArray(s) FROM tmp;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user