I have an Avro generated class - com.avro.Person which has a method -> getClassSchema.
I’m passing className to a method, and in the method I need to get the Avro schema.
Here is the code I’m using:
val pr = Class.forName(productCls) // where productCls = classOf[Product].getName
How do I call the method getClassSchema of this class ?
Additional Info :
Links to Person.java & Person.avsc
Person.java
[https://drive.google.com/open?id=1LOa_muN0tFSEm-VReOBDh3ozU3ufmLZQ]
Person.avsc
[https://drive.google.com/open?id=1evVW9bTy5bOqq6h_oCyhXDFv9Fuz6zUn][1]
In Person.java, there is a method
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
I'm trying to call this method to get the AVRO schema corresponding to class - Person
Code
import com.avro.Person
val m1 = Map("schema.class" -> classOf[Person].getName)
This Map is passed onto a function .. say foo, and i'm trying to get the schema based on the class
def foo(m : Map[String, String]){
val personClass = Map("schema.class")
val pr = Class.forName(personClass)
//TBD - to get the schema of the avro class
}
Now using this "pr", i need to get the avro schema of the Person avro, hence i'm trying to call method getClassSchema, which returns the schema
How do i do this ?
any help on this is really appreciated.