Cyanty opened a new pull request, #9906:
URL: https://github.com/apache/seatunnel/pull/9906
- reslove #9857
**Issue:**
When using `clickhouse-client:0.3.2-patch11`, inserting data into a `JSON`
column throws an `Unsupported data type` exception. The error originates from
`ClickHouseRowBinaryProcessor#MappedFunctions.serialize(484)`.
**Root Cause:**
The `ClickHouseRowBinaryProcessor` in this driver version lacks a serializer
mapping for the `JSON` data type. For `INSERT ... VALUES (?,?,...)` statements,
the driver defaults to using `InputBasedPreparedStatement`, which invokes the
`serialize` method during `addBatch()`. This inevitably triggers the exception
when a `JSON` type is encountered.
**Solution:**
It was observed that if the `VALUES()` clause contains characters other than
`?`, `,`, or `Whitespace`, the driver defaults to `SqlBasedPreparedStatement`.
This implementation builds the `INSERT` statement by concatenating values as a
single string and does not call the `serialize` method. By slightly modifying
the statement, we can force the use of `SqlBasedPreparedStatement`, thus
bypassing the bug and enabling `JSON` insertion without a driver update.
**Usage for JSON columns:**
Data for `JSON` columns must be sent as a string via JDBC, allowing the
ClickHouse server to handle parsing. Internally, our application now includes a
`JSON` type that acts as an alias for `String` to align with ClickHouse
metadata and ensure consistent handling.
### Check list
* [ ] If any new Jar binary package adding in your PR, please add License
Notice according
[New License
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
* [ ] If necessary, please update the documentation to describe the new
feature. https://github.com/apache/seatunnel/tree/dev/docs
* [ ] If you are contributing the connector code, please check that the
following files are updated:
1. Update
[plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties)
and add new connector information in it
2. Update the pom file of
[seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
3. Add ci label in
[label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
4. Add e2e testcase in
[seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
5. Update connector
[plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]