cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to write data to Confluent Kafka with SchemaRegistry format on sparkstructured?

GCosta
New Contributor II

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:

df.select(to_avro(carrossel_schema, schema_str)).alias("value") \
.write \
.format('kafka') \
.option("kafka.bootstrap.servers", confluent_server) \
.option("topic", topico) \
.option("kafka.security.protocol", "SASL_SSL") \
.option(
"kafka.sasl.jaas.config",
f"kafkashaded.org.apache.kafka.common.security.plain.PlainLoginModule required username='{confluent_user}' password='{confluent_pass}';"
) \
.option("kafka.ssl.endpoint.identification.algorithm", "https") \
.option("kafka.sasl.mechanism", "PLAIN") \
.save()


return df

0 REPLIES 0
Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!