Add test for storage args with UDFs

This commit is contained in:
Antonio Andelic 2022-11-24 09:35:17 +00:00
parent c52ca6e10e
commit 6e21e63871
4 changed files with 74 additions and 2 deletions

View File

@ -1026,8 +1026,20 @@ void AlterCommands::prepare(const StorageInMemoryMetadata & metadata)
command.ignore = true;
}
if (command.default_expression && !UserDefinedSQLFunctionFactory::instance().empty())
UserDefinedSQLFunctionVisitor::visit(command.default_expression);
if (!UserDefinedSQLFunctionFactory::instance().empty())
{
if (command.default_expression)
UserDefinedSQLFunctionVisitor::visit(command.default_expression);
if (command.order_by)
UserDefinedSQLFunctionVisitor::visit(command.order_by);
if (command.sample_by)
UserDefinedSQLFunctionVisitor::visit(command.sample_by);
if (command.ttl)
UserDefinedSQLFunctionVisitor::visit(command.ttl);
}
}
prepared = true;

View File

@ -1,3 +1,5 @@
-- Tags: no-parallel
DROP TABLE IF EXISTS 02483_substitute_udf;
DROP FUNCTION IF EXISTS 02483_plusone;
DROP FUNCTION IF EXISTS 02483_plustwo;

View File

@ -0,0 +1,21 @@
-- { echo }
CREATE TABLE 02484_substitute_udf (id UInt32, dt DateTime, number UInt32)
ENGINE=MergeTree()
ORDER BY 02484_plusone(id)
PARTITION BY 02484_plustwo(id)
SAMPLE BY 02484_plusone(id)
TTL 02484_plusthreemonths(dt);
SHOW CREATE TABLE 02484_substitute_udf;
CREATE TABLE default.`02484_substitute_udf`\n(\n `id` UInt32,\n `dt` DateTime,\n `number` UInt32\n)\nENGINE = MergeTree\nPARTITION BY id + 2\nORDER BY id + 1\nSAMPLE BY id + 1\nTTL dt + toIntervalMonth(3)\nSETTINGS index_granularity = 8192
CREATE FUNCTION 02484_plusthree AS (a) -> a + 3;
ALTER TABLE 02484_substitute_udf ADD COLUMN id2 UInt64, MODIFY ORDER BY (02484_plusone(id), 02484_plusthree(id2));
SHOW CREATE TABLE 02484_substitute_udf;
CREATE TABLE default.`02484_substitute_udf`\n(\n `id` UInt32,\n `dt` DateTime,\n `number` UInt32,\n `id2` UInt64\n)\nENGINE = MergeTree\nPARTITION BY id + 2\nPRIMARY KEY id + 1\nORDER BY (id + 1, id2 + 3)\nSAMPLE BY id + 1\nTTL dt + toIntervalMonth(3)\nSETTINGS index_granularity = 8192
CREATE FUNCTION 02484_plusthreedays AS (a) -> a + INTERVAL 3 DAY;
ALTER TABLE 02484_substitute_udf MODIFY TTL 02484_plusthreedays(dt);
SHOW CREATE TABLE 02484_substitute_udf;
CREATE TABLE default.`02484_substitute_udf`\n(\n `id` UInt32,\n `dt` DateTime,\n `number` UInt32,\n `id2` UInt64\n)\nENGINE = MergeTree\nPARTITION BY id + 2\nPRIMARY KEY id + 1\nORDER BY (id + 1, id2 + 3)\nSAMPLE BY id + 1\nTTL dt + toIntervalDay(3)\nSETTINGS index_granularity = 8192
DROP TABLE 02484_substitute_udf;
DROP FUNCTION 02484_plusone;
DROP FUNCTION 02484_plustwo;
DROP FUNCTION 02484_plusthree;

View File

@ -0,0 +1,37 @@
-- Tags: no-parallel
DROP TABLE IF EXISTS 02484_substitute_udf;
DROP FUNCTION IF EXISTS 02484_plusone;
DROP FUNCTION IF EXISTS 02484_plustwo;
DROP FUNCTION IF EXISTS 02484_plusthree;
DROP FUNCTION IF EXISTS 02484_plusthreemonths;
DROP FUNCTION IF EXISTS 02484_plusthreedays;
CREATE FUNCTION 02484_plusone AS (a) -> a + 1;
CREATE FUNCTION 02484_plustwo AS (a) -> a + 2;
CREATE FUNCTION 02484_plusthreemonths AS (a) -> a + INTERVAL 3 MONTH;
-- { echo }
CREATE TABLE 02484_substitute_udf (id UInt32, dt DateTime, number UInt32)
ENGINE=MergeTree()
ORDER BY 02484_plusone(id)
PARTITION BY 02484_plustwo(id)
SAMPLE BY 02484_plusone(id)
TTL 02484_plusthreemonths(dt);
SHOW CREATE TABLE 02484_substitute_udf;
CREATE FUNCTION 02484_plusthree AS (a) -> a + 3;
ALTER TABLE 02484_substitute_udf ADD COLUMN id2 UInt64, MODIFY ORDER BY (02484_plusone(id), 02484_plusthree(id2));
SHOW CREATE TABLE 02484_substitute_udf;
CREATE FUNCTION 02484_plusthreedays AS (a) -> a + INTERVAL 3 DAY;
ALTER TABLE 02484_substitute_udf MODIFY TTL 02484_plusthreedays(dt);
SHOW CREATE TABLE 02484_substitute_udf;
DROP TABLE 02484_substitute_udf;
DROP FUNCTION 02484_plusone;
DROP FUNCTION 02484_plustwo;
DROP FUNCTION 02484_plusthree;
DROP FUNCTION 02484_plusthreemonths;
DROP FUNCTION 02484_plusthreedays;