title: Read Data from kafka topic into spark dataframe
body: <pre><code>private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(sparkSqlMysql.class);
  
  private static final SparkSession sparkSession = SparkSession.builder().master(&quot;local[*]&quot;).appName(&quot;Spark2JdbcDs&quot;)
          .getOrCreate();
  
  public static void main(String[] args) {
      // JDBC connection properties
  
  
      // Load MySQL query result as Dataset
  
      Dataset&lt;Row&gt; df = sparkSession.readStream().format(&quot;kafka&quot;).option(&quot;kafka.bootstrap.servers&quot;, &quot;localhost:9092&quot;)
              .option(&quot;subscribe&quot;, &quot;SqlMessages&quot;).load();
  </code></pre>
  <p>I want to do something where I can read data from my spark SQL from my  kafka topic but not able to do so .</p>
  <p>Can someone guide who I can convert my data from kafka Topic to spark SQL ?</p>
  <p>Something where I can do this</p>
  <pre><code> Dataset&lt;Row&gt; schoolData = sparkSession.sql(&quot;select * from Schools&quot;);
  </code></pre>