Power BI converts numeric types, such as Int32, into Decimal before running aggregate functions like SUM.
For example, to get the sum of all values in the volume column from the trades table, Power BI generates the following query:
SELECT sum(CAST(volume AS Decimal)) FROM trades;
This is likely done to avoid integer overflow, as Decimal typically supports a much larger range of values.
The Decimal type comes from SQLGetTypeInfo—specifically, it is the first type that matches ODBC's SQL_DECIMAL. Normally, SQL databases allow converting NULL to any type, because most types, including Decimal, are nullable. However, in the case of ClickHouse, this causes an issue if the volume column contains NULL values.
ClickHouse does not allow converting NULL to Decimal, only to Nullable(Decimal). Therefore, the query above results in an error, even though Power BI does see any problems with the generated query.
Power BI converts numeric types, such as
Int32, intoDecimalbefore running aggregate functions likeSUM.For example, to get the sum of all values in the
volumecolumn from thetradestable, Power BI generates the following query:This is likely done to avoid integer overflow, as
Decimaltypically supports a much larger range of values.The
Decimaltype comes fromSQLGetTypeInfo—specifically, it is the first type that matches ODBC'sSQL_DECIMAL. Normally, SQL databases allow convertingNULLto any type, because most types, includingDecimal, are nullable. However, in the case of ClickHouse, this causes an issue if thevolumecolumn containsNULLvalues.ClickHouse does not allow converting
NULLtoDecimal, only toNullable(Decimal). Therefore, the query above results in an error, even though Power BI does see any problems with the generated query.