debezium / debezium/dbz

MariaDB source doesnt extract JSON columns properly [DBZ-9430]

Open
#1,397 0 comments 0 reactions 0 assignees View on GitHub
component/mariadb-connector migrated-from-jira type/bug
Dominant language
HTML
Stars
6
Forks
8
Avg merge
2d 19h
Merged PRs (30d)
1

Description

Migrated from [DBZ-9430](https://issues.redhat.com/browse/DBZ-9430)

Mariadb stores JSON as LONGTEXT, not JSON. So, when you have a JSON column in mariadb, it just comes out with a string in the schema, rather than io.debezium.data.Json

 
{code:java}
{    
"name": "json_col",
"type": ["null","string"],
"default": null
}{code}
Here's a blog post from Mariadb on the topic
[Making MariaDB understand MySQL JSON - MariaDB.org|https://mariadb.org/making-mariadb-understand-mysql-json/]

 

And from their docs;:

{{JSON}} is an alias for {{{}LONGTEXT{}}}. See [JSON Data Type|https://mariadb.com/docs/server/reference/data-types/string-data-types/json] for details.

In MySQL, JSON is an object and is [compared according to json values|https://dev.mysql.com/doc/refman/8.0/en/json.html#json-comparison]. In MariaDB JSON strings are normal strings and compared as strings. One exception is when using [JSON_EXTRACT()|https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_extract] in which case strings are unescaped before comparison. 

 

So, Its really just a LONGTEXT. 

 

I think that all that could probably be done is change the docs [Debezium connector for MariaDB :: Debezium Documentation |https://debezium.io/documentation/reference/3.2/connectors/mariadb.html#mariadb-basic-types]to say that JSON is actually LONGTEXT and will output as string, and wont have io.debezium.data.Json

 

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.