mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-08 07:22:25 +00:00
34 lines
1.2 KiB
Plaintext
34 lines
1.2 KiB
Plaintext
-- { echo }
|
|
CREATE FUNCTION 02483_plusone AS (a) -> a + 1;
|
|
CREATE TABLE 02483_substitute_udf (id UInt32, number UInt32 DEFAULT 02483_plusone(id)) ENGINE=MergeTree() ORDER BY id;
|
|
DESC TABLE 02483_substitute_udf;
|
|
id UInt32
|
|
number UInt32 DEFAULT id + 1
|
|
INSERT INTO 02483_substitute_udf (id, number) VALUES (1, NULL);
|
|
SELECT * FROM 02483_substitute_udf ORDER BY id;
|
|
1 2
|
|
CREATE FUNCTION 02483_plustwo AS (a) -> a + 2;
|
|
ALTER TABLE 02483_substitute_udf MODIFY COLUMN number UInt32 DEFAULT 02483_plustwo(id);
|
|
DESC TABLE 02483_substitute_udf;
|
|
id UInt32
|
|
number UInt32 DEFAULT id + 2
|
|
INSERT INTO 02483_substitute_udf (id, number) VALUES (5, NULL);
|
|
SELECT * FROM 02483_substitute_udf ORDER BY id;
|
|
1 2
|
|
5 7
|
|
CREATE FUNCTION 02483_plusthree AS (a) -> a + 3;
|
|
ALTER TABLE 02483_substitute_udf DROP COLUMN number;
|
|
ALTER TABLE 02483_substitute_udf ADD COLUMN new_number UInt32 DEFAULT 02483_plusthree(id);
|
|
DESC TABLE 02483_substitute_udf;
|
|
id UInt32
|
|
new_number UInt32 DEFAULT id + 3
|
|
INSERT INTO 02483_substitute_udf (id, new_number) VALUES (10, NULL);
|
|
SELECT * FROM 02483_substitute_udf ORDER BY id;
|
|
1 4
|
|
5 8
|
|
10 13
|
|
DROP TABLE 02483_substitute_udf;
|
|
DROP FUNCTION 02483_plusone;
|
|
DROP FUNCTION 02483_plustwo;
|
|
DROP FUNCTION 02483_plusthree;
|