julianpeeters / avrohugger

Generate Scala case class definitions from Avro schemas
Apache License 2.0
202 stars 120 forks source link

Ability to use Avro files defined in other avsc files #137

Open nmarasoiu opened 4 years ago

nmarasoiu commented 4 years ago

When I define certain common Avro types in their own avsc files, and use them by fully qualified name in other Avro definitions (in other avsc files), I get this error:

throw new SchemaParseException(fieldTypeNode + " is not a defined name." + " The type of the "" + fieldName
+ "" field must be" + " a defined name or a {"type": ...} expression.");

I want to go the "defined name" way, but I am not clear how is this possible.

Apache Avro 1.7.3 seemingly introduced the possibility of import, but looking in its code, it does not populate imports, presumably leaving it to implementations like maven/gradle/sbt plugins.

I guess a way is like maven plugin does, allowing configuration of import paths to be done before the others.

Another way is the one proposed in this https://issues.apache.org/jira/browse/AVRO-1188 which is an explicit import at the site of the usage in another avsc.

https://stackoverflow.com/questions/62535519/how-do-i-use-an-avro-type-in-another-avro-type-without-defining-it-again

Can I apply the FileSorter so that the avsc files are parsed in their dependency order? is this a configuration, or a call that i can code? how to hook in the lifecycle?