Closed rockwotj closed 2 months ago
First time I ran the tool:
$ ./rsgen/rsgen-avro ../redact/avro/schema.avsc src/avro.rs
Templating error: Ref `Name { name: "Node", namespace: Some("org.apache.avro") }` is not resolved. Schema: Ref { name: Name { name: "Node", namespace: Some("or
g.apache.avro") } }
If I remove the namespace for the top level record I get:
$ ./rsgen/rsgen-avro ../redact/avro/schema.avsc src/avro.rs
zsh: segmentation fault (core dumped) ./rsgen/rsgen-avro ../redact/avro/schema.avsc src/avro.rs
Here it fails with:
./target/release/rsgen-avro interop.avsc -
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
fish: Job 1, './target/release/rsgen-avro int…' terminated by signal SIGABRT (Abort)
There are two issues:
recordField
that uses recursion (i.e. Schema::Ref). Removing this field solves the issue (stack overflow)Thanks for the quick response. I think the null
one is fine, I think the stack overflow is more important. I'll update this issue to support that feature
The recursive schemas are indeed not supported, tbh I wasn't even aware of it.
@martin-g do you know what a valid Rust struct corresponding to this schema (w/o the null field) would look like ?
I guess here Box<Node>
, but is that actually supported by apache-avro
?
Actually it fails when determining whether the generated struct is Eq
or not, this boils down to looking for a "float" recursively (which here stack overflows).
If you change {"name": "label", "type": "string"}
to {"name": "label", "type": "float"}
it manages to generate the code.
So it shouldn't be too hard to fix.
@rockwotj I have added support for recursive types on the branch apache-avro-0.17
, could you give it a try ?
Works well for me! Thanks.
The following schema causes a segfault for me, this schema is taken from the offical apache avro test suite: https://github.com/apache/avro/blob/main/share/test/schemas/interop.avsc
System information