Open maxim-lixakov opened 3 months ago
@maxim-lixakov, thank you for reporting the issue. It will look into it. Btw, ClickHouse has own Spark connector. Please see https://clickhouse.com/docs/en/integrations/apache-spark
Thanks!
This issue prevents our custom Clickhouse dialect for Spark from reading Arrays from Clickhouse: https://github.com/MobileTeleSystems/spark-dialect-extension/blob/b4ba3724bf036394457985588ea891c05c90e5b1/src/test/scala/io/github/mtsongithub/doetl/sparkdialectextensions/clickhouse/ClickhouseDialectTest.scala#L478-L500
Describe the bug
In the current implementation of Spark when working with arrays of data returned from ClickHouse through the clickhouse-java driver, there is a type conversion error. When the driver returns an array of primitive types (e.g., bytes or integers), Spark attempts to cast them to an array of objects, which is not possible in Java and Scala, as arrays of primitives are not subtypes of arrays of objects. This leads to a
ClassCastException
.Steps to reproduce
CREATE TABLE
statements for tables involved:At first we implement custom Clickhouse dialect that handles
Array(T)
because in native Spark,Array(T)
is unsupported typeExpected behaviour
The driver should return an array of objects instead of an array of primitives to avoid
ClassCastException
in Spark.Code example
Example code snippet in Spark that demonstrates the issue:
Error log
Configuration
Environment
ClickHouse server
clickhouse-server:latest-alpine