Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes of Enum in partition key don't work #7513

Closed
filimonov opened this issue Oct 28, 2019 · 5 comments · Fixed by #11973
Closed

Changes of Enum in partition key don't work #7513

filimonov opened this issue Oct 28, 2019 · 5 comments · Fixed by #11973
Assignees
Labels
easy task Good for first contributors feature unfinished code

Comments

@filimonov
Copy link
Contributor

filimonov commented Oct 28, 2019

From #2667. thanks @develar

CREATE TABLE report
(
    `product` Enum8('IU' = 1, 'WS' = 2), 
    `machine` String, 
    `branch` String, 
    `build_c1` String, 
    `build_c2` String, 
    `build_c3` String, 
    `build_time` DateTime, 
    `generated_time` DateTime
)
ENGINE = MergeTree
PARTITION BY (product, toYYYYMM(generated_time))
ORDER BY (product, machine, branch, build_c1, build_c2, build_c3, build_time, generated_time)
SETTINGS old_parts_lifetime = 10;

alter table report modify column product Enum8('IU' = 1, 'WS' = 2, 'PS' = 3);

Got:

Received exception from server (version 19.16.1):
Code: 44. DB::Exception: Received from localhost:9000. DB::Exception: Trying to ALTER key column product. Stack trace:

0. 0x55e1ab472d20 StackTrace::StackTrace() /build/obj-x86_64-linux-gnu/../dbms/src/Common/StackTrace.cpp:228
1. 0x55e1ab472af5 DB::Exception::Exception(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) /build/obj-x86_64-linux-gnu/../dbms/src/Common/Exception.h:27
2. 0x55e1ab1ff52d DB::MergeTreeData::checkAlter(DB::AlterCommands const&, DB::Context const&) [clone .cold] /usr/include/c++/9/bits/basic_string.h:222
3. 0x55e1aea283af DB::StorageMergeTree::alter(DB::AlterCommands const&, DB::Context const&, DB::TableStructureWriteLockHolder&) /build/obj-x86_64-linux-gnu/../dbms/src/Storages/StorageMergeTree.cpp:273
4. 0x55e1aef5ab33 DB::InterpreterAlterQuery::execute() /usr/include/c++/9/bits/shared_ptr_base.h:729
5. 0x55e1ae917916 DB::executeQueryImpl(char const*, char const*, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool, DB::ReadBuffer*, bool) /build/obj-x86_64-linux-gnu/../dbms/src/Interpreters/executeQuery.cpp:314
6. 0x55e1ae918ade DB::executeQuery(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool, bool) /build/obj-x86_64-linux-gnu/../dbms/src/Interpreters/executeQuery.cpp:562
7. 0x55e1ab4fae74 DB::TCPHandler::runImpl() /build/obj-x86_64-linux-gnu/../dbms/programs/server/TCPHandler.cpp:247
8. 0x55e1ab4fb8ab DB::TCPHandler::run() /build/obj-x86_64-linux-gnu/../dbms/programs/server/TCPHandler.cpp:1225
9. 0x55e1af392970 Poco::Net::TCPServerConnection::start() /build/obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServerConnection.cpp:57
10. 0x55e1af39308d Poco::Net::TCPServerDispatcher::run() /usr/include/c++/9/bits/atomic_base.h:327
11. 0x55e1b0a69261 Poco::PooledThread::run() /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:748
12. 0x55e1b0a6700c Poco::ThreadImpl::runnableEntry(void*) /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/include/Poco/AutoPtr.h:205
13. 0x55e1b11d8ba0 execute_native_thread_routine /usr/lib/debug/usr/bin/clickhouse
14. 0x7f67701416db start_thread /lib/x86_64-linux-gnu/libpthread-2.27.so
15. 0x7f676fa5e88f clone /build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97
0 rows in set. Elapsed: 0.147 sec. 

metadata only changes of ORDER BY is allowed:
9918965c
https://github.com/yandex/ClickHouse/blob/master/dbms/tests/queries/0_stateless/00427_alter_primary_key.sh

But not for partition key

@filimonov filimonov added the bug Confirmed user-visible misbehaviour in official release label Oct 28, 2019
@filimonov filimonov changed the title Changes of Enum in PK don't work Changes of Enum in partition key don't work Oct 29, 2019
@filimonov
Copy link
Contributor Author

It's actually about solving that TODO:

/// TODO: in some cases (e.g. adding an Enum value) a partition key column can still be ALTERed.
/// We should allow it.

@filimonov filimonov added feature unfinished code and removed bug Confirmed user-visible misbehaviour in official release labels Oct 29, 2019
@alexey-milovidov alexey-milovidov added the easy task Good for first contributors label Nov 3, 2019
@SergeyLossev
Copy link

@alexey-milovidov, So what about this bug/feature?

@SergeyLossev
Copy link

SergeyLossev commented Jun 5, 2020

@alexey-milovidov alexey-milovidov self-assigned this Jun 25, 2020
@alexey-milovidov
Copy link
Member

#11973

@SergeyLossev
Copy link

@alexey-milovidov

Trying to add new value to Enum, but still get an error:
DB::Exception: ALTER of key column interaction_type is forbidden (version 20.5.3.27 (official build))

What should I do to add a new value to Enum?

Stop service, edit all *.sql-files and start service again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy task Good for first contributors feature unfinished code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants