**Describe the unexpected behaviour**
After successfully built ClickHouse binary on Power9 platform,I run `clickhouse-tests`,and clickhouse server segment fault.

**How to reproduce**
v21.11.4.14-stable
Run `clickhouse-tests`.
Several problems occured when run `clickhouse-tests`:
1.  There's no output on query `SELECT value FROM system.merge_tree_settings WHERE name = 'min_bytes_for_wide_part' `:
```
root@tserver-overlayregen:/clickhouse/ClickHouse/tests# ./clickhouse-test -b /clickhouse/ClickHouse/build/programs/clickhouse
Using queries from 'queries' directory
Using /clickhouse/ClickHouse/build/programs/clickhouse-client as client program (expecting split build)
Connecting to ClickHouse server... OK
Traceback (most recent call last):
  File "./clickhouse-test", line 1442, in <module>
    main(args)
  File "./clickhouse-test", line 1140, in main
    args.build_flags = collect_build_flags(args)
  File "./clickhouse-test", line 1032, in collect_build_flags
    value = int(clickhouse_execute(args, "SELECT value FROM system.merge_tree_settings WHERE name = 'min_bytes_for_wide_part'"))
ValueError: invalid literal for int() with base 10: b''
```

```
root@tserver-overlayregen:/clickhouse/ClickHouse/build# programs/clickhouse client
ClickHouse client version 21.11.4.14.
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 21.11.4 revision 54450.

tserver-overlayregen :) Cannot load data for command line suggestions: Code: 49. DB::Exception: Received from localhost:9000. DB::Exception: Invalid number of rows in Chunk column String position 0: expected 83, got 20. (LOGICAL_ERROR) (version 21.11.4.14)
                        
tserver-overlayregen :) SELECT value FROM system.merge_tree_settings WHERE name = 'min_bytes_for_wide_part';

SELECT value
FROM system.merge_tree_settings
WHERE name = 'min_bytes_for_wide_part'

Query id: 9653c397-cbd4-499f-a3e4-85ee6808f044

Ok.

0 rows in set. Elapsed: 0.006 sec. 

```
2.  After modifying `clickhouse-tests` to pass the query,it successfully to run next tests,and ClickHouse server segment fault:
```
2021.11.19 14:49:57.892883 [ 318580 ] {8328680e-22de-4e88-bc29-02399199c6ec} <Error> executeQuery: Code: 70. DB::Exception: Conversion from UInt64 to AggregateFunction(count) is not supported: while converting source column `count()` to destination column `count()`. (CANNOT_CONVERT_TYPE) (version 21.11.4.14) (from 127.0.0.1:52288) (comment: 02096_rename_atomic_hang.sql) (in query: select count() from db_hang.test_mv;), Stack trace (when copying this message, always include the lines below):

0. Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x22f0e7d0 in ?
1. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0x1795b5cc in /clickhouse/ClickHouse/build/programs/clickhouse
2. DB::FunctionCast<DB::CastInternalName>::createAggregateFunctionWrapper(std::__1::shared_ptr<DB::IDataType const> const&, DB::DataTypeAggregateFunction const*) const @ 0x1a71b524 in /clickhouse/ClickHouse/build/programs/clickhouse
3. DB::FunctionCast<DB::CastInternalName>::prepareImpl(std::__1::shared_ptr<DB::IDataType const> const&, std::__1::shared_ptr<DB::IDataType const> const&, bool) const @ 0x1a717a7c in /clickhouse/ClickHouse/build/programs/clickhouse
4. DB::FunctionCast<DB::CastInternalName>::prepareRemoveNullable(std::__1::shared_ptr<DB::IDataType const> const&, std::__1::shared_ptr<DB::IDataType const> const&, bool) const @ 0x1a716a68 in /clickhouse/ClickHouse/build/programs/clickhouse
5. DB::FunctionCast<DB::CastInternalName>::prepareUnpackDictionaries(std::__1::shared_ptr<DB::IDataType const> const&, std::__1::shared_ptr<DB::IDataType const> const&) const @ 0x1a714b74 in /clickhouse/ClickHouse/build/programs/clickhouse
6. DB::FunctionCast<DB::CastInternalName>::prepare(std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName> > const&) const @ 0x1a714288 in /clickhouse/ClickHouse/build/programs/clickhouse
7. DB::ActionsDAG::addFunction(std::__1::shared_ptr<DB::IFunctionOverloadResolver> const&, std::__1::vector<DB::ActionsDAG::Node const*, std::__1::allocator<DB::ActionsDAG::Node const*> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) @ 0x20dccf98 in ?
8. DB::ActionsDAG::makeConvertingActions(std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName> > const&, std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName> > const&, DB::ActionsDAG::MatchColumnsMode, bool, bool, std::__1::unordered_map<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> >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >*) @ 0x20dd8d20 in ?
9. DB::StorageMaterializedView::read(DB::QueryPlan&, 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&, DB::SelectQueryInfo&, std::__1::shared_ptr<DB::Context const>, DB::QueryProcessingStage::Enum, unsigned long, unsigned int) @ 0x219b8de0 in ?
10. DB::InterpreterSelectQuery::executeFetchColumns(DB::QueryProcessingStage::Enum, DB::QueryPlan&) @ 0x212b6b44 in ?
11. DB::InterpreterSelectQuery::executeImpl(DB::QueryPlan&, std::__1::optional<DB::Pipe>) @ 0x212b06d8 in ?
12. DB::InterpreterSelectQuery::buildQueryPlan(DB::QueryPlan&) @ 0x212b00b0 in ?
13. DB::InterpreterSelectWithUnionQuery::buildQueryPlan(DB::QueryPlan&) @ 0x21467f08 in ?
14. DB::InterpreterSelectWithUnionQuery::execute() @ 0x21468c00 in ?
15. DB::executeQueryImpl(char const*, char const*, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x21681d5c in ?
16. 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) @ 0x216801a4 in ?
17. DB::TCPHandler::runImpl() @ 0x2201f744 in ?
18. DB::TCPHandler::run() @ 0x22031678 in ?
19. Poco::Net::TCPServerConnection::start() @ 0x22e46c2c in ?
20. Poco::Net::TCPServerDispatcher::run() @ 0x22e474f4 in ?
21. Poco::PooledThread::run() @ 0x22f980f4 in ?
22. Poco::(anonymous namespace)::RunnableHolder::run() @ 0x22f960ac in ?
23. Poco::ThreadImpl::runnableEntry(void*) @ 0x22f94870 in ?
24. start_thread @ 0x9818 in /usr/lib/powerpc64le-linux-gnu/libpthread-2.31.so

2021.11.19 14:49:57.893197 [ 318580 ] {8328680e-22de-4e88-bc29-02399199c6ec} <Error> TCPHandler: Code: 70. DB::Exception: Conversion from UInt64 to AggregateFunction(count) is not supported: while converting source column `count()` to destination column `count()`. (CANNOT_CONVERT_TYPE), Stack trace (when copying this message, always include the lines below):

0. Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x22f0e7d0 in ?
1. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0x1795b5cc in /clickhouse/ClickHouse/build/programs/clickhouse
2. DB::FunctionCast<DB::CastInternalName>::createAggregateFunctionWrapper(std::__1::shared_ptr<DB::IDataType const> const&, DB::DataTypeAggregateFunction const*) const @ 0x1a71b524 in /clickhouse/ClickHouse/build/programs/clickhouse
3. DB::FunctionCast<DB::CastInternalName>::prepareImpl(std::__1::shared_ptr<DB::IDataType const> const&, std::__1::shared_ptr<DB::IDataType const> const&, bool) const @ 0x1a717a7c in /clickhouse/ClickHouse/build/programs/clickhouse
4. DB::FunctionCast<DB::CastInternalName>::prepareRemoveNullable(std::__1::shared_ptr<DB::IDataType const> const&, std::__1::shared_ptr<DB::IDataType const> const&, bool) const @ 0x1a716a68 in /clickhouse/ClickHouse/build/programs/clickhouse
5. DB::FunctionCast<DB::CastInternalName>::prepareUnpackDictionaries(std::__1::shared_ptr<DB::IDataType const> const&, std::__1::shared_ptr<DB::IDataType const> const&) const @ 0x1a714b74 in /clickhouse/ClickHouse/build/programs/clickhouse
6. DB::FunctionCast<DB::CastInternalName>::prepare(std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName> > const&) const @ 0x1a714288 in /clickhouse/ClickHouse/build/programs/clickhouse
7. DB::ActionsDAG::addFunction(std::__1::shared_ptr<DB::IFunctionOverloadResolver> const&, std::__1::vector<DB::ActionsDAG::Node const*, std::__1::allocator<DB::ActionsDAG::Node const*> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) @ 0x20dccf98 in ?
8. DB::ActionsDAG::makeConvertingActions(std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName> > const&, std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName> > const&, DB::ActionsDAG::MatchColumnsMode, bool, bool, std::__1::unordered_map<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> >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >*) @ 0x20dd8d20 in ?
9. DB::StorageMaterializedView::read(DB::QueryPlan&, 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&, DB::SelectQueryInfo&, std::__1::shared_ptr<DB::Context const>, DB::QueryProcessingStage::Enum, unsigned long, unsigned int) @ 0x219b8de0 in ?
10. DB::InterpreterSelectQuery::executeFetchColumns(DB::QueryProcessingStage::Enum, DB::QueryPlan&) @ 0x212b6b44 in ?
11. DB::InterpreterSelectQuery::executeImpl(DB::QueryPlan&, std::__1::optional<DB::Pipe>) @ 0x212b06d8 in ?
12. DB::InterpreterSelectQuery::buildQueryPlan(DB::QueryPlan&) @ 0x212b00b0 in ?
13. DB::InterpreterSelectWithUnionQuery::buildQueryPlan(DB::QueryPlan&) @ 0x21467f08 in ?
14. DB::InterpreterSelectWithUnionQuery::execute() @ 0x21468c00 in ?
15. DB::executeQueryImpl(char const*, char const*, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x21681d5c in ?
16. 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) @ 0x216801a4 in ?
17. DB::TCPHandler::runImpl() @ 0x2201f744 in ?
18. DB::TCPHandler::run() @ 0x22031678 in ?
19. Poco::Net::TCPServerConnection::start() @ 0x22e46c2c in ?
20. Poco::Net::TCPServerDispatcher::run() @ 0x22e474f4 in ?
21. Poco::PooledThread::run() @ 0x22f980f4 in ?
22. Poco::(anonymous namespace)::RunnableHolder::run() @ 0x22f960ac in ?
23. Poco::ThreadImpl::runnableEntry(void*) @ 0x22f94870 in ?
24. start_thread @ 0x9818 in /usr/lib/powerpc64le-linux-gnu/libpthread-2.31.so

2021.11.19 14:49:57.893334 [ 318580 ] {8328680e-22de-4e88-bc29-02399199c6ec} <Debug> MemoryTracker: Peak memory usage (for query): 0.00 B.
2021.11.19 14:49:57.893358 [ 318580 ] {} <Debug> TCPHandler: Processed in 0.002127228 sec.
2021.11.19 14:49:57.893636 [ 318580 ] {} <Debug> TCPHandler: Done processing connection.
2021.11.19 14:49:57.893671 [ 318580 ] {} <Debug> TCP-Session: aef81ccf-fd9b-41a2-aef8-1ccffd9bd1a2 Destroying unnamed session of user 94309d50-4f52-5250-31bd-74fecac179db
2021.11.19 14:49:57.899873 [ 318579 ] {} <Trace> HTTPHandler-factory: HTTP Request for HTTPHandler-factory. Method: POST, Address: 127.0.0.1:41212, User-Agent: (none), Length: 0, Content Type: , Transfer Encoding: identity, X-Forwarded-For: (none)
2021.11.19 14:49:57.899949 [ 318579 ] {} <Trace> DynamicQueryHandler: Request URI: /?query=DROP+DATABASE+test_vrfyu7&database=system&connect_timeout=599&receive_timeout=599&send_timeout=599&http_connection_timeout=599&http_receive_timeout=599&http_send_timeout=599&log_comment=02096_rename_atomic_hang.sql
2021.11.19 14:49:57.899997 [ 318579 ] {} <Debug> HTTP-Session: 13945d52-0212-415a-9394-5d520212e15a Authenticating user 'default' from 127.0.0.1:41212
2021.11.19 14:49:57.900032 [ 318579 ] {} <Debug> HTTP-Session: 13945d52-0212-415a-9394-5d520212e15a Authenticated with global context as user 94309d50-4f52-5250-31bd-74fecac179db
2021.11.19 14:49:57.900067 [ 318579 ] {} <Debug> HTTP-Session: 13945d52-0212-415a-9394-5d520212e15a Creating query context from global context, user_id: 94309d50-4f52-5250-31bd-74fecac179db, parent context user: <NOT SET>
2021.11.19 14:49:57.900364 [ 318579 ] {3b54260b-e5ef-4cd7-a8ec-5574a482ac57} <Debug> executeQuery: (from 127.0.0.1:41212) (comment: 02096_rename_atomic_hang.sql) DROP DATABASE test_vrfyu7 
2021.11.19 14:49:57.900418 [ 318579 ] {3b54260b-e5ef-4cd7-a8ec-5574a482ac57} <Trace> ContextAccess (default): Access granted: DROP DATABASE ON test_vrfyu7.*
2021.11.19 14:49:57.900813 [ 318579 ] {3b54260b-e5ef-4cd7-a8ec-5574a482ac57} <Debug> DynamicQueryHandler: Done processing query
2021.11.19 14:49:57.900870 [ 318579 ] {3b54260b-e5ef-4cd7-a8ec-5574a482ac57} <Debug> MemoryTracker: Peak memory usage (for query): 0.00 B.
2021.11.19 14:49:57.900916 [ 318579 ] {} <Debug> HTTP-Session: 13945d52-0212-415a-9394-5d520212e15a Destroying unnamed session of user 94309d50-4f52-5250-31bd-74fecac179db
2021.11.19 14:49:57.906555 [ 318579 ] {} <Trace> HTTPHandler-factory: HTTP Request for HTTPHandler-factory. Method: POST, Address: 127.0.0.1:41214, User-Agent: (none), Length: 0, Content Type: , Transfer Encoding: identity, X-Forwarded-For: (none)
2021.11.19 14:49:57.906632 [ 318579 ] {} <Trace> DynamicQueryHandler: Request URI: /?query=CREATE+DATABASE+test_hjqesr&database=system&connect_timeout=30&receive_timeout=30&send_timeout=30&http_connection_timeout=30&http_receive_timeout=30&http_send_timeout=30&log_comment=02096_totals_global_in_bug.sql
2021.11.19 14:49:57.906677 [ 318579 ] {} <Debug> HTTP-Session: fa1dab93-e23f-4869-ba1d-ab93e23fb869 Authenticating user 'default' from 127.0.0.1:41214
2021.11.19 14:49:57.906712 [ 318579 ] {} <Debug> HTTP-Session: fa1dab93-e23f-4869-ba1d-ab93e23fb869 Authenticated with global context as user 94309d50-4f52-5250-31bd-74fecac179db
2021.11.19 14:49:57.906752 [ 318579 ] {} <Debug> HTTP-Session: fa1dab93-e23f-4869-ba1d-ab93e23fb869 Creating query context from global context, user_id: 94309d50-4f52-5250-31bd-74fecac179db, parent context user: <NOT SET>
2021.11.19 14:49:57.907012 [ 318579 ] {120b8211-eb3f-4079-9b66-c04f476b3776} <Debug> executeQuery: (from 127.0.0.1:41214) (comment: 02096_totals_global_in_bug.sql) CREATE DATABASE test_hjqesr 
2021.11.19 14:49:57.907062 [ 318579 ] {120b8211-eb3f-4079-9b66-c04f476b3776} <Trace> ContextAccess (default): Access granted: CREATE DATABASE ON test_hjqesr.*
2021.11.19 14:49:57.911481 [ 318579 ] {120b8211-eb3f-4079-9b66-c04f476b3776} <Information> DatabaseAtomic (test_hjqesr): Metadata processed, database test_hjqesr has 0 tables and 0 dictionaries in total.
2021.11.19 14:49:57.911514 [ 318579 ] {120b8211-eb3f-4079-9b66-c04f476b3776} <Information> TablesLoader: Parsed metadata of 0 tables in 1 databases in 6.2704e-05 sec
2021.11.19 14:49:57.911537 [ 318579 ] {120b8211-eb3f-4079-9b66-c04f476b3776} <Information> TablesLoader: Loading 0 tables with 0 dependency level
2021.11.19 14:49:57.911559 [ 318579 ] {120b8211-eb3f-4079-9b66-c04f476b3776} <Information> DatabaseAtomic (test_hjqesr): Starting up tables.
2021.11.19 14:49:57.911696 [ 318579 ] {120b8211-eb3f-4079-9b66-c04f476b3776} <Debug> DynamicQueryHandler: Done processing query
2021.11.19 14:49:57.911740 [ 318579 ] {120b8211-eb3f-4079-9b66-c04f476b3776} <Debug> MemoryTracker: Peak memory usage (for query): 0.00 B.
2021.11.19 14:49:57.911777 [ 318579 ] {} <Debug> HTTP-Session: fa1dab93-e23f-4869-ba1d-ab93e23fb869 Destroying unnamed session of user 94309d50-4f52-5250-31bd-74fecac179db
2021.11.19 14:49:57.941043 [ 318580 ] {} <Trace> TCPHandlerFactory: TCP Request. Address: 127.0.0.1:52294
2021.11.19 14:49:57.941245 [ 318580 ] {} <Debug> TCPHandler: Connected ClickHouse client version 21.11.0, revision: 54450, database: test_hjqesr, user: default.
2021.11.19 14:49:57.941295 [ 318580 ] {} <Debug> TCP-Session: 74113ef2-cdb4-4bbd-b411-3ef2cdb4bbbd Authenticating user 'default' from 127.0.0.1:52294
2021.11.19 14:49:57.941336 [ 318580 ] {} <Debug> TCP-Session: 74113ef2-cdb4-4bbd-b411-3ef2cdb4bbbd Authenticated with global context as user 94309d50-4f52-5250-31bd-74fecac179db
2021.11.19 14:49:57.941392 [ 318580 ] {} <Debug> TCP-Session: 74113ef2-cdb4-4bbd-b411-3ef2cdb4bbbd Creating session context with user_id: 94309d50-4f52-5250-31bd-74fecac179db
2021.11.19 14:49:57.941526 [ 318580 ] {} <Trace> ContextAccess (default): Settings: readonly=0, allow_ddl=true, allow_introspection_functions=false
2021.11.19 14:49:57.941567 [ 318580 ] {} <Trace> ContextAccess (default): List of all grants: GRANT ALL ON *.* WITH GRANT OPTION
2021.11.19 14:49:57.941601 [ 318580 ] {} <Trace> ContextAccess (default): List of all grants including implicit: GRANT ALL ON *.* WITH GRANT OPTION
2021.11.19 14:49:57.941935 [ 318580 ] {} <Debug> TCP-Session: 74113ef2-cdb4-4bbd-b411-3ef2cdb4bbbd Creating query context from session context, user_id: 94309d50-4f52-5250-31bd-74fecac179db, parent context user: default
2021.11.19 14:49:57.942609 [ 318580 ] {a9c87b52-d059-478e-a532-cfb402d3fffc} <Debug> executeQuery: (from 127.0.0.1:52294) (comment: 02096_totals_global_in_bug.sql) select sum(number) from remote('127.0.0.{2,3}', numbers(2)) where number global in (select sum(number) from numbers(2) group by number with totals) group by number with totals 
2021.11.19 14:49:57.943877 [ 318580 ] {a9c87b52-d059-478e-a532-cfb402d3fffc} <Trace> ContextAccess (default): Access granted: CREATE TEMPORARY TABLE, REMOTE ON *.*
2021.11.19 14:49:57.944020 [ 318580 ] {a9c87b52-d059-478e-a532-cfb402d3fffc} <Trace> Connection (127.0.0.2:9000): Connecting. Database: (not specified). User: default
Segmentation fault
```

