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

'Missing columns' when do MATERIALIZE COLUMN referencing the ALIAS columns #46016

Open
filimonov opened this issue Feb 3, 2023 · 0 comments
Open

Comments

@filimonov
Copy link
Contributor

DROP TABLE IF EXISTS t;
create table t 
(
  id int,
  c int alias id + 1
) engine=MergeTree
order by id;

insert into t values(1);
insert into t values(2);
alter table t add column d int default c;
alter table t materialize column d;

the exception:

Received exception from server (version 23.1.3):
Code: 47. DB::Exception: Received from localhost:9000. DB::Exception: Missing columns: 'c' while processing query: '_CAST(c, 'Int32'), d', required columns: 'c' 'd', maybe you meant: 'd'. Stack trace:

0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0xddb0df5 in /usr/bin/clickhouse
1. ? @ 0x8bccead in /usr/bin/clickhouse
2. DB::TreeRewriterResult::collectUsedColumns(std::__1::shared_ptr<DB::IAST> const&, bool, bool) @ 0x1375edb7 in /usr/bin/clickhouse
3. DB::TreeRewriter::analyze(std::__1::shared_ptr<DB::IAST>&, DB::NamesAndTypesList const&, std::__1::shared_ptr<DB::IStorage const>, std::__1::shared_ptr<DB::StorageSnapshot> const&, bool, bool, bool, bool) const @ 0x1376a790 in /usr/bin/clickhouse
4. DB::MutationsInterpreter::prepareMutationStages(std::__1::vector<DB::MutationsInterpreter::Stage, std::__1::allocator<DB::MutationsInterpreter::Stage>>&, bool) @ 0x135696b4 in /usr/bin/clickhouse
5. DB::MutationsInterpreter::prepare(bool) @ 0x13565b0a in /usr/bin/clickhouse
6. DB::MutationsInterpreter::MutationsInterpreter(DB::MutationsInterpreter::Source, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, DB::MutationCommands, std::__1::shared_ptr<DB::Context const>, bool, bool, bool) @ 0x1355e612 in /usr/bin/clickhouse
7. DB::MutationsInterpreter::MutationsInterpreter(std::__1::shared_ptr<DB::IStorage>, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, DB::MutationCommands, std::__1::shared_ptr<DB::Context const>, bool, bool, bool) @ 0x1355e11a in /usr/bin/clickhouse
8. DB::InterpreterAlterQuery::executeToTable(DB::ASTAlterQuery const&) @ 0x1331e160 in /usr/bin/clickhouse
9. DB::InterpreterAlterQuery::execute() @ 0x1331bc30 in /usr/bin/clickhouse
10. ? @ 0x1380c087 in /usr/bin/clickhouse
11. DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum) @ 0x13808f2d in /usr/bin/clickhouse
12. DB::TCPHandler::runImpl() @ 0x14676f79 in /usr/bin/clickhouse
13. DB::TCPHandler::run() @ 0x1468b8d9 in /usr/bin/clickhouse
14. Poco::Net::TCPServerConnection::start() @ 0x1753e2f4 in /usr/bin/clickhouse
15. Poco::Net::TCPServerDispatcher::run() @ 0x1753fc9b in /usr/bin/clickhouse
16. Poco::PooledThread::run() @ 0x176cf0a7 in /usr/bin/clickhouse
17. Poco::ThreadImpl::runnableEntry(void*) @ 0x176ccadd in /usr/bin/clickhouse
18. ? @ 0x7f331838e609 in ?
19. __clone @ 0x7f33182b3133 in ?
. (UNKNOWN_IDENTIFIER)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants