To facilitate working with Avro in Scala, I'd like to define a case class based on the schema stored with a .avro file. I could try:
Thanks, any advice is appreciated. -Julian
I've been hacking on a little project called Scalavro to go the other way (Scala types to Avro schemas). It also gives you direct binary I/O.
Simple Example:
package com.gensler.scalavro.tests
import com.gensler.scalavro.types.AvroType
case class Person(name: String, age: Int)
val personAvroType = AvroType[Person]
personAvroType.schema
which yields:
{
"name": "Person",
"type": "record",
"fields": [
{"name": "name", "type": "string"},
{"name": "age", "type": "int"}
],
"namespace": "com.gensler.scalavro.tests"
}
There are many more examples on the project site (linked above) and in the scalatest specs.
I have plans to host the binaries on Sonatype OSS in the near future, but for now you can pull the source from github and sbt publish-local
if you want to try it out.
Update:
Scalavro is now available on Maven Central.
Look like you got your hands dirty with type providers at https://github.com/julianpeeters/avro-scala-macro-annotations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With