Skip to content

Comparison of nullables inside tuples #11985

@zlobober

Description

@zlobober

Describe the bug
Comparing nullable against non-nullable works fine:

$ curl localhost:8123 -d "select 'b' > 'a'"
1
$ curl localhost:8123 -d "select toNullable('b') > 'a'"
1
$ curl localhost:8123 -d "select toNullable('b') > toNullable('a')"
1
$ curl localhost:8123 -d "select 'b' > toNullable('a')"
1

But when we put nullable inside single element tuple, it crashes the server (after each crash I restarted the server):

$ curl localhost:8123 -d "select tuple('b') > tuple('a')"
1
$ curl localhost:8123 -d "select tuple(toNullable('b')) > tuple('a')"
curl: (52) Empty reply from server
$ curl localhost:8123 -d "select tuple(toNullable('b')) > tuple(toNullable('a'))"
curl: (52) Empty reply from server
$ curl localhost:8123 -d "select tuple('b') > tuple(toNullable('a'))"
curl: (52) Empty reply from server

Server stderr looks like the following:

2020.06.26 18:57:07.770739 [ 20123 ] {} <Trace> HTTPHandler-factory: HTTP Request for HTTPHandler-factory. Method: POST, Address: [::1]:38144, User-Agent: curl/7.58.0, Length: 42, Content Type: application/x-www-form-urlencoded, Transfer Encoding: identity                                                              
2020.06.26 18:57:07.771115 [ 20123 ] {} <Trace> DynamicQueryHandler: Request URI: /                                                                                                                                                                                                                                           
2020.06.26 18:57:07.771927 [ 20123 ] {6015c322-8e28-49e9-a8b5-126e7c4d2244} <Debug> executeQuery: (from [::1]:38144) select tuple(toNullable('b')) > tuple('a')                                                                                                                                                               
2020.06.26 18:57:07.773392 [ 20123 ] {6015c322-8e28-49e9-a8b5-126e7c4d2244} <Trace> ContextAccess (default): Access granted: SELECT(dummy) ON system.one                                                                                                                                                                      
2020.06.26 18:57:07.773629 [ 20123 ] {6015c322-8e28-49e9-a8b5-126e7c4d2244} <Trace> InterpreterSelectQuery: FetchColumns -> Complete                                                                                                                                                                                          
2020.06.26 18:57:07.774329 [ 20123 ] {6015c322-8e28-49e9-a8b5-126e7c4d2244} <Error> : Logical error: 'Bad cast from type DB::ColumnNullable to DB::ColumnVector<unsigned char>'.                                                                                                                                              
clickhouse-server: /place/db-0/key_0/srvs/worker_3e27dc966f8b8c61e8432d508e3db20f/srvdata/tared_svnc/12f2797-39a58e0c-86c4981b-2a8660d6/clickhouse/src/Common/Exception.cpp:45: DB::Exception::Exception(const std::string &, int): Assertion `false' failed.                                                                 
2020.06.26 18:57:07.774630 [ 20054 ] {} <Trace> BaseDaemon: Received signal 6                                                                                                                                                                                                                                                 
2020.06.26 18:57:07.774978 [ 20303 ] {} <Fatal> BaseDaemon: ########################################                                                                                                                                                                                                                          

What surprises me, longer tuples work just fine:

$ curl localhost:8123 -d "select tuple(toNullable('b'), toNullable('b')) > tuple('a', 'a')"
1
$ curl localhost:8123 -d "select tuple(toNullable('b'), 'b') > tuple('a', 'a')"
1
$ curl localhost:8123 -d "select tuple('b', toNullable('b')) > tuple('a', 'a')"
1
$ curl localhost:8123 -d "select tuple('b', toNullable('b')) > tuple(toNullable('a'), 'a')"
1
$ curl localhost:8123 -d "select tuple('b', toNullable('b')) > tuple(toNullable('a'), toNullable('a'))"
1

How to reproduce

  • Which ClickHouse server version to use
$ ./clickhouse-server -V
ClickHouse server version 20.6.1.1-arcadia.

Metadata

Metadata

Labels

bugConfirmed user-visible misbehaviour in official releasecomp-datatype-wrapperType modifiers/wrappers (Nullable, LowCardinality, etc.).

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions