Skip to content

NOT_FOUND_COLUMN_IN_BLOCK for column equals(...) #54511

Closed

Description

@vitlibar

The following SELECT query throws an exception:

CREATE TABLE tbl ( type String, value String ) ENGINE = MergeTree() ORDER BY tuple();

SELECT b
FROM
(
    SELECT
        if(type = 'ABC', groupArray(value) OVER (), []) AS a,
        arrayMap(x -> has(a, x), ['L1', 'L2']) AS b
    FROM tbl
    WHERE type = 'ABC'
);
2023.09.11 15:36:51.017637 [ 28757 ] {44844c00-9999-43b4-8687-2728a7592387} <Error> executeQuery: Code: 10. DB::Exception: Not found column equals(type, 'ABC') in block value String String(size = 0), ['L1', 'L2'] Array(String) Const(size = 0, Array(size = 1, UInt64(size = 1), String(size = 2))), groupArray(value) OVER () Array(String) Array(size = 0, UInt64(size = 0), String(size = 0)). (NOT_FOUND_COLUMN_IN_BLOCK) (version 23.9.1.1) (from 127.0.0.1:35684) (in query: SELECT b FROM ( SELECT if(type = 'ABC', groupArray(value) OVER (), []) AS a, arrayMap(x -> has(a, x), ['L1', 'L2']) AS b FROM tbl WHERE type = 'ABC' )), Stack trace (when copying this message, always include the lines below):

