Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ksqlDB unable to correctly deserialise JSON array of objects as MAP #10160

Open
cpettigre opened this issue Dec 12, 2023 · 0 comments
Open

ksqlDB unable to correctly deserialise JSON array of objects as MAP #10160

cpettigre opened this issue Dec 12, 2023 · 0 comments

Comments

@cpettigre
Copy link

Description
The ksqlDB stream doesn't return any results when querying MAP data that was created using 'INSERT INTO'. This only affects JSON_SR schemas on CCloud.

To Reproduce

CREATE STREAM MAP_TEST (ID INT KEY, DATA STRUCT<VAL MAP<STRING, STRING>>)
WITH (kafka_topic='MAP_TEST', partitions=1, value_format='json_sr');

INSERT INTO MAP_TEST (ID, DATA) VALUES (1, STRUCT(VAL := MAP('a' := '1', 'b' := '2')));

SELECT * FROM MAP_TEST EMIT CHANGES;

Expected behavior
A new row is emitted showing the data that was inserted.

Actual Behaviour
No data comes through and the processing logs show the following:

"ERRORMESSAGE": "Failed to deserialize value from topic: MAP_TEST. Can't convert type. sourceType: ArrayNode, requiredType: MAP<VARCHAR, VARCHAR>, path: $.DATA.VAL"

Additional context
The INSERT INTO statement registers a schema (see below). This schema shows an array of objects as well as 'connect.index' attributes. It seems that the consumer used by the SELECT statement doesn't know how to deserialise to the map format.

{
  "properties": {
    "DATA": {
      "connect.index": 0,
      "oneOf": [
        {
          "type": "null"
        },
        {
          "properties": {
            "VAL": {
              "connect.index": 0h,
              "oneOf": [
                {
                  "type": "null"
                },
                {
                  "connect.type": "map",
                  "items": {
                    "properties": {
                      "key": {
                        "connect.index": 0,
                        "oneOf": [
                          {
                            "type": "null"
                          },
                          {
                            "type": "string"
                          }
                        ]
                      },
                      "value": {
                        "connect.index": 1,
                        "oneOf": [
                          {
                            "type": "null"
                          },
                          {
                            "type": "string"
                          }
                        ]
                      }
                    },
                    "type": "object"
                  },
                  "type": "array"
                }
              ]
            }
          },
          "type": "object"
        }
      ]
    }
  },
  "type": "object"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant