https://s3.amazonaws.com/clickhouse-test-reports/0/ec24f730b12074446b334eafbf94e7d505cdec6c/stress_test__debug__actions_.html


```
SELECT toDateTime64(toString(toString('0000-00-00 00:00:000000-00-00 00:00:00', toDateTime64(toDateTime64('655.36', -2, NULL)))), NULL) FROM t1_00850 GLOBAL INNER JOIN (SELECT toDateTime64(toDateTime64('6553.6', '', NULL), NULL), * FROM (SELECT * FROM t2_00850) INNER JOIN (SELECT toDateTime64('6553.7', 1024, NULL), * FROM t1_00850) USING (dummy)) USING (dummy)
```

```
2022.07.13 00:00:07.023917 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Debug> executeQuery: (from [::1]:41482) (comment: 00850_global_join_dups.sql) -- query from fuzzer
 SELECT toDateTime64(toString(toString('0000-00-00 00:00:000000-00-00 00:00:00', toDateTime64(toDateTime64('655.36', -2, NULL)))), NULL) FROM t1_00850 GLOBAL INNER JOIN (SELECT toDateTime64(toDateTime64('6553.6', '', NULL), NULL), * FROM (SELECT * FROM t2_00850) INNER JOIN (SELECT toDateTime64('6553.7', 1024, NULL), * FROM t1_00850) USING (dummy)) USING (dummy); (stage: Complete)2022.07.13 00:00:07.233173 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> ContextAccess (default): Access granted: SELECT(dummy) ON test_21.t2_00850
2022.07.13 00:00:07.244994 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> ContextAccess (default): Access granted: SELECT(dummy) ON test_21.t1_00850
2022.07.13 00:00:07.288479 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> ContextAccess (default): Access granted: SELECT(dummy) ON test_21.t2_00850
2022.07.13 00:00:07.456588 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> ContextAccess (default): Access granted: SELECT(dummy) ON test_21.t1_00850
2022.07.13 00:00:07.461998 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Debug> TableJoin: Left JOIN converting actions: empty
2022.07.13 00:00:07.464626 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Debug> TableJoin: Right JOIN converting actions: empty
2022.07.13 00:00:07.465885 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> FullSortingMergeJoin: Will use full sorting merge join
2022.07.13 00:00:07.575593 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> ContextAccess (default): Access granted: SELECT(dummy) ON test_21.t2_00850
2022.07.13 00:00:07.621874 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> ContextAccess (default): Access granted: SELECT(dummy) ON test_21.t1_00850
2022.07.13 00:00:07.721637 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> ContextAccess (default): Access granted: SELECT(dummy) ON test_21.t1_00850
2022.07.13 00:00:07.724186 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> InterpreterSelectQuery: Complete -> Complete
2022.07.13 00:00:07.728390 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Debug> TableJoin: Left JOIN converting actions: empty
2022.07.13 00:00:07.736440 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Debug> TableJoin: Right JOIN converting actions: empty
2022.07.13 00:00:07.744422 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> FullSortingMergeJoin: Will use full sorting merge join
2022.07.13 00:00:07.852283 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> ContextAccess (default): Access granted: SELECT(dummy) ON test_21.t2_00850
2022.07.13 00:00:07.868928 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> ContextAccess (default): Access granted: SELECT(dummy) ON test_21.t2_00850
2022.07.13 00:00:07.881920 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> InterpreterSelectQuery: Complete -> Complete
2022.07.13 00:00:07.889419 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> InterpreterSelectQuery: FetchColumns -> Complete
2022.07.13 00:00:07.922932 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Debug> JoiningTransform: Before join block: 'dummy UInt8 UInt8(size = 0)'
2022.07.13 00:00:07.925859 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Debug> JoiningTransform: After join block: 'dummy UInt8 UInt8(size = 0), dummy UInt8 UInt8(size = 0), toDateTime64('6553.7', 1024, NULL) Nullable(Nothing) Nullable(size = 0, Nothing(size = 0), UInt8(size = 0))'
2022.07.13 00:00:07.974440 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> MergeJoinTransform: Use MergeJoinTransform
2022.07.13 00:00:08.024326 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Debug> Connection (localhost:9000): Sent data for 2 scalars, total 2 rows in 0.000122579 sec., 16145 rows/sec., 16.20 KiB (127.63 MiB/sec.), no compression.
2022.07.13 00:00:08.028220 [ 1661 ] {1ffdf8a7-c768-47d7-a71e-bec1f6f27d81} <Debug> executeQuery: (from [::1]:41218, initial_query_id: bf6b0611-3b69-4a46-83e9-ba2bbcba5250) (comment: 00850_global_join_dups.sql) SELECT `t_local`.`dummy` FROM `test_21`.`t_local` (stage: Complete)
2022.07.13 00:00:08.094945 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Debug> Connection (localhost:9000): Sent data for 2 scalars, total 2 rows in 0.000134199 sec., 14767 rows/sec., 2.98 KiB (21.51 MiB/sec.), no compression.
2022.07.13 00:00:08.117853 [ 19108 ] {02f6446b-c5f1-4cc4-84ed-449bf05230db} <Debug> executeQuery: (from [::1]:41506, initial_query_id: bf6b0611-3b69-4a46-83e9-ba2bbcba5250) (comment: 00850_global_join_dups.sql) SELECT `t_local`.`dummy`, toDateTime64('6553.7', 1024, NULL) FROM `test_21`.`t_local` (stage: Complete)
2022.07.13 00:00:08.764100 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Test> Epoll: EINTR
2022.07.13 00:00:10.088155 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Test> Epoll: EINTR
2022.07.13 00:00:10.091679 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Test> Epoll: EINTR
2022.07.13 00:00:10.100270 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Test> Epoll: EINTR
2022.07.13 00:00:10.103504 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Test> Epoll: EINTR
2022.07.13 00:00:10.164106 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> MergeJoinAlgorithm: Finished pocessing in 2.192018023 seconds, left: 0 blocks, 0 rows; right: 0 blocks, 0 rows, max blocks loaded to memory: 0
2022.07.13 00:00:10.196465 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> MergeJoinAlgorithm: Finished pocessing in 2.224018286 seconds, left: 1 blocks, 1 rows; right: 1 blocks, 1 rows, max blocks loaded to memory: 0
2022.07.13 00:00:10.201542 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> MergeJoinAlgorithm: Finished pocessing in 2.228018319 seconds, left: 1 blocks, 1 rows; right: 1 blocks, 1 rows, max blocks loaded to memory: 0
2022.07.13 00:00:10.202640 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Trace> MergeJoinAlgorithm: Finished pocessing in 2.228018319 seconds, left: 1 blocks, 1 rows; right: 1 blocks, 1 rows, max blocks loaded to memory: 0
2022.07.13 00:00:10.223354 [ 20619 ] {bf6b0611-3b69-4a46-83e9-ba2bbcba5250} <Fatal> : Logical error: 'Invalid number of columns in chunk pushed to OutputPort. Expected 3, found 4
Header: dummy UInt8 UInt8(size = 0), dummy UInt8 UInt8(size = 0), toDateTime64('6553.7', 1024, NULL) Nullable(Nothing) Nullable(size = 0, Nothing(size = 0), UInt8(size = 0))
Chunk:  UInt8(size = 1) UInt8(size = 1) Nullable(size = 1, Nothing(size = 1), UInt8(size = 1)) Nullable(size = 1, Nothing(size = 1), UInt8(size = 1))
'.
2022.07.13 00:17:12.841254 [ 21690 ] {} <Fatal> BaseDaemon: ########################################
2022.07.13 00:17:12.862732 [ 21690 ] {} <Fatal> BaseDaemon: (version 22.7.1.1 (official build), build id: 77418886F3BA724B) (from thread 20619) (query_id: bf6b0611-3b69-4a46-83e9-ba2bbcba5250) (query: -- query from fuzzer
2022.07.13 00:17:12.937565 [ 21690 ] {} <Fatal> BaseDaemon:
2022.07.13 00:17:12.950392 [ 21690 ] {} <Fatal> BaseDaemon: Stack trace: 0x7f0f83bcb00b 0x7f0f83baa859 0x1709bd66 0x1709bdf5 0x1709bea5 0x26f2661c 0x2852c222 0x1731d31e 0x28019a2c 0x2800ef1f 0x2800f197 0x2800e312 0x2800d8b8 0x2800ba1e 0x26347c9b 0x26346d47 0x263468f2 0x26330377 0x26346857 0x26330362 0x26346857 0x26330362 0x2631bd23 0x2631b9f8 0x26a62947 0x26a6a0f7 0x26a4bbc3 0x26a48e52 0x26a47291 0x26adba59 0x26ad95a9 0x26ad8a87 0x269e9ad0 0x269e7f5d 0x26f2b559 0x26f28764 0x27f8d062 0x27f9c265 0x2c496179 0x2c496986 0x2c6dbcd4
2022.07.13 00:17:12.968547 [ 21690 ] {} <Fatal> BaseDaemon: 4. raise @ 0x7f0f83bcb00b in ?
2022.07.13 00:17:12.970155 [ 21690 ] {} <Fatal> BaseDaemon: 5. abort @ 0x7f0f83baa859 in ?
2022.07.13 00:17:13.345668 [ 21690 ] {} <Fatal> BaseDaemon: 6. /build/build_docker/../src/Common/Exception.cpp:40: DB::abortOnFailedAssertion(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0x1709bd66 in /usr/bin/clickhouse
2022.07.13 00:17:13.701373 [ 21690 ] {} <Fatal> BaseDaemon: 7. /build/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&) @ 0x1709bdf5 in /usr/bin/clickhouse
2022.07.13 00:17:14.044700 [ 21690 ] {} <Fatal> BaseDaemon: 8. /build/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) @ 0x1709bea5 in /usr/bin/clickhouse
2022.07.13 00:17:15.040604 [ 21690 ] {} <Fatal> BaseDaemon: 9. /build/build_docker/../src/Common/Exception.h:37: DB::Exception::Exception<unsigned long, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(int, fmt::v8::basic_format_string<char, fmt::v8::type_identity<unsigned long>::type, fmt::v8::type_identity<unsigned long>::type, fmt::v8::type_identity<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::type, fmt::v8::type_identity<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::type>, unsigned long&&, unsigned long&&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) @ 0x26f2661c in /usr/bin/clickhouse
2022.07.13 00:17:15.336936 [ 21690 ] {} <Fatal> BaseDaemon: 10.1. inlined from /build/build_docker/../src/Processors/Port.h:408: DB::OutputPort::pushData(DB::Port::State::Data)
2022.07.13 00:17:15.351552 [ 21690 ] {} <Fatal> BaseDaemon: 10.2. inlined from ../src/Processors/Port.h:396: DB::OutputPort::push(DB::Chunk)
2022.07.13 00:17:15.378404 [ 21690 ] {} <Fatal> BaseDaemon: 10. ../src/Processors/Merges/IMergingTransform.cpp:157: DB::IMergingTransformBase::prepare() @ 0x2852c222 in /usr/bin/clickhouse
2022.07.13 00:17:16.665598 [ 21690 ] {} <Fatal> BaseDaemon: 11. /build/build_docker/../src/Processors/IProcessor.h:190: DB::IProcessor::prepare(std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > const&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > const&) @ 0x1731d31e in /usr/bin/clickhouse
2022.07.13 00:17:17.042596 [ 21690 ] {} <Fatal> BaseDaemon: 12. /build/build_docker/../src/Processors/Executors/ExecutingGraph.cpp:269: DB::ExecutingGraph::updateNode(unsigned long, std::__1::queue<DB::ExecutingGraph::Node*, std::__1::deque<DB::ExecutingGraph::Node*, std::__1::allocator<DB::ExecutingGraph::Node*> > >&, std::__1::queue<DB::ExecutingGraph::Node*, std::__1::deque<DB::ExecutingGraph::Node*, std::__1::allocator<DB::ExecutingGraph::Node*> > >&) @ 0x28019a2c in /usr/bin/clickhouse
2022.07.13 00:17:17.471569 [ 21690 ] {} <Fatal> BaseDaemon: 13. /build/build_docker/../src/Processors/Executors/PipelineExecutor.cpp:241: DB::PipelineExecutor::executeStepImpl(unsigned long, std::__1::atomic<bool>*) @ 0x2800ef1f in /usr/bin/clickhouse
2022.07.13 00:17:17.979112 [ 21690 ] {} <Fatal> BaseDaemon: 14. /build/build_docker/../src/Processors/Executors/PipelineExecutor.cpp:187: DB::PipelineExecutor::executeSingleThread(unsigned long) @ 0x2800f197 in /usr/bin/clickhouse
2022.07.13 00:17:18.415886 [ 21690 ] {} <Fatal> BaseDaemon: 15. /build/build_docker/../src/Processors/Executors/PipelineExecutor.cpp:331: DB::PipelineExecutor::executeImpl(unsigned long) @ 0x2800e312 in /usr/bin/clickhouse
2022.07.13 00:17:18.974933 [ 21690 ] {} <Fatal> BaseDaemon: 16. /build/build_docker/../src/Processors/Executors/PipelineExecutor.cpp:88: DB::PipelineExecutor::execute(unsigned long) @ 0x2800d8b8 in /usr/bin/clickhouse
2022.07.13 00:17:19.221225 [ 21690 ] {} <Fatal> BaseDaemon: 17. /build/build_docker/../src/Processors/Executors/CompletedPipelineExecutor.cpp:98: DB::CompletedPipelineExecutor::execute() @ 0x2800ba1e in /usr/bin/clickhouse
2022.07.13 00:17:21.390334 [ 21690 ] {} <Fatal> BaseDaemon: 18. /build/build_docker/../src/Interpreters/GlobalSubqueriesVisitor.h:177: DB::GlobalSubqueriesMatcher::Data::addExternalStorage(std::__1::shared_ptr<DB::IAST>&, bool) @ 0x26347c9b in /usr/bin/clickhouse
2022.07.13 00:17:23.505326 [ 21690 ] {} <Fatal> BaseDaemon: 19. /build/build_docker/../src/Interpreters/GlobalSubqueriesVisitor.h:246: DB::GlobalSubqueriesMatcher::visit(DB::ASTTablesInSelectQueryElement&, std::__1::shared_ptr<DB::IAST>&, DB::GlobalSubqueriesMatcher::Data&) @ 0x26346d47 in /usr/bin/clickhouse
2022.07.13 00:17:25.467789 [ 21690 ] {} <Fatal> BaseDaemon: 20. /build/build_docker/../src/Interpreters/GlobalSubqueriesVisitor.h:200: DB::GlobalSubqueriesMatcher::visit(std::__1::shared_ptr<DB::IAST>&, DB::GlobalSubqueriesMatcher::Data&) @ 0x263468f2 in /usr/bin/clickhouse
2022.07.13 00:17:26.806039 [ 21690 ] {} <Fatal> BaseDaemon: 21. /build/build_docker/../src/Interpreters/InDepthNodeVisitor.h:34: DB::InDepthNodeVisitor<DB::GlobalSubqueriesMatcher, false, false, std::__1::shared_ptr<DB::IAST> >::visit(std::__1::shared_ptr<DB::IAST>&) @ 0x26330377 in /usr/bin/clickhouse
2022.07.13 00:17:28.887953 [ 21690 ] {} <Fatal> BaseDaemon: 22. /build/build_docker/../src/Interpreters/InDepthNodeVisitor.h:53: DB::InDepthNodeVisitor<DB::GlobalSubqueriesMatcher, false, false, std::__1::shared_ptr<DB::IAST> >::visitChildren(std::__1::shared_ptr<DB::IAST>&) @ 0x26346857 in /usr/bin/clickhouse
2022.07.13 00:17:30.662742 [ 21690 ] {} <Fatal> BaseDaemon: 23. /build/build_docker/../src/Interpreters/InDepthNodeVisitor.h:30: DB::InDepthNodeVisitor<DB::GlobalSubqueriesMatcher, false, false, std::__1::shared_ptr<DB::IAST> >::visit(std::__1::shared_ptr<DB::IAST>&) @ 0x26330362 in /usr/bin/clickhouse
2022.07.13 00:17:32.191387 [ 21690 ] {} <Fatal> BaseDaemon: 24. /build/build_docker/../src/Interpreters/InDepthNodeVisitor.h:53: DB::InDepthNodeVisitor<DB::GlobalSubqueriesMatcher, false, false, std::__1::shared_ptr<DB::IAST> >::visitChildren(std::__1::shared_ptr<DB::IAST>&) @ 0x26346857 in /usr/bin/clickhouse
2022.07.13 00:17:33.144794 [ 679 ] {} <Fatal> Application: Child process was terminated by signal 6.
```
}
                    
                    if (copy.type == ActionType::INPUT)
                    {
                        auto & input_copy = first_nodes.emplace_back(*cur.node);
                        assert(cur_data.to_first == nullptr);
                        cur_data.to_first = &input_copy;
                        new_inputs.push_back(cur.node);
                    }
                }
                else
                {
                    auto & copy = first_nodes.emplace_back(*cur.node);
                    cur_data.to_first = &copy;
                    
                    for (auto & child : copy.children)
                    {
                        child = data[child].to_first;
                        assert(child != nullptr);
                    }
                    if (cur_data.used_in_result)
                    {
                        
                        Node input_node;
                        input_node.type = ActionType::INPUT;
                        input_node.result_type = node.result_type;
                        input_node.result_name = node.result_name;
                        cur_data.to_second = &second_nodes.emplace_back(std::move(input_node));
                        new_inputs.push_back(cur.node);
                    }