title: How to get columns from an org.apache.spark.sql row by name?
body: <p>I have reading records from a kafka source to <code>mydataframe</code> spark dataframe.
  I want to pick some column from the <code>row</code> and do some operation. So to check if I am getting the correct index, I tried to print the index in the statement <code>println(row.getFieldIndex(pathtoDesiredColumnFromSchema))</code> as shown below:</p>
  
  <pre><code>val pathtoDesiredColumnFromSchema = "data.root.column1.column2.field"
  val myQuery = mydataframe.writeStream.foreach(new ForeachWriter[Row]() {
  
    override def open(partitionId: Long, version: Long): Boolean = true
    override def process(row: Row): Unit = {
      println(row.getFieldIndex(pathtoDesiredColumnFromSchema))
    }
  
    override def close(errorOrNull: Throwable): Unit = {}
  }).outputMode("append").start()
  </code></pre>
  
  <p>But the above code says that row has only one name as <code>data</code>, and there is no column name <code>data.root.column1.column2.field</code>.</p>
  
  <p>What is the correct way to get columns values from the spark sql row by name paths?</p>