title: Convert a spark dataframe Row to Avro and publish to kakfa
body: <p>I have a spark data frame with the below schema and trying to stream this dataframe to Kafka using Avro </p>
  
  <pre><code>```root
   |-- clientTag: struct (nullable = true)
   |    |-- key: string (nullable = true)
   |-- contactPoint: struct (nullable = true)
   |    |-- email: string (nullable = true)
   |    |-- type: string (nullable = true)
   |-- performCheck: string (nullable = true)```
  </code></pre>
  
  <p>Sample Record: <code>{"performCheck" : "N", "clientTag" :{"key":"value"}, "contactPoint": {"email":"abc@gmail.com", "type":"EML"}}</code></p>
  
  <p>Avro Schema:</p>
  
  <p><code>{
      "name":"Message",
      "namespace":"kafka.sample.avro",
      "type":"record",
          "fields":[
              {"type":"string", "name":"id"},
              {"type":"string", "name":"email"}
              {"type":"string", "name":"type"}
          ]
  }</code></p>
  
  <p>I have couple of questions.</p>
  
  <ol>
  <li>What is the best way to convert a <code>org.apache.spark.sql.Row</code> to Avro Message because i want to extract <code>email</code> and <code>type</code> from the dataframe for each Row and use those values to construct an Avro message?</li>
  <li>Eventually, all the Avro messages will be send to Kafka. So, if there is an error while producing, how can i collect all the Row's that failed to be produced to Kafka and return a dataframe?</li>
  </ol>
  
  <p>Thanks for the help</p>