**Describe the bug**
[A link to the report
](https://s3.amazonaws.com/clickhouse-test-reports/0/8af95a6fc2cff71db3407c5da987f6e7565f7148/fuzzer_astfuzzerasan//report.html)
**How to reproduce**
```sql
SELECT time, round(exp_smooth, 10), bar(exp_smooth, -9223372036854775807, 1048575, 50) AS bar FROM (SELECT 2 OR (number = 0) OR (number >= 1) AS value, number AS time, exponentialTimeDecayedSum(2147483646)(value, time) OVER (RANGE BETWEEN CURRENT ROW AND CURRENT ROW) AS exp_smooth FROM numbers(2147483647) WHERE 10) WHERE 25
```

```
2022.10.18 17:15:14.590592 [ 197608 ] {d41426f1-7c52-43ce-b387-ea0eb39100ea} <Fatal> : Logical error: 'LogicalExpressionsOptimizer: parent node information is corrupted'.
2022.10.18 17:15:14.591017 [ 197606 ] {} <Trace> BaseDaemon: Received signal 6
2022.10.18 17:15:14.591676 [ 197931 ] {} <Fatal> BaseDaemon: ########################################
2022.10.18 17:15:14.591948 [ 197931 ] {} <Fatal> BaseDaemon: (version 22.10.1.1 (official build), build id: AD76F1D00331FF83B84FF51C30F41B5C5FC116B2) (from thread 197608) (query_id: d41426f1-7c52-43ce-b387-ea0eb39100ea) (query: SELECT time, round(exp_smooth, 10), bar(exp_smooth, -9223372036854775807, 1048575, 50) AS bar FROM (SELECT 2 OR (number = 0) OR (number >= 1) AS value, number AS time, exponentialTimeDecayedSum(2147483646)(value, time) OVER (RANGE BETWEEN CURRENT ROW AND CURRENT ROW) AS exp_smooth FROM numbers(2147483647) WHERE 10) WHERE 25) Received signal Aborted (6)
2022.10.18 17:15:14.592063 [ 197931 ] {} <Fatal> BaseDaemon:
2022.10.18 17:15:14.592207 [ 197931 ] {} <Fatal> BaseDaemon: Stack trace: 0x7f199d53803b 0x7f199d517859 0x1ead443b 0x1ead497b 0x30588a8d 0x30586616 0x3049bfa0 0x2fd7a180 0x2fd71e5e 0x2fd6b70b 0x2fe492d6 0x2fe4533d 0x2fe4b772 0x306bc90f 0x2fee6bec 0x2fd6d3cf 0x2fd6b70b 0x2fe492d6 0x2fe4533d 0x2fcd2948 0x2fccff3b 0x3067b805 0x30674d20 0x329b5ba4 0x329e7563 0x3a2d366f 0x3a2d43f3 0x3a7a98dc 0x3a7a31c8 0x7f199d6ef609 0x7f199d614163
2022.10.18 17:15:14.592356 [ 197931 ] {} <Fatal> BaseDaemon: 3. raise @ 0x7f199d53803b in ?
2022.10.18 17:15:14.592468 [ 197931 ] {} <Fatal> BaseDaemon: 4. abort @ 0x7f199d517859 in ?
2022.10.18 17:15:14.693446 [ 197931 ] {} <Fatal> BaseDaemon: 5. ./build_docker/../src/Common/Exception.cpp:40: DB::abortOnFailedAssertion(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0x1ead443b in /usr/bin/clickhouse
2022.10.18 17:15:14.792436 [ 197931 ] {} <Fatal> BaseDaemon: 6.1. inlined from ./build_docker/../src/Common/Exception.cpp:63: DB::handle_error_code(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool, std::__1::vector<void*, std::__1::allocator<void*> > const&)
2022.10.18 17:15:14.792603 [ 197931 ] {} <Fatal> BaseDaemon: 6. ./build_docker/../src/Common/Exception.cpp:70: DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0x1ead497b in /usr/bin/clickhouse
2022.10.18 17:15:14.879039 [ 197931 ] {} <Fatal> BaseDaemon: 7. ./build_docker/../src/Interpreters/LogicalExpressionsOptimizer.cpp:154: DB::LogicalExpressionsOptimizer::collectDisjunctiveEqualityChains() @ 0x30588a8d in /usr/bin/clickhouse
2022.10.18 17:15:14.960704 [ 197931 ] {} <Fatal> BaseDaemon: 8. ./build_docker/../src/Interpreters/LogicalExpressionsOptimizer.cpp:63: DB::LogicalExpressionsOptimizer::perform() @ 0x30586616 in /usr/bin/clickhouse
2022.10.18 17:15:15.000216 [ 197836 ] {} <Trace> AsynchronousMetrics: MemoryTracking: was 1.67 GiB, peak 1.67 GiB, will set to 1.80 GiB (RSS), difference: 140.41 MiB
2022.10.18 17:15:15.204321 [ 197931 ] {} <Fatal> BaseDaemon: 9. ./build_docker/../src/Interpreters/TreeRewriter.cpp:0: DB::TreeRewriter::analyzeSelect(std::__1::shared_ptr<DB::IAST>&, DB::TreeRewriterResult&&, DB::SelectQueryOptions const&, std::__1::vector<DB::TableWithColumnNamesAndTypes, std::__1::allocator<DB::TableWithColumnNamesAndTypes> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::shared_ptr<DB::TableJoin>) const @ 0x3049bfa0 in /usr/bin/clickhouse
2022.10.18 17:15:15.654206 [ 197931 ] {} <Fatal> BaseDaemon: 10. ./build_docker/../src/Interpreters/InterpreterSelectQuery.cpp:505: DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context> const&, std::__1::optional<DB::Pipe>, std::__1::shared_ptr<DB::IStorage> const&, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::shared_ptr<DB::PreparedSets>)::$_1::operator()(bool) const @ 0x2fd7a180 in /usr/bin/clickhouse
2022.10.18 17:15:16.000214 [ 197836 ] {} <Trace> AsynchronousMetrics: MemoryTracking: was 1.80 GiB, peak 1.80 GiB, will set to 1.87 GiB (RSS), difference: 70.72 MiB
2022.10.18 17:15:16.078066 [ 197931 ] {} <Fatal> BaseDaemon: 11. ./build_docker/../src/Interpreters/InterpreterSelectQuery.cpp:0: DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context> const&, std::__1::optional<DB::Pipe>, std::__1::shared_ptr<DB::IStorage> const&, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::shared_ptr<DB::PreparedSets>) @ 0x2fd71e5e in /usr/bin/clickhouse
2022.10.18 17:15:16.510060 [ 197931 ] {} <Fatal> BaseDaemon: 12. ./build_docker/../src/Interpreters/InterpreterSelectQuery.cpp:192: DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context> const&, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x2fd6b70b in /usr/bin/clickhouse
2022.10.18 17:15:16.644165 [ 197931 ] {} <Fatal> BaseDaemon: 13. ./build_docker/../src/Interpreters/InterpreterSelectWithUnionQuery.cpp:247: DB::InterpreterSelectWithUnionQuery::buildCurrentChildInterpreter(std::__1::shared_ptr<DB::IAST> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x2fe492d6 in /usr/bin/clickhouse
^C2022.10.18 17:15:16.730987 [ 197606 ] {} <Trace> BaseDaemon: Received signal 2
2022.10.18 17:15:16.731054 [ 197606 ] {} <Information> Application: Received termination signal (Interrupt)
2022.10.18 17:15:16.731106 [ 197605 ] {} <Debug> Application: Received termination signal.
2022.10.18 17:15:16.731155 [ 197605 ] {} <Debug> Application: Waiting for current connections to close.
2022.10.18 17:15:16.762459 [ 197931 ] {} <Fatal> BaseDaemon: 14. ./build_docker/../src/Interpreters/InterpreterSelectWithUnionQuery.cpp:0: DB::InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context>, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x2fe4533d in /usr/bin/clickhouse
```
{
public:
    explicit RestoreAliasOnExitScope(String & alias_)
        : alias(alias_)
        , copy(alias_)
    {}
    ~RestoreAliasOnExitScope()
    {
        alias = copy;
    }
private:
    String & alias;
    const String copy;
};
void QueryNormalizer::visit(ASTIdentifier & node, ASTPtr & ast, Data & data)
{
    auto & current_asts = data.current_asts;
    String & current_alias = data.current_alias;
    if (!IdentifierSemantic::getColumnName(node))
        return;
    if (data.settings.prefer_column_name_to_alias)
    {
        if (data.source_columns_set.find(node.name()) != data.source_columns_set.end())
            return;
    }
    
    auto it_alias = data.aliases.find(node.name());
    if (!data.allow_self_aliases && current_alias == node.name())
        throw Exception(ErrorCodes::CYCLIC_ALIASES, "Self referencing of {} to {}. Cyclic alias", backQuote(current_alias), backQuote(node.name()));
    if (it_alias != data.aliases.end() && current_alias != node.name())