ClickHouse / clickhouse-odbc

ODBC driver for ClickHouse
https://clickhouse.tech
Apache License 2.0
245 stars 86 forks source link

Error while using Null values in Tableau #353

Closed SergeiStradomsky closed 3 years ago

SergeiStradomsky commented 3 years ago

Hi! We found some error, while using Null values in Tableau.

We get this error in release https://github.com/ClickHouse/clickhouse-odbc/releases/tag/v1.1.9.20201226, but in release https://github.com/ClickHouse/clickhouse-odbc/releases/tag/v1.1.1.20191108 everything works just fine.

An error occurred while communicating with the Other Databases (ODBC) data source 'oroboros_test_123 (cubes)' Bad Connection: Tableau could not connect to the data source. Error Code: B19090E0 unknown type SELECT SUM({fn CONVERT(NULL, SQL_BIGINT)}) AS sum_Calculation_3063644052176396288_ok FROM oroboros_test_123 HAVING (COUNT(1) > 0)

This error occurs while creating Calculation Filed like IF FALSE THEN 1 END How can we fix this?

UPD: I changed some code here https://github.com/ClickHouse/clickhouse-odbc/blob/3c37dbd1e4e75cfba8dfa5300c52fcfd0d94a008/driver/utils/type_info.h#L51, by replacing this line to throw std::runtime_error("unknown type. Got type " + type); And got next message

An error occurred while communicating with the Other Databases (ODBC) data source 'cubes_clickhousefact_ue_partitioned_distributed (cubes)' Bad Connection: Tableau could not connect to the data source. Error Code: B19090E0 unknown type. Got type Nothing SELECT SUM({fn CONVERT(NULL, SQL_BIGINT)}) AS sum_Calculation_3485082461064859648_ok FROM cubes_clickhousefact_ue_partitioned_distributed HAVING (COUNT(1) > 0)

As far as I can see, there is no type Nothing here https://github.com/ClickHouse/clickhouse-odbc/blob/3c37dbd1e4e75cfba8dfa5300c52fcfd0d94a008/driver/utils/type_info.cpp#L7, but there is type Nothing in Clickhouse doc https://clickhouse.tech/docs/ru/sql-reference/data-types/special-data-types/nothing/

SergeiStradomsky commented 3 years ago

Can anyone help with this?

savelov commented 3 years ago

Hi Sergei - you need to add mapping to TypeInfo with mapping to some SQL Type and number of bytes required to store it