<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Getting Error &amp;quot;java.lang.NoSuchMethodError: org.apache.spark.sql.AnalysisException&amp;quot;
while writing data to event hub for streaming. It is working fine if I am writing it to another data brick table in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/getting-error-quot-java-lang-nosuchmethoderror-org-apache-spark/m-p/23711#M16424</link>
    <description>&lt;P&gt;The dataframe to write needs to have the following schema:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Column                             |  Type
----------------------------------------------
body (required)               |  string or binary 
partitionId (*optional)     |  string 
partitionKey (*optional)  |  string&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This worked for me (pyspark version):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df.withColumn('body', F.to_json(
       F.struct(*df.columns),
       options={"ignoreNullFields": False}))\
   .select('body')\
   .write\
   .format("eventhubs")\
   .options(**ehconf)\
   .save()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Nov 2022 16:47:24 GMT</pubDate>
    <dc:creator>Gepap</dc:creator>
    <dc:date>2022-11-17T16:47:24Z</dc:date>
    <item>
      <title>Getting Error "java.lang.NoSuchMethodError: org.apache.spark.sql.AnalysisException"
while writing data to event hub for streaming. It is working fine if I am writing it to another data brick table</title>
      <link>https://community.databricks.com/t5/data-engineering/getting-error-quot-java-lang-nosuchmethoderror-org-apache-spark/m-p/23709#M16422</link>
      <description>&lt;P&gt;import org.apache.spark.sql._&lt;/P&gt;&lt;P&gt;import scala.collection.JavaConverters._&lt;/P&gt;&lt;P&gt;import com.microsoft.azure.eventhubs._&lt;/P&gt;&lt;P&gt;import java.util.concurrent._&lt;/P&gt;&lt;P&gt;import scala.collection.immutable._&lt;/P&gt;&lt;P&gt;import org.apache.spark.eventhubs._&lt;/P&gt;&lt;P&gt;import scala.concurrent.Future&lt;/P&gt;&lt;P&gt;import scala.concurrent.ExecutionContext.Implicits.global&lt;/P&gt;&lt;P&gt;import org.apache.spark.sql.streaming.{OutputMode, Trigger}&lt;/P&gt;&lt;P&gt;import scala.concurrent.duration._&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var testConnectionstr = "Connection string"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;val parameters = EventHubsConf(testConnectionstr).setMaxEventsPerTrigger(5)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;val df = spark.readStream.format("delta").table("gold.redemption")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;val ds = df&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;.selectExpr("RedemptionId", "ProgramId","ClaimsPK_CL_FILEID")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;.writeStream&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;.format("eventhubs")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;.options(parameters.toMap)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;.option("startingOffsets", "latest")&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;.option("checkpointLocation", "path/to/checkpoint/dir")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;.start()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Error Log --&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ava.lang.NoSuchMethodError: org.apache.spark.sql.AnalysisException.&amp;lt;init&amp;gt;(Ljava/lang/String;Lscala/Option;Lscala/Option;Lscala/Option;Lscala/Option;)V&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.eventhubs.EventHubsWriter$.$anonfun$validateQuery$2(EventHubsWriter.scala:53)&lt;/P&gt;&lt;P&gt;	at scala.Option.getOrElse(Option.scala:189)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.eventhubs.EventHubsWriter$.validateQuery(EventHubsWriter.scala:53)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.eventhubs.EventHubsWriter$.write(EventHubsWriter.scala:70)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.eventhubs.EventHubsSink.addBatch(EventHubsSink.scala:39)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.streaming.MicroBatchExecution.$anonfun$runBatch$17(MicroBatchExecution.scala:805)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withCustomExecutionEnv$8(SQLExecution.scala:240)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:388)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withCustomExecutionEnv$1(SQLExecution.scala:187)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:973)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.SQLExecution$.withCustomExecutionEnv(SQLExecution.scala:142)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:338)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.streaming.MicroBatchExecution.$anonfun$runBatch$16(MicroBatchExecution.scala:803)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.streaming.ProgressReporter.reportTimeTaken(ProgressReporter.scala:320)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.streaming.ProgressReporter.reportTimeTaken$(ProgressReporter.scala:318)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.streaming.StreamExecution.reportTimeTaken(StreamExecution.scala:73)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.streaming.MicroBatchExecution.runBatch(MicroBatchExecution.scala:803)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.streaming.MicroBatchExecution.$anonfun$runActivatedStreamWithListener$5(MicroBatchExecution.scala:339)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.streaming.MicroBatchExecution.withSchemaEvolution(MicroBatchExecution.scala:904)&lt;/P&gt;&lt;P&gt;	at org.apache.spark.sql.execution.streaming.MicroBatchExecution.$anonfun$runActivatedStreamWithListener$2(MicroBatchExecution.scala:336)&lt;/P&gt;&lt;P&gt;	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;.options(parameters.toMap)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;.option("startingOffsets", "latest")&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;.option("checkpointLocation", "path/to/checkpoint/dir")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;.start()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 11:20:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/getting-error-quot-java-lang-nosuchmethoderror-org-apache-spark/m-p/23709#M16422</guid>
      <dc:creator>Rahul_Tiwary</dc:creator>
      <dc:date>2022-11-04T11:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error "java.lang.NoSuchMethodError: org.apache.spark.sql.AnalysisException"
while writing data to event hub for streaming. It is working fine if I am writing it to another data brick table</title>
      <link>https://community.databricks.com/t5/data-engineering/getting-error-quot-java-lang-nosuchmethoderror-org-apache-spark/m-p/23711#M16424</link>
      <description>&lt;P&gt;The dataframe to write needs to have the following schema:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Column                             |  Type
----------------------------------------------
body (required)               |  string or binary 
partitionId (*optional)     |  string 
partitionKey (*optional)  |  string&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This worked for me (pyspark version):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df.withColumn('body', F.to_json(
       F.struct(*df.columns),
       options={"ignoreNullFields": False}))\
   .select('body')\
   .write\
   .format("eventhubs")\
   .options(**ehconf)\
   .save()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 16:47:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/getting-error-quot-java-lang-nosuchmethoderror-org-apache-spark/m-p/23711#M16424</guid>
      <dc:creator>Gepap</dc:creator>
      <dc:date>2022-11-17T16:47:24Z</dc:date>
    </item>
  </channel>
</rss>

