```
WITH
    a AS
    (
        SELECT
            t1.number AS n1,
            t2.number AS n2
        FROM numbers(1) AS t1, numbers(1) AS t2
    ),
    b AS
    (
        SELECT sum(n1) AS s
        FROM a
    )
SELECT *
FROM a AS l, b AS r
SETTINGS allow_experimental_analyzer = 1

Query id: 3e4256ae-2d4a-413a-8af0-b1d6cd645bfc


0 rows in set. Elapsed: 0.001 sec.

Received exception from server (version 22.12.1):
Code: 60. DB::Exception: Received from localhost:9000. DB::Exception: Table default.a doesn't exist. Stack trace:

0. ./build_docker/../src/Common/Exception.cpp:77: DB::Exception::Exception(DB::Exception::MessageMasked const&, int, bool) @ 0xe469f1a in /usr/bin/clickhouse
1. ./build_docker/../contrib/libcxx/include/string:1499: DB::Exception& std::__1::optional<DB::Exception>::emplace[abi:v15003]<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, int const&, void>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&&, int const&) @ 0x1375a8c2 in /usr/bin/clickhouse
2. ./build_docker/../contrib/libcxx/include/string:1499: DB::DatabaseCatalog::getTableImpl(DB::StorageID const&, std::__1::shared_ptr<DB::Context const>, std::__1::optional<DB::Exception>*) const @ 0x137d0568 in /usr/bin/clickhouse
3. ./build_docker/../contrib/libcxx/include/__memory/shared_ptr.h:801: DB::DatabaseCatalog::getTable(DB::StorageID const&, std::__1::shared_ptr<DB::Context const>) const @ 0x137d826a in /usr/bin/clickhouse
4. ./build_docker/../src/Analyzer/Passes/QueryAnalysisPass.cpp:2027: DB::(anonymous namespace)::QueryAnalyzer::tryResolveIdentifier(DB::(anonymous namespace)::IdentifierLookup const&, DB::(anonymous namespace)::IdentifierResolveScope&, DB::(anonymous namespace)::IdentifierResolveSettings) @ 0x13d79ff6 in /usr/bin/clickhouse
5. ./build_docker/../src/Analyzer/Passes/QueryAnalysisPass.cpp:0: DB::(anonymous namespace)::QueryAnalyzer::resolveQuery(std::__1::shared_ptr<DB::IQueryTreeNode> const&, DB::(anonymous namespace)::IdentifierResolveScope&) @ 0x13d60eca in /usr/bin/clickhouse
6. ./build_docker/../src/Analyzer/Passes/QueryAnalysisPass.cpp:5419: DB::(anonymous namespace)::QueryAnalyzer::resolveQueryJoinTreeNode(std::__1::shared_ptr<DB::IQueryTreeNode>&, DB::(anonymous namespace)::IdentifierResolveScope&, DB::(anonymous namespace)::QueryExpressionsAliasVisitor&) @ 0x13d70951 in /usr/bin/clickhouse
7. ./build_docker/../contrib/libcxx/include/vector:1457: DB::(anonymous namespace)::QueryAnalyzer::resolveQueryJoinTreeNode(std::__1::shared_ptr<DB::IQueryTreeNode>&, DB::(anonymous namespace)::IdentifierResolveScope&, DB::(anonymous namespace)::QueryExpressionsAliasVisitor&) @ 0x13d6fce3 in /usr/bin/clickhouse
8. ./build_docker/../contrib/libcxx/include/vector:1457: DB::(anonymous namespace)::QueryAnalyzer::resolveQuery(std::__1::shared_ptr<DB::IQueryTreeNode> const&, DB::(anonymous namespace)::IdentifierResolveScope&) @ 0x13d61921 in /usr/bin/clickhouse
9. ./build_docker/../src/Analyzer/Passes/QueryAnalysisPass.cpp:989: DB::QueryAnalysisPass::run(std::__1::shared_ptr<DB::IQueryTreeNode>, std::__1::shared_ptr<DB::Context const>) @ 0x13d5f820 in /usr/bin/clickhouse
10. ./build_docker/../src/Analyzer/QueryTreePassManager.cpp:97: DB::QueryTreePassManager::run(std::__1::shared_ptr<DB::IQueryTreeNode>) @ 0x13d5e245 in /usr/bin/clickhouse
11. ./build_docker/../contrib/libcxx/include/vector:434: DB::InterpreterSelectQueryAnalyzer::InterpreterSelectQueryAnalyzer(std::__1::shared_ptr<DB::IAST> const&, DB::SelectQueryOptions const&, std::__1::shared_ptr<DB::Context const>) @ 0x13e6a8ba in /usr/bin/clickhouse
12. ./build_docker/../contrib/libcxx/include/__memory/unique_ptr.h:0: DB::InterpreterFactory::get(std::__1::shared_ptr<DB::IAST>&, std::__1::shared_ptr<DB::Context>, DB::SelectQueryOptions const&) @ 0x13de2c2a in /usr/bin/clickhouse
13. ./build_docker/../src/Interpreters/executeQuery.cpp:0: DB::executeQueryImpl(char const*, char const*, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x141c1da0 in /usr/bin/clickhouse
14. ./build_docker/../src/Interpreters/executeQuery.cpp:1082: 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) @ 0x141bf68d in /usr/bin/clickhouse
15. ./build_docker/../src/Server/TCPHandler.cpp:0: DB::TCPHandler::runImpl() @ 0x14e76fee in /usr/bin/clickhouse
16. ./build_docker/../src/Server/TCPHandler.cpp:1904: DB::TCPHandler::run() @ 0x14e8a4f9 in /usr/bin/clickhouse
17. ./build_docker/../contrib/poco/Net/src/TCPServerConnection.cpp:57: Poco::Net::TCPServerConnection::start() @ 0x17ce03b4 in /usr/bin/clickhouse
18. ./build_docker/../contrib/libcxx/include/__memory/unique_ptr.h:48: Poco::Net::TCPServerDispatcher::run() @ 0x17ce1d5b in /usr/bin/clickhouse
19. ./build_docker/../contrib/poco/Foundation/src/ThreadPool.cpp:213: Poco::PooledThread::run() @ 0x17e70b67 in /usr/bin/clickhouse
20. ./build_docker/../contrib/poco/Foundation/include/Poco/SharedPtr.h:277: Poco::ThreadImpl::runnableEntry(void*) @ 0x17e6e59d in /usr/bin/clickhouse
21. ? @ 0x7fea26f61609 in ?
22. __clone @ 0x7fea26e86133 in ?
. (UNKNOWN_TABLE)

ip-172-31-16-30.us-east-2.compute.internal :) WITH a AS
                                              (
                                              SELECT t1.number as n1, t2.number as n2
                                              FROM numbers(1) as t1, numbers(1) as t2
                                              ),
                                              b AS
                                              (
                                              SELECT sum(n1) as s
                                              FROM a
                                              )
                                              SELECT *
                                              FROM a l, b r
                                              SETTINGS allow_experimental_analyzer = 0

WITH
    a AS
    (
        SELECT
            t1.number AS n1,
            t2.number AS n2
        FROM numbers(1) AS t1, numbers(1) AS t2
    ),
    b AS
    (
        SELECT sum(n1) AS s
        FROM a
    )
SELECT *
FROM a AS l, b AS r
SETTINGS allow_experimental_analyzer = 0

Query id: 09e947a7-e32a-4a23-9161-39582b0f86b0

┌─n1─┬─n2─┬─s─┐
│  0 │  0 │ 0 │
└────┴────┴───┘

1 row in set. Elapsed: 0.028 sec.
```
*
      * Example: SELECT * FROM test_table LIMIT 1 IN 1;
      */
    if (is_special_function_in)
    {
        const auto * first_argument_constant_node = function_arguments[0]->as<ConstantNode>();
        const auto * second_argument_constant_node = function_arguments[1]->as<ConstantNode>();
        if (first_argument_constant_node && second_argument_constant_node)
        {
            const auto & first_argument_constant_type = first_argument_constant_node->getResultType();
            const auto & second_argument_constant_literal = second_argument_constant_node->getValue();
            const auto & second_argument_constant_type = second_argument_constant_node->getResultType();
            auto set = makeSetForConstantValue(first_argument_constant_type,
                second_argument_constant_literal,
                second_argument_constant_type,
                scope.context->getSettingsRef());
            
            auto column_set = ColumnSet::create(1, std::move(set));
            argument_columns[1].column = ColumnConst::create(std::move(column_set), 1);
        }
    }
    std::shared_ptr<ConstantValue> constant_value;
    DataTypePtr result_type;
    try
    {
        auto function_base = function->build(argument_columns);
        result_type = function_base->getResultType();
        /** If function is suitable for constant folding try to convert it to constant.
          * Example: SELECT plus(1, 1);
          * Result: SELECT 2;