lerouxrgd / rsgen-avro

Command line and library for generating Rust types from Avro schemas
MIT License
37 stars 29 forks source link

3d Arrays cause Templating error #65

Closed ajfabbri closed 3 months ago

ajfabbri commented 5 months ago

Using a 3-dimensional array fails with Templating error: Didn't find schema Array(Array(Double)) in state GenState

fabbri@linux~/Code/rsgen-avro$ cat array-3d.avsc
{
  "type" : "record",
  "name" : "Array3d",
  "fields" : [ {
    "name" : "coordinates",
    "type" : {
      "type" : "array",
      "items" : {
        "type" : "array",
        "items" : {
          "type" : "array",
          "items" : "double"
        }
      }
    }
  } ]
}
fabbri@linux:~/Code/rsgen-avro$ target/debug/rsgen-avro array-3d.avsc -
Templating error: Didn't find schema Array(Array(Double)) in state GenState { types_by_schema: {"{\"type\":\"array\",\"items\":\"double\"}": "Vec<f64>"}, schemata_by_name: {Name { name: "Array3d", namespace: None }: Record(RecordSchema { name: Name { name: "Array3d", namespace: None }, aliases: None, doc: None, fields: [RecordField { name: "coordinates", doc: None, aliases: None, default: None, schema: Array(Array(Array(Double))), order: Ascending, position: 0, custom_attributes: {} }], lookup: {"coordinates": 0}, attributes: {} })}, not_eq: {"{\"type\":\"record\",\"name\":\"Array3d\",\"fields\":[{\"name\":\"coordinates\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"array\",\"items\":{\"type\":\"array\",\"items\":\"double\"}}}}]}", "{\"type\":\"array\",\"items\":\"double\"}"}, use_chrono_dates: false }
lerouxrgd commented 4 months ago

Hello, Thank you for reporting this and sorry for the late reply. I have fixed it on branch apache-avro-0.17 (which is the main one until apache-avro 0.17 is actually released). Let me know how it goes for you.

ajfabbri commented 4 months ago

Awesome, thanks Romain! Will test it out when I get a chance.

lerouxrgd commented 3 months ago

Released in 0.14.0, don't hesitate to re-open if something isn't working.

baxterjo commented 3 months ago

Hey @lerouxrgd, I just tested this on @ajfabbri 's behalf. Looking good! Thanks for the fix!