Support Questions

Find answers, ask questions, and share your expertise

Way to get a Schema's Metadata without building it?

avatar

I have data that I want to serialize, and I currently have it laid out like so:

val mySerializer: AvroSnapshotSerializer = schemaRegistryClient.getDefaultSerializer(...)
val myObj: GenericData.Record = new GenericData.Record(...)
val myMetadata: SchemaMetadata = new SchemaMetadata.Builder("NameOfMySchema")
  .schemaGroup(...)
  .description(...)
  .etc.
val serializedObj = mySerializer.serializer(myObj, myMetadata)

Assuming that I've already registered my schema (by hand or in another application), is there a way to use the Serializer's serialize() method without having to build the metadata all over again? Can I retrieve the a SchemaMetadata object from, say, the SchemaVersionInfo that I get with the following?

schemaRegistryClient.getLatestSchemaVersionInfo("NameOfMySchema")

Having looked through the reference material and source code, I can't seem to find a way to get a copy of the metadata from without building it anew.

Thanks!

Edgar

1 ACCEPTED SOLUTION

avatar
Contributor

You can get SchemaMetadata for a given schema name using schemaRegistryClient with the below API.

SchemaMetadata schemaMetadata = getSchemaMetadataInfo(String schemaName).getSchemaMetadata()

View solution in original post

3 REPLIES 3

avatar
Super Collaborator

@Satish Duggana --> Thoughts?

avatar
Contributor

You can get SchemaMetadata for a given schema name using schemaRegistryClient with the below API.

SchemaMetadata schemaMetadata = getSchemaMetadataInfo(String schemaName).getSchemaMetadata()

avatar

Fantastic, that did the trick! Thank you