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: 

I am trying to write a data frame to Kafka topic with Avro schema for key and value using a schema registry URL. The to_avro function is not writing t...

dheeraj2444
New Contributor II

I am trying to write a data frame to Kafka topic with Avro schema for key and value using a schema registry URL. The to_avro function is not writing to the topic and throwing an exception with code 40403 something. Is there an alternate way to do this?

error message:

Caused by: RestClientException: Schema not found; error code: 40403

This is how I am using to_avro:

val kafkaDf= df.select(to_avro($"value", lit("topicName-value"), schemaRegistry).as("value"))
kafkaDf
  .write
  .format("kafka")
  .option("kafka.bootstrap.servers", bootstrapServer)
  .option("topic", topicName)
  .option("schema.registry.url", schemaRegistry)
  .option(AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG, schemaRegistry)
  .save()

4 REPLIES 4

Debayan
Esteemed Contributor III
Esteemed Contributor III

Hi,

Could you please refer to https://github.com/confluentinc/kafka-connect-elasticsearch/issues/59 and let us know if this helps.

dheeraj2444
New Contributor II

This does not help solve the problem. I have the schema registered but somehow databricks's implementation of to_avro is not able to pick the correct one. I had to define my own Producer and Generic Avro records to send to the Kafka. to_avro utility method is not able to accomplish that.

Debayan
Esteemed Contributor III
Esteemed Contributor III

@Dheeraj Singh​ , Did it solve the issue? If yes, could you please log a case with Databricks to look into the implementation?

Hi @Dheeraj Singh​(Customer)​ , We haven’t heard from you on the last response from @Debayan Mukherjee​​, and I was checking back to see if his suggestions helped you.

Or else, If you have any solution, please do share that with the community as it can be helpful to others.

Also, Please don't forget to click on the "Select As Best" button whenever the information provided helps resolve your question.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group