Alter query function normalization.

This commit is contained in:
Amos Bird 2021-11-05 12:21:52 +08:00
parent 6dc51bf540
commit 0200d1c001
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
4 changed files with 21 additions and 0 deletions

View File

@ -6,6 +6,7 @@
#include <Databases/IDatabase.h>
#include <Interpreters/AddDefaultDatabaseVisitor.h>
#include <Interpreters/Context.h>
#include <Interpreters/FunctionNameNormalizer.h>
#include <Interpreters/MutationsInterpreter.h>
#include <Interpreters/QueryLog.h>
#include <Interpreters/executeDDLQueryOnCluster.h>
@ -43,6 +44,7 @@ InterpreterAlterQuery::InterpreterAlterQuery(const ASTPtr & query_ptr_, ContextP
BlockIO InterpreterAlterQuery::execute()
{
FunctionNameNormalizer().visit(query_ptr.get());
const auto & alter = query_ptr->as<ASTAlterQuery &>();
if (alter.alter_object == ASTAlterQuery::AlterObjectType::DATABASE)
return executeToDatabase(alter);

View File

@ -790,6 +790,10 @@ bool ParserAlterCommand::parseImpl(Pos & pos, ASTPtr & node, Expected & expected
command->children.push_back(command->constraint_decl);
if (command->constraint)
command->children.push_back(command->constraint);
if (command->projection_decl)
command->children.push_back(command->projection_decl);
if (command->projection)
command->children.push_back(command->projection);
if (command->predicate)
command->children.push_back(command->predicate);
if (command->update_assignments)

View File

@ -0,0 +1,2 @@
CREATE TABLE default.x\n(\n `i` Int32,\n INDEX mm rand() TYPE minmax GRANULARITY 1,\n INDEX nn rand() TYPE minmax GRANULARITY 1,\n PROJECTION p\n (\n SELECT max(i)\n ),\n PROJECTION p2\n (\n SELECT min(i)\n )\n)\nENGINE = ReplicatedMergeTree(\'/clickhouse/tables/default/x\', \'r\')\nORDER BY i\nSETTINGS index_granularity = 8192
metadata format version: 1\ndate column: \nsampling expression: \nindex granularity: 8192\nmode: 0\nsign column: \nprimary key: i\ndata format version: 1\npartition key: \nindices: mm rand() TYPE minmax GRANULARITY 1, nn rand() TYPE minmax GRANULARITY 1\nprojections: p(SELECT max(i)), p2(SELECT min(i))\ngranularity bytes: 10485760\n

View File

@ -0,0 +1,13 @@
-- Tags: zookeeper, no-replicated-database, no-parallel
drop table if exists x;
create table x(i int, index mm RAND() type minmax granularity 1, projection p (select MAX(i))) engine ReplicatedMergeTree('/clickhouse/tables/{database}/x', 'r') order by i;
alter table x add index nn RAND() type minmax granularity 1, add projection p2 (select MIN(i));
show create x;
select value from system.zookeeper WHERE name = 'metadata' and path = '/clickhouse/tables/'||currentDatabase()||'/x';
drop table x;