mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #41533 from kssenii/add-settings-for-delete
Support `SETTINGS` in `DELETE ...` query
This commit is contained in:
commit
d598802988
@ -20,6 +20,12 @@ ASTPtr ASTDeleteQuery::clone() const
|
||||
res->children.push_back(res->predicate);
|
||||
}
|
||||
|
||||
if (settings_ast)
|
||||
{
|
||||
res->settings_ast = settings_ast->clone();
|
||||
res->children.push_back(res->settings_ast);
|
||||
}
|
||||
|
||||
cloneTableOptions(*res);
|
||||
return res;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <Parsers/ASTDeleteQuery.h>
|
||||
#include <Parsers/parseDatabaseAndTableName.h>
|
||||
#include <Parsers/ExpressionListParsers.h>
|
||||
#include <Parsers/ParserSetQuery.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -16,6 +17,7 @@ bool ParserDeleteQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
ParserKeyword s_from("FROM");
|
||||
ParserKeyword s_where("WHERE");
|
||||
ParserExpression parser_exp_elem;
|
||||
ParserKeyword s_settings("SETTINGS");
|
||||
|
||||
if (s_delete.ignore(pos, expected))
|
||||
{
|
||||
@ -30,6 +32,14 @@ bool ParserDeleteQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
|
||||
if (!parser_exp_elem.parse(pos, query->predicate, expected))
|
||||
return false;
|
||||
|
||||
if (s_settings.ignore(pos, expected))
|
||||
{
|
||||
ParserSetQuery parser_settings(true);
|
||||
|
||||
if (!parser_settings.parse(pos, query->settings_ast, expected))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
@ -43,6 +53,9 @@ bool ParserDeleteQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
if (query->table)
|
||||
query->children.push_back(query->table);
|
||||
|
||||
if (query->settings_ast)
|
||||
query->children.push_back(query->settings_ast);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
500000
|
6
tests/queries/0_stateless/02428_delete_with_settings.sql
Normal file
6
tests/queries/0_stateless/02428_delete_with_settings.sql
Normal file
@ -0,0 +1,6 @@
|
||||
drop table if exists test;
|
||||
create table test (id Int32, key String) engine=MergeTree() order by tuple();
|
||||
insert into test select number, toString(number) from numbers(1000000);
|
||||
set allow_experimental_lightweight_delete=1;
|
||||
delete from test where id % 2 = 0 SETTINGS mutations_sync=1;
|
||||
select count() from test;
|
Loading…
Reference in New Issue
Block a user