mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Fix ALTER column with column names with dots
This commit is contained in:
parent
349f1b140a
commit
a4f378f8c3
@ -173,16 +173,14 @@ static auto getNameRange(const ColumnsDescription::ColumnsContainer & columns, c
|
||||
{
|
||||
String name_with_dot = name_without_dot + ".";
|
||||
|
||||
auto begin = columns.begin();
|
||||
for (; begin != columns.end(); ++begin)
|
||||
for (auto it = columns.begin(); it != columns.end(); ++it)
|
||||
{
|
||||
if (begin->name == name_without_dot)
|
||||
return std::make_pair(begin, std::next(begin));
|
||||
|
||||
if (startsWith(begin->name, name_with_dot))
|
||||
break;
|
||||
if (it->name == name_without_dot)
|
||||
return std::make_pair(it, std::next(it));
|
||||
}
|
||||
|
||||
auto begin = std::find_if(columns.begin(), columns.end(), [&](const auto & column){ return startsWith(column.name, name_with_dot); });
|
||||
|
||||
if (begin == columns.end())
|
||||
return std::make_pair(begin, begin);
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
id String
|
||||
abc.1 String
|
||||
abc.2 String
|
||||
abc String
|
||||
id String
|
||||
abc.2 String
|
||||
abc String
|
||||
abc.1 String
|
||||
id String
|
||||
abc String
|
||||
abc.2 String
|
||||
abc.1 String
|
||||
id String
|
||||
abc.2 String
|
||||
abc String
|
||||
abc.1 String
|
||||
id String
|
||||
abc String
|
||||
abc.2 String
|
||||
abc.1 String
|
||||
id String
|
||||
abc.2 String
|
||||
abc.1 String
|
||||
abc String
|
||||
id String
|
||||
abc.2 String
|
||||
abc.1 String
|
15
tests/queries/0_stateless/02320_alter_columns_with_dots.sql
Normal file
15
tests/queries/0_stateless/02320_alter_columns_with_dots.sql
Normal file
@ -0,0 +1,15 @@
|
||||
DROP TABLE IF EXISTS test;
|
||||
CREATE TABLE test (id String, `abc.1` String, `abc.2` String, `abc` String) ENGINE MergeTree order by id;
|
||||
DESC TABLE test;
|
||||
ALTER TABLE test MODIFY COLUMN `abc.1` String AFTER `abc`;
|
||||
DESC TABLE test;
|
||||
ALTER TABLE test MODIFY COLUMN `abc.2` String AFTER `abc`;
|
||||
DESC TABLE test;
|
||||
ALTER TABLE test MODIFY COLUMN `abc` String AFTER `abc.2`;
|
||||
DESC TABLE test;
|
||||
ALTER TABLE test MODIFY COLUMN `abc` String AFTER `id`;
|
||||
DESC TABLE test;
|
||||
ALTER TABLE test MODIFY COLUMN `abc` String AFTER `abc.1`;
|
||||
DESC TABLE test;
|
||||
ALTER TABLE test DROP COLUMN `abc`;
|
||||
DESC TABLE test;
|
Loading…
Reference in New Issue
Block a user