Closed spanwp closed 6 days ago
@spanwp the different comes from different way of data serialization.
conn.Exec
will serialize data to a stringified format client-side using bind logic: https://github.com/ClickHouse/clickhouse-go/blob/14f8a65e86283f1f11ebaeb1b7e8901512ea1db2/examples/std/bind.go#L28
Prepared statement (it's basically a batch insert) will normalize data to a ClickHouse native format and send it natively to ClickHouse.
It's basically a misalignment of how the various data types are handled. Bind logic is flexible in data handling, but it has a cost of reflection. Native data format serialization is explicit on input data type, because ClickHosue expects strict type.
I will close this issue, but if you have any follow-up questions feel free to ask.
Observed
Hello everyone! When I use db.Prepare and then stmt.Exec from database/sql package, I receive the error:
clickhouse [AppendRow]: converting map[string]interface {} to Map(String, String) is unsupported. Try using map[string]string
. However, when I use db.Exec with the same query and arguments, everything works fine.Expected behaviour
Both cases should work?
Code example
Go code:
Clickhouse schema:
Details
Environment
clickhouse-go
version: v2.25.0database/sql
CREATE TABLE
statements for tables involved: yes