0. /clickhouse/contrib/llvm-project/libcxx/include/exception:134: std::exception::capture() in /clickhouse/build/programs/clickhouse
1. /clickhouse/contrib/llvm-project/libcxx/include/exception:112: std::exception::exception[abi:v15000]() in /clickhouse/build/programs/clickhouse
2. /clickhouse/base/poco/Foundation/src/Exception.cpp:27: Poco::Exception::Exception(String const&, int) in /clickhouse/build/programs/clickhouse
3. /clickhouse/src/Common/Exception.cpp:96: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) in /clickhouse/build/programs/clickhouse
4. /clickhouse/src/Common/Exception.h:73: DB::Exception::Exception(String&&, int, bool) in /clickhouse/build/programs/clickhouse
5. /clickhouse/src/Common/Exception.h:101: DB::Exception::Exception<String const&, String>(int, FormatStringHelperImpl<std::type_identity<String const&>::type, std::type_identity<String>::type>, String const&, String&&) in /clickhouse/build/programs/clickhouse
6. /clickhouse/src/Interpreters/ActionsDAG.cpp:656: DB::ActionsDAG::updateHeader(DB::Block) const in /clickhouse/build/programs/clickhouse
7. /clickhouse/src/Processors/Transforms/ExpressionTransform.cpp:8: DB::ExpressionTransform::transformHeader(DB::Block, DB::ActionsDAG const&) in /clickhouse/build/programs/clickhouse
8. /clickhouse/src/Processors/QueryPlan/ExpressionStep.cpp:31: DB::ExpressionStep::ExpressionStep(DB::DataStream const&, std::shared_ptr<DB::ActionsDAG> const&) in /clickhouse/build/programs/clickhouse
9. /clickhouse/contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:714: std::__unique_if<DB::ExpressionStep>::__unique_single std::make_unique[abi:v15000]<DB::ExpressionStep, DB::DataStream const&, std::shared_ptr<DB::ActionsDAG> const&>(DB::DataStream const&, std::shared_ptr<DB::ActionsDAG> const&) in /clickhouse/build/programs/clickhouse
10. /clickhouse/src/Interpreters/InterpreterSelectQuery.cpp:2776: DB::InterpreterSelectQuery::executeExpression(DB::QueryPlan&, std::shared_ptr<DB::ActionsDAG> const&, String const&) in /clickhouse/build/programs/clickhouse
11. /clickhouse/src/Interpreters/InterpreterSelectQuery.cpp:1795: DB::InterpreterSelectQuery::executeImpl(DB::QueryPlan&, std::optional<DB::Pipe>) in /clickhouse/build/programs/clickhouse
12. /clickhouse/src/Interpreters/InterpreterSelectQuery.cpp:875: DB::InterpreterSelectQuery::buildQueryPlan(DB::QueryPlan&) in /clickhouse/build/programs/clickhouse
13. /clickhouse/src/Interpreters/InterpreterSelectWithUnionQuery.cpp:303: DB::InterpreterSelectWithUnionQuery::buildQueryPlan(DB::QueryPlan&) in /clickhouse/build/programs/clickhouse
14. /clickhouse/src/Interpreters/InterpreterSelectQuery.cpp:2415: DB::InterpreterSelectQuery::executeFetchColumns(DB::QueryProcessingStage::Enum, DB::QueryPlan&) in /clickhouse/build/programs/clickhouse
15. /clickhouse/src/Interpreters/InterpreterSelectQuery.cpp:0: DB::InterpreterSelectQuery::executeImpl(DB::QueryPlan&, std::optional<DB::Pipe>) in /clickhouse/build/programs/clickhouse
16. /clickhouse/src/Interpreters/InterpreterSelectQuery.cpp:875: DB::InterpreterSelectQuery::buildQueryPlan(DB::QueryPlan&) in /clickhouse/build/programs/clickhouse
17. /clickhouse/src/Interpreters/InterpreterSelectWithUnionQuery.cpp:303: DB::InterpreterSelectWithUnionQuery::buildQueryPlan(DB::QueryPlan&) in /clickhouse/build/programs/clickhouse
18. /clickhouse/src/Interpreters/InterpreterSelectWithUnionQuery.cpp:377: DB::InterpreterSelectWithUnionQuery::execute() in /clickhouse/build/programs/clickhouse
19. /clickhouse/src/Interpreters/executeQuery.cpp:1091: DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) in /clickhouse/build/programs/clickhouse
20. /clickhouse/src/Interpreters/executeQuery.cpp:1229: DB::executeQuery(String const&, std::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum) in /clickhouse/build/programs/clickhouse
21. /clickhouse/src/Server/TCPHandler.cpp:496: DB::TCPHandler::runImpl() in /clickhouse/build/programs/clickhouse
22. /clickhouse/src/Server/TCPHandler.cpp:2124: DB::TCPHandler::run() in /clickhouse/build/programs/clickhouse
23. /clickhouse/base/poco/Net/src/TCPServerConnection.cpp:43: Poco::Net::TCPServerConnection::start() in /clickhouse/build/programs/clickhouse
24. /clickhouse/base/poco/Net/src/TCPServerDispatcher.cpp:115: Poco::Net::TCPServerDispatcher::run() in /clickhouse/build/programs/clickhouse
25. /clickhouse/base/poco/Foundation/src/ThreadPool.cpp:188: Poco::PooledThread::run() in /clickhouse/build/programs/clickhouse
26. /clickhouse/base/poco/Foundation/src/Thread.cpp:46: Poco::(anonymous namespace)::RunnableHolder::run() in /clickhouse/build/programs/clickhouse
27. /clickhouse/base/poco/Foundation/src/Thread_POSIX.cpp:335: Poco::ThreadImpl::runnableEntry(void*) in /clickhouse/build/programs/clickhouse
28. ? in ?
29. ? in ?

However a similar SELECT query works successfully:

SELECT b
FROM
(
    SELECT
        if(type = 'ABC', groupArray(value) OVER (), []) AS a,
        [has(a, 'L1'), has(a, 'L2')] AS b
    FROM tbl
    WHERE type = 'ABC'
)

Activity

  1. added
    unexpected behaviour
    on Sep 11, 2023
  2. vitlibar commented on Sep 11, 2023

    @vitlibar
    MemberAuthor

    With the experimental analyzer (set allow_experimental_analyzer=1) there is no issue, both SELECT queries works without exceptions.

  3. assigned and unassigned on Sep 11, 2023
  4. kirik commented on Sep 13, 2023

    @kirik

    Possible same issue here.

    https://fiddle.clickhouse.com/b89e6c78-a9e1-43a9-8a08-d324c503ea3c - getting NOT_FOUND_COLUMN_IN_BLOCK.

    With set allow_experimental_analyzer=1 works with no problems.

    Also query is working fine before v23.

  5. added a commit that references this issue on Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    unexpected behaviour

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions