ClickHouse/metabase-clickhouse-driver

Inconsistencies in booleans handling

mlazowik opened this issue · 1 comments

Describe the bug

I'm not 100% sure whether this should be here, or in Metabase repo, but my bet is here.

When using the notebook with boolean questions:

  • the "original schema" type inferred by Metabase is type/Boolean, same as when using Postgres
  • the semantic type is "Category", same as when using Postgres
  • when selecting the column from the list in the notebook it has the Aa icon, while in Postgres it has I/O
Screenshot 2023-08-31 at 16 26 11 Screenshot 2023-08-31 at 16 26 56
  • the filtering interface for ClickHouse seems to be generic category one, in Postgres it's dedicated to booleans
Screenshot 2023-08-31 at 16 27 39 Screenshot 2023-08-31 at 16 27 50
  • it's possible to select boolean columns in Sum of … in ClickHouse, not possible in Postgres
  • the result of summing over a boolean column in ClickHouse is treated as a textual result by Metabase, there is no option to set separator style etc.
Screenshot 2023-08-31 at 16 29 33 Screenshot 2023-08-31 at 16 32 53
  • It is possible to select the number styling when either summing booleans in SQL, or using CountIf() instead of summing
Screenshot 2023-08-31 at 16 33 33 Screenshot 2023-08-31 at 16 34 08
  • Notably formatting options are missing when using a notebook, but when you convert a question created using notebook to raw sql the options are there. Which seems to show that the problem is with how Metabase treats the results, not with the SQL query

IMO this is a problem, because non-technical users will reach for the Sum of … by default, and training them that they should avoid it and use CountIf() to get proper formatting will not be easy.

Expected behaviour

Either summing over booleans is not supported in the graphical interface, or the result is understood by Metabase to be a number.

Configuration

Environment

  • metabase-clickhouse-driver version: 1.1.7
  • Metabase version: 0.46.7
  • OS: NixOS 23.05

ClickHouse server

  • ClickHouse Server version: 23.7.4.5

@mlazowik, I cannot reproduce it with CH 23.8/MB 0.47.2/Driver 1.21. Can you please check it with these versions? It could be due to 1.2.0 database types mapping rework, though I am not sure.

create table test (b Boolean, s String) engine MergeTree order by b;
insert into test values (true, "foo"), (true, "bar"), (false, "qaz");

image

image