Merge pull request #44447 from ClickHouse/42637_Disallow_arrayJoin_in_mutations

Disallow arrayjoin in mutations
This commit is contained in:
Nikolai Kochetov 2023-01-05 18:00:16 +01:00 committed by GitHub
commit f629425f96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View File

@ -43,6 +43,7 @@ namespace ErrorCodes
extern const int UNKNOWN_MUTATION_COMMAND;
extern const int NO_SUCH_COLUMN_IN_TABLE;
extern const int CANNOT_UPDATE_COLUMN;
extern const int UNEXPECTED_EXPRESSION;
}
namespace
@ -946,6 +947,8 @@ QueryPipelineBuilder MutationsInterpreter::addStreamsForLaterStages(const std::v
for (size_t i = 0; i < stage.expressions_chain.steps.size(); ++i)
{
const auto & step = stage.expressions_chain.steps[i];
if (step->actions()->hasArrayJoin())
throw Exception("arrayJoin is not allowed in mutations", ErrorCodes::UNEXPECTED_EXPRESSION);
if (i < stage.filter_column_names.size())
{
/// Execute DELETEs.

View File

@ -0,0 +1,3 @@
1 1
2 2
3 3

View File

@ -0,0 +1,9 @@
DROP TABLE IF EXISTS test_02504;
CREATE TABLE test_02504 (`a` UInt32,`b` UInt32) ENGINE = MergeTree ORDER BY a;
INSERT INTO test_02504 values (1, 1) (2, 2), (3, 3);
SELECT * FROM test_02504;
ALTER TABLE test_02504 UPDATE b = 33 WHERE arrayJoin([1, 2]) = a; -- { serverError UNEXPECTED_EXPRESSION}
DROP TABLE test_02504;