allegro/json-avro-converter

Problem decoding union of map: Failed to convert JSON to Avro

Open

#59 opened on Sep 8, 2021

View on GitHub
 (2 comments) (0 reactions) (1 assignee)Groovy (93 forks)batch import
hacktoberfest

Repository metrics

Stars
 (255 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Example schema:

protocol ScoreData {
  record ScoreData {
    string id;
    union {null, map<double>} multiScore = null;
  }
}

Example payload:

"{\"id\":\"myKey\",\"multiScore\":{\"map\":{\"a\":10.0}}}"

Exception:

tech.allegro.schema.json2avro.converter.AvroConversionException: Failed to convert JSON to Avro: Could not evaluate union, field multiScore is expected to be one of these: NULL, MAP. If this is a complex type, check if offending field: multiScore adheres to schema.

AFAICT, this is syntactically valid JSON for a union{null, map}. I've tried with avro4s too and it decodes things without issues.

Version: 0.2.10

Contributor guide