mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 02:41:59 +00:00
Cosmetics
This commit is contained in:
parent
7b49a0e530
commit
c30736d415
@ -76,8 +76,8 @@ static void splitAndModifyMutationCommands(
|
||||
{
|
||||
if (command.type == MutationCommand::Type::MATERIALIZE_COLUMN)
|
||||
{
|
||||
/// For ordinary column with default expression, materialize column should not override past values
|
||||
/// So we only mutated column if `command.column_name` is a materialized column or if the part does not have physical column file
|
||||
/// For ordinary column with default or materialized expression, MATERIALIZE COLUMN should not override past values
|
||||
/// So we only mutate column if `command.column_name` is a default/materialized column or if the part does not have physical column file
|
||||
auto column_ordinary = table_columns.getOrdinary().tryGetByName(command.column_name);
|
||||
if (!column_ordinary || !part->tryGetColumn(command.column_name) || !part->hasColumnFiles(*column_ordinary))
|
||||
{
|
||||
@ -206,8 +206,8 @@ static void splitAndModifyMutationCommands(
|
||||
{
|
||||
if (command.type == MutationCommand::Type::MATERIALIZE_COLUMN)
|
||||
{
|
||||
/// For ordinary column with default expression, materialize column should not override past values
|
||||
/// So we only mutated column if `command.column_name` is a materialized column or if the part does not have physical column file
|
||||
/// For ordinary column with default or materialized expression, MATERIALIZE COLUMN should not override past values
|
||||
/// So we only mutate column if `command.column_name` is a default/materialized column or if the part does not have physical column file
|
||||
auto column_ordinary = table_columns.getOrdinary().tryGetByName(command.column_name);
|
||||
if (!column_ordinary || !part->tryGetColumn(command.column_name) || !part->hasColumnFiles(*column_ordinary))
|
||||
for_interpreter.push_back(command);
|
||||
|
@ -0,0 +1,33 @@
|
||||
-- Compact parts
|
||||
Origin
|
||||
1 2
|
||||
2 54321
|
||||
After materialize
|
||||
1 2
|
||||
2 54321
|
||||
-- Wide parts
|
||||
Origin
|
||||
1 2
|
||||
2 54321
|
||||
After materialize
|
||||
1 2
|
||||
2 54321
|
||||
-- Nullable column != physically absent
|
||||
Origin
|
||||
1 2
|
||||
2 \N
|
||||
3 54321
|
||||
After materialize
|
||||
1 2
|
||||
2 \N
|
||||
3 54321
|
||||
-- Parts with renamed column
|
||||
Origin
|
||||
1 2
|
||||
2 54321
|
||||
After rename
|
||||
1 2
|
||||
2 54321
|
||||
After materialize
|
||||
1 2
|
||||
2 54321
|
@ -0,0 +1,53 @@
|
||||
SET mutations_sync = 2;
|
||||
|
||||
SELECT '-- Compact parts';
|
||||
|
||||
CREATE TABLE tab (id Int64, dflt Int64 DEFAULT 54321) ENGINE MergeTree ORDER BY id;
|
||||
INSERT INTO tab (id, dflt) VALUES (1, 2);
|
||||
INSERT INTO tab (id) VALUES (2);
|
||||
SELECT 'Origin';
|
||||
SELECT * FROM tab ORDER BY id;
|
||||
ALTER TABLE tab MATERIALIZE COLUMN dflt;
|
||||
SELECT 'After materialize';
|
||||
SELECT * FROM tab ORDER BY id;
|
||||
DROP TABLE tab;
|
||||
|
||||
SELECT '-- Wide parts';
|
||||
|
||||
CREATE TABLE tab (id Int64, dflt Int64 DEFAULT 54321) ENGINE MergeTree ORDER BY id SETTINGS min_bytes_for_wide_part = 1;
|
||||
INSERT INTO tab (id, dflt) VALUES (1, 2);
|
||||
INSERT INTO tab (id) VALUES (2);
|
||||
SELECT 'Origin';
|
||||
SELECT * FROM tab ORDER BY id;
|
||||
ALTER TABLE tab MATERIALIZE COLUMN dflt;
|
||||
SELECT 'After materialize';
|
||||
SELECT * FROM tab ORDER BY id;
|
||||
DROP TABLE tab;
|
||||
|
||||
SELECT '-- Nullable column != physically absent';
|
||||
|
||||
CREATE TABLE tab (id Int64, dflt Nullable(Int64) DEFAULT 54321) ENGINE MergeTree ORDER BY id SETTINGS min_bytes_for_wide_part = 1;
|
||||
INSERT INTO tab (id, dflt) VALUES (1, 2);
|
||||
INSERT INTO tab (id, dflt) VALUES (2, NULL);
|
||||
INSERT INTO tab (id) VALUES (3);
|
||||
SELECT 'Origin';
|
||||
SELECT * FROM tab ORDER BY id;
|
||||
ALTER TABLE tab MATERIALIZE COLUMN dflt;
|
||||
SELECT 'After materialize';
|
||||
SELECT * FROM tab ORDER BY id;
|
||||
DROP TABLE tab;
|
||||
|
||||
SELECT '-- Parts with renamed column';
|
||||
|
||||
CREATE TABLE tab (id Int64, dflt Int64 DEFAULT 54321) ENGINE MergeTree ORDER BY id;
|
||||
INSERT INTO tab (id, dflt) VALUES (1, 2);
|
||||
INSERT INTO tab (id) VALUES (2);
|
||||
SELECT 'Origin';
|
||||
SELECT * FROM tab ORDER BY id;
|
||||
ALTER TABLE tab RENAME COLUMN dflt TO dflt2;
|
||||
SELECT 'After rename';
|
||||
SELECT * FROM tab ORDER BY id;
|
||||
ALTER TABLE tab MATERIALIZE COLUMN bar;
|
||||
SELECT 'After materialize';
|
||||
SELECT * FROM tab ORDER BY id;
|
||||
DROP TABLE tab;
|
@ -1,29 +0,0 @@
|
||||
--Origin--
|
||||
1 2
|
||||
2 54321
|
||||
--After materialize--
|
||||
1 2
|
||||
2 54321
|
||||
--Origin--
|
||||
1 2
|
||||
2 54321
|
||||
--After materialize--
|
||||
1 2
|
||||
2 54321
|
||||
--Origin--
|
||||
1 2
|
||||
2 \N
|
||||
3 54321
|
||||
--After materialize--
|
||||
1 2
|
||||
2 \N
|
||||
3 54321
|
||||
--Origin--
|
||||
1 2
|
||||
2 54321
|
||||
--After rename--
|
||||
1 2
|
||||
2 54321
|
||||
--After materialize--
|
||||
1 2
|
||||
2 54321
|
@ -1,49 +0,0 @@
|
||||
|
||||
SET mutations_sync = 2;
|
||||
-- Compact parts
|
||||
CREATE TABLE test (id Int64, foo Int64 default 54321) ENGINE MergeTree ORDER BY id;
|
||||
INSERT INTO test ( id, foo ) values ( 1, 2 );
|
||||
INSERT INTO test ( id ) values ( 2 );
|
||||
SELECT '--Origin--';
|
||||
SELECT * FROM test ORDER BY id;
|
||||
ALTER TABLE test MATERIALIZE COLUMN foo;
|
||||
SELECT '--After materialize--';
|
||||
SELECT * FROM test ORDER BY id;
|
||||
DROP TABLE test;
|
||||
|
||||
-- Wide parts
|
||||
CREATE TABLE test (id Int64, foo Nullable(Int64) default 54321) ENGINE MergeTree ORDER BY id SETTINGS min_bytes_for_wide_part = 1;
|
||||
INSERT INTO test ( id, foo ) values ( 1, 2 );
|
||||
INSERT INTO test ( id ) values ( 2 );
|
||||
SELECT '--Origin--';
|
||||
SELECT * FROM test ORDER BY id;
|
||||
ALTER TABLE test MATERIALIZE COLUMN foo;
|
||||
SELECT '--After materialize--';
|
||||
SELECT * FROM test ORDER BY id;
|
||||
DROP TABLE test;
|
||||
|
||||
-- Nullable column != physically absent
|
||||
CREATE TABLE test (id Int64, foo Nullable(Int64) default 54321) ENGINE MergeTree ORDER BY id SETTINGS min_bytes_for_wide_part = 1;
|
||||
INSERT INTO test ( id, foo ) values ( 1, 2 );
|
||||
INSERT INTO test ( id, foo ) values ( 2, NULL );
|
||||
INSERT INTO test ( id ) values ( 3 );
|
||||
SELECT '--Origin--';
|
||||
SELECT * FROM test ORDER BY id;
|
||||
ALTER TABLE test MATERIALIZE COLUMN foo;
|
||||
SELECT '--After materialize--';
|
||||
SELECT * FROM test ORDER BY id;
|
||||
DROP TABLE test;
|
||||
|
||||
-- Parts with renamed column
|
||||
CREATE TABLE test (id Int64, foo Int64 default 54321) ENGINE MergeTree ORDER BY id;
|
||||
INSERT INTO test ( id, foo ) values ( 1, 2 );
|
||||
INSERT INTO test ( id ) values ( 2 );
|
||||
SELECT '--Origin--';
|
||||
SELECT * FROM test ORDER BY id;
|
||||
ALTER TABLE test RENAME COLUMN foo TO bar;
|
||||
SELECT '--After rename--';
|
||||
SELECT * FROM test ORDER BY id;
|
||||
ALTER TABLE test MATERIALIZE COLUMN bar;
|
||||
SELECT '--After materialize--';
|
||||
SELECT * FROM test ORDER BY id;
|
||||
DROP TABLE test;
|
Loading…
Reference in New Issue
Block a user