SRserves85 / avro-to-python

Light tool for compiling avro schema files (.avsc) to python classes
MIT License
25 stars 19 forks source link

Multidimensional arrays are not supported #27

Closed fmiguelez closed 1 year ago

fmiguelez commented 1 year ago

Consider following schema:

{
  "type" : "record",
  "name" : "RecordWithMultiDimensionalArray",
  "namespace" : "test",
  "fields" : [ {
    "name" : "coordinates",
    "type" : {
      "type" : "array",
      "items" : {
        "type" : "array",
        "items" : "double",
        "java-class" : "[D"
      },
      "java-class" : "[[D"
    }
  } ]
}

It fails with following error when trying to be processed:

Traceback (most recent call last):
  File "/home/fer/.local/bin/avro-to-python", line 8, in <module>
    sys.exit(main())
  File "/home/fer/.local/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/fer/.local/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/fer/.local/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/fer/.local/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/fer/.local/lib/python3.10/site-packages/avro_to_python/cli.py", line 34, in main
    reader.read()
  File "/home/fer/.local/lib/python3.10/site-packages/avro_to_python/reader/read.py", line 81, in read
    self._build_namespace_tree()
  File "/home/fer/.local/lib/python3.10/site-packages/avro_to_python/reader/read.py", line 164, in _build_namespace_tree
    _record_file(file, item, queue)
  File "/home/fer/.local/lib/python3.10/site-packages/avro_to_python/utils/avro/files/record.py", line 45, in _record_file
    field = _array_field(
  File "/home/fer/.local/lib/python3.10/site-packages/avro_to_python/utils/avro/types/array.py", line 93, in _array_field
    f"avro type {field['items']['type']} is not supported"
KeyError: 'items'