Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

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
New Member

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
New Member

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