I need to work with Avro schemas in a Scala 3 project and I am having trouble with union types. Imagine a situation like this:
{
"name": "ExampleObject",
"namespace": "example.namespace"
"type": "record",
"fields": [
{
"name": "location",
"type": "string"
}
]
}
{
"type": "record",
"name": "ExampleRecord",
"fields": [
{
"name": "exampleField",
"type": [
"string",
"int",
"example.namespace.ExampleObject"
]
}
]
}
The field ‘exampleField’ could be an int, a string or an ExampleObject. Now, both avro4s and avrohugger represent such fields using Shapeless and don’t support Scala 3’s union types yet.
Shapeless3 is unable to work with Shapeless2’s coproduct, which is what both project use. The farthest I got is to cross compile Shapeless2 in my Scala 3 project, but an error occurred about a missing typeclass No given instance of type shapeless.ops.coproduct.Inject
and I gave up.
Has anyone been able to work around this problem? Thanks in advance for any pointer ????