-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Description
At the moment the compile command only allows for passing a directory containing Avro schemas. This is problematic because the ordering in which the Avro schemas are loaded is non-deterministic to the external user of the CLI. Code generation will fail if Schema A depends on Schema B, but Schema B is loaded prior to Schema A.
I also tried using compile:file and manually iterating through the Avro schemas to generate them in the correct order, but the issue with inter-dependencies between schemas persisted.
Desired State
The ordering of schemas loaded into the code generator should be deterministic and able to be specified by the end user.
An additional nice to have feature would be that the files are output to the output directory in the same directory structure as in the input directory.
Proposed Solution
One possible solution to the issue could be to adopt a similar approach to Apache's avro-tools. When using the avro-tools CLI to perform Java code generation from Avro schemas, the user can specify the sequence in which the Avro schemas should be loaded to avoid issues with inter-dependencies between the schemas.
Using the simple example from above, I could do the following with avro-tools:
java -jar /path/to/avro-tools-1.11.0.jar compile schema SchemaB.avsc SchemaA.avsc <output-dir>