# How to write data in SchemaRegistry format with sparkstructured?

**URL:** <https://forum.confluent.io/t/how-to-write-data-in-schemaregistry-format-with-sparkstructured/10888>\
**Category:** Schema Registry\
**Created:** [12 June 2024 19:51 UTC](https://forum.confluent.io/t/how-to-write-data-in-schemaregistry-format-with-sparkstructured/10888 "2024-06-12T19:51:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![guacosta](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@guacosta](https://forum.confluent.io/u/guacosta)\
**Post date:** [12 June 2024 19:51 UTC](https://forum.confluent.io/t/how-to-write-data-in-schemaregistry-format-with-sparkstructured/10888/1 "2024-06-12T19:51:24Z")

</div>

Hi There!  
I am to trying write a batch data to kafka topic with schema registry in databricks using pyspark, i serialize the data with pyspark to\_avro function and write it to the topic, but the consumers can’t read the schema id. If they do not separate the schema\_id first 5 bytes they can read the data as well.  
I read the avro schema from .avsc file downloaded in confluent, and it’s version is ok.

This is my script:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/2X/2/2fafca68ae7a96fed03c775af7e7747d45092d01.png)

The var schema\_str is the avro schema readed.

Anyone can help me to serialize this data with schema\_id in the few first bytes?(Schema Registry Format)