```
root@tserver-overlayregen:/clickhouse/ClickHouse/tests# ./clickhouse-test -b /clickhouse/ClickHouse/build/programs/clickhouse
Using queries from 'queries' directory
Using /clickhouse/ClickHouse/build/programs/clickhouse-client as client program (expecting split build)
Connecting to ClickHouse server... OK

Running 3524 stateless tests (MainProcess).

02114_hdfs_bad_url:                                                     [ FAIL ] - result differs with reference: 
--- /clickhouse/ClickHouse/tests/queries/0_stateless/02114_hdfs_bad_url.reference       2021-11-16 05:55:33.000000000 +0000
+++ /clickhouse/ClickHouse/tests/queries/0_stateless/02114_hdfs_bad_url.stdout  2021-11-19 14:41:54.336000000 +0000
@@ -1,17 +1,17 @@
-OK
-OK
-OK
-OK
-OK
-OK
-OK
-OK
-OK
-OK
-OK
-OK
-OK
-OK
-OK
-OK
-OK
+FAIL
+FAIL
+FAIL
+FAIL
+FAIL
+FAIL
+FAIL
+FAIL
+FAIL
+FAIL
+FAIL
+FAIL
+FAIL
+FAIL
+FAIL
+FAIL
+FAIL


Database: test_u32k62
02113_format_row_bug:                                                   [ OK ]
02113_hdfs_assert:                                                      [ FAIL ] - result differs with reference: 
--- /clickhouse/ClickHouse/tests/queries/0_stateless/02113_hdfs_assert.reference        2021-11-16 05:55:33.000000000 +0000
+++ /clickhouse/ClickHouse/tests/queries/0_stateless/02113_hdfs_assert.stdout   2021-11-19 14:41:54.572000000 +0000
@@ -1 +1 @@
-OK
+FAIL


Database: test_mp7wrb
02112_skip_index_set_and_or:                                            [ OK ]
02112_parse_date_yyyymmdd:                                              [ OK ]
02111_modify_table_comment:                                             [ OK ]
02111_function_mapExtractKeyLike:                                       [ OK ]
02111_with_fill_no_rows:                                                [ OK ]
02110_clickhouse_local_custom_tld:                                      [ OK ]
02104_clickhouse_local_columns_description:                             [ OK ]
02103_sql_user_defined_functions_composition:                           [ OK ]
02102_sql_user_defined_functions_create_if_not_exists:                  [ OK ]
02101_sql_user_defined_functions_drop_if_exists:                        [ OK ]
02101_sql_user_defined_functions_create_or_replace:                     [ FAIL ] - result differs with reference: 
--- /clickhouse/ClickHouse/tests/queries/0_stateless/02101_sql_user_defined_functions_create_or_replace.reference       2021-11-16 05:55:33.000000000 +0000
+++ /clickhouse/ClickHouse/tests/queries/0_stateless/02101_sql_user_defined_functions_create_or_replace.stdout  2021-11-19 14:41:55.588000000 +0000
@@ -1,4 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 CREATE FUNCTION `02101_test_function` AS x -> (x + 1)
 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 CREATE FUNCTION `02101_test_function` AS x -> (x + 2)
 3


Database: test_3bntfx
02100_now64_types_bug:                                                  [ OK ]
02100_limit_push_down_bug:                                              [ OK ]
02100_alter_scalar_circular_deadlock:                                   [ OK ]
02100_replaceRegexpAll_bug:                                             [ OK ]
02099_hashed_array_dictionary_complex_key:                              [ OK ]
02099_sql_user_defined_functions_lambda:                                [ OK ]
02098_sql_user_defined_functions_aliases:                               [ OK ]
02098_hashed_array_dictionary_simple_key:                               [ OK ]
02098_date32_comparison:                                                [ OK ]
02097_remove_sample_by:                                                 [ SKIPPED ] - no zookeeper
02097_polygon_dictionary_store_key:                                     [ OK ]
02097_initializeAggregationNullable:                                    [ OK ]
02097_default_dict_get_add_database:                                    [ OK ]
02096_rename_atomic_hang:                                               [ FAIL ] - return code: 70
[tserver-overlayregen] 2021.11.19 14:41:57.824042 [ 315690 ] {29e82268-2635-434f-954e-044ac139daf7} <Error> executeQuery: Code: 70. DB::Exception: Conversion from UInt64 to AggregateFunction(count) is not supported: while converting source column `count()` to destination column `count()`. (CANNOT_CONVERT_TYPE) (version 21.11.4.14) (from 127.0.0.1:39746) (comment: 02096_rename_atomic_hang.sql) (in query: select count() from db_hang.test_mv;), Stack trace (when copying this message, always include the lines below):

0. Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x22f0e7d0 in ?
1. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0x1795b5cc in /clickhouse/ClickHouse/build/programs/clickhouse
2. DB::FunctionCast<DB::CastInternalName>::createAggregateFunctionWrapper(std::__1::shared_ptr<DB::IDataType const> const&, DB::DataTypeAggregateFunction const*) const @ 0x1a71b524 in /clickhouse/ClickHouse/build/programs/clickhouse
3. DB::FunctionCast<DB::CastInternalName>::prepareImpl(std::__1::shared_ptr<DB::IDataType const> const&, std::__1::shared_ptr<DB::IDataType const> const&, bool) const @ 0x1a717a7c in /clickhouse/ClickHouse/build/programs/clickhouse
4. DB::FunctionCast<DB::CastInternalName>::prepareRemoveNullable(std::__1::shared_ptr<DB::IDataType const> const&, std::__1::shared_ptr<DB::IDataType const> const&, bool) const @ 0x1a716a68 in /clickhouse/ClickHouse/build/programs/clickhouse
5. DB::FunctionCast<DB::CastInternalName>::prepareUnpackDictionaries(std::__1::shared_ptr<DB::IDataType const> const&, std::__1::shared_ptr<DB::IDataType const> const&) const @ 0x1a714b74 in /clickhouse/ClickHouse/build/programs/clickhouse
6. DB::FunctionCast<DB::CastInternalName>::prepare(std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName> > const&) const @ 0x1a714288 in /clickhouse/ClickHouse/build/programs/clickhouse
7. DB::ActionsDAG::addFunction(std::__1::shared_ptr<DB::IFunctionOverloadResolver> const&, std::__1::vector<DB::ActionsDAG::Node const*, std::__1::allocator<DB::ActionsDAG::Node const*> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) @ 0x20dccf98 in ?
8. DB::ActionsDAG::makeConvertingActions(std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName> > const&, std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName> > const&, DB::ActionsDAG::MatchColumnsMode, bool, bool, std::__1::unordered_map<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> >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >*) @ 0x20dd8d20 in ?
9. DB::StorageMaterializedView::read(DB::QueryPlan&, 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&, DB::SelectQueryInfo&, std::__1::shared_ptr<DB::Context const>, DB::QueryProcessingStage::Enum, unsigned long, unsigned int) @ 0x219b8de0 in ?
10. DB::InterpreterSelectQuery::executeFetchColumns(DB::QueryProcessingStage::Enum, DB::QueryPlan&) @ 0x212b6b44 in ?
11. DB::InterpreterSelectQuery::executeImpl(DB::QueryPlan&, std::__1::optional<DB::Pipe>) @ 0x212b06d8 in ?
12. DB::InterpreterSelectQuery::buildQueryPlan(DB::QueryPlan&) @ 0x212b00b0 in ?
13. DB::InterpreterSelectWithUnionQuery::buildQueryPlan(DB::QueryPlan&) @ 0x21467f08 in ?
14. DB::InterpreterSelectWithUnionQuery::execute() @ 0x21468c00 in ?
15. DB::executeQueryImpl(char const*, char const*, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x21681d5c in ?
16. 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) @ 0x216801a4 in ?
17. DB::TCPHandler::runImpl() @ 0x2201f744 in ?
18. DB::TCPHandler::run() @ 0x22031678 in ?
19. Poco::Net::TCPServerConnection::start() @ 0x22e46c2c in ?
20. Poco::Net::TCPServerDispatcher::run() @ 0x22e474f4 in ?
21. Poco::PooledThread::run() @ 0x22f980f4 in ?
22. Poco::(anonymous namespace)::RunnableHolder::run() @ 0x22f960ac in ?
23. Poco::ThreadImpl::runnableEntry(void*) @ 0x22f94870 in ?
24. start_thread @ 0x9818 in /usr/lib/powerpc64le-linux-gnu/libpthread-2.31.so

Received exception from server (version 21.11.4):
Code: 70. DB::Exception: Received from localhost:9000. DB::Exception: Conversion from UInt64 to AggregateFunction(count) is not supported: while converting source column `count()` to destination column `count()`. (CANNOT_CONVERT_TYPE)
(query: select count() from db_hang.test_mv;)
, result:

2000

stdout:
2000


Database: test_01a9d0
02096_totals_global_in_bug:                                             [ UNKNOWN ] - Test internal error: ConnectionRefusedError
[Errno 111] Connection refused
  File "./clickhouse-test", line 644, in run
    proc, stdout, stderr, total_time = self.run_single_test(server_logs_level, client_options)

  File "./clickhouse-test", line 599, in run_single_test
    clickhouse_execute(args, "DROP DATABASE " + database, timeout=seconds_left, settings={

  File "./clickhouse-test", line 106, in clickhouse_execute
    return clickhouse_execute_http(base_args, query, timeout, settings).strip()

  File "./clickhouse-test", line 97, in clickhouse_execute_http
    client.request('POST', '/?' + base_args.client_options_query_str + urllib.parse.urlencode(params))

  File "/usr/lib/python3.8/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)

  File "/usr/lib/python3.8/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)

  File "/usr/lib/python3.8/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)

  File "/usr/lib/python3.8/http/client.py", line 1007, in _send_output
    self.send(msg)

  File "/usr/lib/python3.8/http/client.py", line 947, in send
    self.connect()

  File "/usr/lib/python3.8/http/client.py", line 918, in connect
    self.sock = self._create_connection(

02096_bad_options_in_client_and_local:                                  [ UNKNOWN ] - Test internal error: ConnectionRefusedError
```


**Expected behavior**
No segment fault

**Error message and/or stacktrace**


**Additional context**


{
    auto sort = [](auto begin, auto end, auto pred) { pdqsort(begin, end, pred); };
    auto partial_sort = [](auto begin, auto mid, auto end, auto pred) { ::partial_sort(begin, mid, end, pred); };
    if (reverse)
        this->updatePermutationImpl(
            limit, res, equal_range,
            greater(*this, nan_direction_hint),
            equals(*this, nan_direction_hint),
            sort, partial_sort);
    else
        this->updatePermutationImpl(
            limit, res, equal_range,
            less(*this, nan_direction_hint),
            equals(*this, nan_direction_hint),
            sort, partial_sort);
}
template <typename T>
MutableColumnPtr ColumnVector<T>::cloneResized(size_t size) const