Spark 2.4.0 Avro Java - cannot resolve method from_avro2019 Community Moderator ElectionWhy is the Java main method static?How do I invoke a Java method when given the method name as a string?Why can't static methods be abstract in JavaWhy doesn't Java allow overriding of static methods?Java: when to use static methodsIntelliJ inspection gives “Cannot resolve symbol” but still compiles codeWhat's the difference between map and flatMap methods in Java 8?map in DataFrame ( Spark2.0 )How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9Spark reading Avro file

What are some noteworthy "mic-drop" moments in math?

Why does liquid water form when we exhale on a mirror?

What are the practical Opportunity Attack values for a bugbear, holding a reach weapon, with the Polearm Master feat?

What Happens when Passenger Refuses to Fly Boeing 737 Max?

How can I get players to stop ignoring or overlooking the plot hooks I'm giving them?

Plausibility of Mushroom Buildings

NASA's RS-25 Engines shut down time

What wound would be of little consequence to a biped but terrible for a quadruped?

Hotkey (or other quick way) to insert a keyframe for only one component of a vector-valued property?

Can I pump my MTB tire to max (55 psi / 380 kPa) without the tube inside bursting?

Are babies of evil humanoid species inherently evil?

How are instrumentation amplifiers constructed on the semiconductor level?

Are there historical instances of the capital of a colonising country being temporarily or permanently shifted to one of its colonies?

Does this video of collapsing warehouse shelves show a real incident?

Do I really need to have a scientific explanation for my premise?

Is "conspicuously missing" or "conspicuously" the subject of this sentence?

At what distance can a bugbear, holding a reach weapon, with the Polearm Master feat, get their Opportunity Attack?

Makefile strange variable substitution

What problems would a superhuman have whose skin is constantly hot?

What's wrong with this bogus proof?

How do I express some one as a black person?

Do f-stop and exposure time perfectly cancel?

What was the Kree's motivation in Captain Marvel?

Find longest word in a string: are any of these algorithms good?



Spark 2.4.0 Avro Java - cannot resolve method from_avro



2019 Community Moderator ElectionWhy is the Java main method static?How do I invoke a Java method when given the method name as a string?Why can't static methods be abstract in JavaWhy doesn't Java allow overriding of static methods?Java: when to use static methodsIntelliJ inspection gives “Cannot resolve symbol” but still compiles codeWhat's the difference between map and flatMap methods in Java 8?map in DataFrame ( Spark2.0 )How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9Spark reading Avro file










1















I'm trying to run a spark stream from a kafka queue containing Avro messages.



As per https://spark.apache.org/docs/latest/sql-data-sources-avro.html I should be able to use from_avro to convert column value to Dataset<Row>.



However, I'm unable to compile the project as it complains from_avro cannot be found. I can see the method declared in package.class of the dependency - see screenshots attached.



How can I use the from_avro method from org.apache.spark.sql.avro in my Java code locally?



import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;

import static org.apache.spark.sql.functions.*;
import org.apache.spark.sql.avro.*;


public class AvroStreamTest
public static void main(String[] args) throws IOException, InterruptedException

// Creating local sparkSession here...

Dataset<Row> df = sparkSession
.readStream()
.format("kafka")
.option("kafka.bootstrap.servers", "host:port")
.option("subscribe", "avro_queue")
.load();

// Cannot resolve method 'from_avro'...
df.select(from_avro(col("value"), jsonFormatSchema)).writeStream().format("console")
.outputMode("update")
.start();






pom.xml:



<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-avro_2.11</artifactId>
<version>2.4.0</version>
</dependency>
<!-- more dependencies below -->

</dependencies>


It seems like Java is unable to import names from sql.avro.package.class










share|improve this question









New contributor




Maciej C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    1















    I'm trying to run a spark stream from a kafka queue containing Avro messages.



    As per https://spark.apache.org/docs/latest/sql-data-sources-avro.html I should be able to use from_avro to convert column value to Dataset<Row>.



    However, I'm unable to compile the project as it complains from_avro cannot be found. I can see the method declared in package.class of the dependency - see screenshots attached.



    How can I use the from_avro method from org.apache.spark.sql.avro in my Java code locally?



    import org.apache.spark.sql.Dataset;
    import org.apache.spark.sql.Row;
    import org.apache.spark.sql.SparkSession;

    import static org.apache.spark.sql.functions.*;
    import org.apache.spark.sql.avro.*;


    public class AvroStreamTest
    public static void main(String[] args) throws IOException, InterruptedException

    // Creating local sparkSession here...

    Dataset<Row> df = sparkSession
    .readStream()
    .format("kafka")
    .option("kafka.bootstrap.servers", "host:port")
    .option("subscribe", "avro_queue")
    .load();

    // Cannot resolve method 'from_avro'...
    df.select(from_avro(col("value"), jsonFormatSchema)).writeStream().format("console")
    .outputMode("update")
    .start();






    pom.xml:



    <build>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
    <source>1.8</source>
    <target>1.8</target>
    </configuration>
    </plugin>
    </plugins>
    </build>

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    </properties>

    <dependencies>
    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-core_2.11</artifactId>
    <version>2.4.0</version>
    </dependency>
    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-sql_2.11</artifactId>
    <version>2.4.0</version>
    </dependency>
    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-avro_2.11</artifactId>
    <version>2.4.0</version>
    </dependency>
    <!-- more dependencies below -->

    </dependencies>


    It seems like Java is unable to import names from sql.avro.package.class










    share|improve this question









    New contributor




    Maciej C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      1












      1








      1








      I'm trying to run a spark stream from a kafka queue containing Avro messages.



      As per https://spark.apache.org/docs/latest/sql-data-sources-avro.html I should be able to use from_avro to convert column value to Dataset<Row>.



      However, I'm unable to compile the project as it complains from_avro cannot be found. I can see the method declared in package.class of the dependency - see screenshots attached.



      How can I use the from_avro method from org.apache.spark.sql.avro in my Java code locally?



      import org.apache.spark.sql.Dataset;
      import org.apache.spark.sql.Row;
      import org.apache.spark.sql.SparkSession;

      import static org.apache.spark.sql.functions.*;
      import org.apache.spark.sql.avro.*;


      public class AvroStreamTest
      public static void main(String[] args) throws IOException, InterruptedException

      // Creating local sparkSession here...

      Dataset<Row> df = sparkSession
      .readStream()
      .format("kafka")
      .option("kafka.bootstrap.servers", "host:port")
      .option("subscribe", "avro_queue")
      .load();

      // Cannot resolve method 'from_avro'...
      df.select(from_avro(col("value"), jsonFormatSchema)).writeStream().format("console")
      .outputMode("update")
      .start();






      pom.xml:



      <build>
      <plugins>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
      <source>1.8</source>
      <target>1.8</target>
      </configuration>
      </plugin>
      </plugins>
      </build>

      <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
      </properties>

      <dependencies>
      <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_2.11</artifactId>
      <version>2.4.0</version>
      </dependency>
      <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-sql_2.11</artifactId>
      <version>2.4.0</version>
      </dependency>
      <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-avro_2.11</artifactId>
      <version>2.4.0</version>
      </dependency>
      <!-- more dependencies below -->

      </dependencies>


      It seems like Java is unable to import names from sql.avro.package.class










      share|improve this question









      New contributor




      Maciej C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I'm trying to run a spark stream from a kafka queue containing Avro messages.



      As per https://spark.apache.org/docs/latest/sql-data-sources-avro.html I should be able to use from_avro to convert column value to Dataset<Row>.



      However, I'm unable to compile the project as it complains from_avro cannot be found. I can see the method declared in package.class of the dependency - see screenshots attached.



      How can I use the from_avro method from org.apache.spark.sql.avro in my Java code locally?



      import org.apache.spark.sql.Dataset;
      import org.apache.spark.sql.Row;
      import org.apache.spark.sql.SparkSession;

      import static org.apache.spark.sql.functions.*;
      import org.apache.spark.sql.avro.*;


      public class AvroStreamTest
      public static void main(String[] args) throws IOException, InterruptedException

      // Creating local sparkSession here...

      Dataset<Row> df = sparkSession
      .readStream()
      .format("kafka")
      .option("kafka.bootstrap.servers", "host:port")
      .option("subscribe", "avro_queue")
      .load();

      // Cannot resolve method 'from_avro'...
      df.select(from_avro(col("value"), jsonFormatSchema)).writeStream().format("console")
      .outputMode("update")
      .start();






      pom.xml:



      <build>
      <plugins>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
      <source>1.8</source>
      <target>1.8</target>
      </configuration>
      </plugin>
      </plugins>
      </build>

      <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
      </properties>

      <dependencies>
      <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_2.11</artifactId>
      <version>2.4.0</version>
      </dependency>
      <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-sql_2.11</artifactId>
      <version>2.4.0</version>
      </dependency>
      <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-avro_2.11</artifactId>
      <version>2.4.0</version>
      </dependency>
      <!-- more dependencies below -->

      </dependencies>


      It seems like Java is unable to import names from sql.avro.package.class







      java scala spark-avro spark-streaming-kafka






      share|improve this question









      New contributor




      Maciej C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Maciej C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited Mar 8 at 11:31







      Maciej C













      New contributor




      Maciej C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Mar 6 at 15:25









      Maciej CMaciej C

      84




      84




      New contributor




      Maciej C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Maciej C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Maciej C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes


















          0














          It's because of the generated class names, importing it as import org.apache.spark.sql.avro.package$; and then using package$.MODULE$.from_avro(...) should work






          share|improve this answer








          New contributor




          ollik1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • That worked, thanks! Interesting how org.apache.spark.sql.functions import works fine but avro one doesn't.

            – Maciej C
            Mar 6 at 21:18












          • @MaciejC The method from_avro is defined inside a package object while functions are inside a regular object. The regular objects generate similar byte code with Java static methods but there is no construct in Java similar to Scala package objects.

            – ollik1
            Mar 7 at 7:06


















          0














          You need to include spark-sql-avro in your pom.xml which is available at



          https://mvnrepository.com/artifact/org.apache.spark/spark-sql-avro_2.11/2.4.0-palantir.28-1-gdf34e2d






          share|improve this answer























          • Thanks for your reply! That doesn't look like an official jar though?

            – Maciej C
            Mar 6 at 16:45










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          Maciej C is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55026584%2fspark-2-4-0-avro-java-cannot-resolve-method-from-avro%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          It's because of the generated class names, importing it as import org.apache.spark.sql.avro.package$; and then using package$.MODULE$.from_avro(...) should work






          share|improve this answer








          New contributor




          ollik1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • That worked, thanks! Interesting how org.apache.spark.sql.functions import works fine but avro one doesn't.

            – Maciej C
            Mar 6 at 21:18












          • @MaciejC The method from_avro is defined inside a package object while functions are inside a regular object. The regular objects generate similar byte code with Java static methods but there is no construct in Java similar to Scala package objects.

            – ollik1
            Mar 7 at 7:06















          0














          It's because of the generated class names, importing it as import org.apache.spark.sql.avro.package$; and then using package$.MODULE$.from_avro(...) should work






          share|improve this answer








          New contributor




          ollik1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • That worked, thanks! Interesting how org.apache.spark.sql.functions import works fine but avro one doesn't.

            – Maciej C
            Mar 6 at 21:18












          • @MaciejC The method from_avro is defined inside a package object while functions are inside a regular object. The regular objects generate similar byte code with Java static methods but there is no construct in Java similar to Scala package objects.

            – ollik1
            Mar 7 at 7:06













          0












          0








          0







          It's because of the generated class names, importing it as import org.apache.spark.sql.avro.package$; and then using package$.MODULE$.from_avro(...) should work






          share|improve this answer








          New contributor




          ollik1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.










          It's because of the generated class names, importing it as import org.apache.spark.sql.avro.package$; and then using package$.MODULE$.from_avro(...) should work







          share|improve this answer








          New contributor




          ollik1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer






          New contributor




          ollik1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered Mar 6 at 16:49









          ollik1ollik1

          1261




          1261




          New contributor




          ollik1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          ollik1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          ollik1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.












          • That worked, thanks! Interesting how org.apache.spark.sql.functions import works fine but avro one doesn't.

            – Maciej C
            Mar 6 at 21:18












          • @MaciejC The method from_avro is defined inside a package object while functions are inside a regular object. The regular objects generate similar byte code with Java static methods but there is no construct in Java similar to Scala package objects.

            – ollik1
            Mar 7 at 7:06

















          • That worked, thanks! Interesting how org.apache.spark.sql.functions import works fine but avro one doesn't.

            – Maciej C
            Mar 6 at 21:18












          • @MaciejC The method from_avro is defined inside a package object while functions are inside a regular object. The regular objects generate similar byte code with Java static methods but there is no construct in Java similar to Scala package objects.

            – ollik1
            Mar 7 at 7:06
















          That worked, thanks! Interesting how org.apache.spark.sql.functions import works fine but avro one doesn't.

          – Maciej C
          Mar 6 at 21:18






          That worked, thanks! Interesting how org.apache.spark.sql.functions import works fine but avro one doesn't.

          – Maciej C
          Mar 6 at 21:18














          @MaciejC The method from_avro is defined inside a package object while functions are inside a regular object. The regular objects generate similar byte code with Java static methods but there is no construct in Java similar to Scala package objects.

          – ollik1
          Mar 7 at 7:06





          @MaciejC The method from_avro is defined inside a package object while functions are inside a regular object. The regular objects generate similar byte code with Java static methods but there is no construct in Java similar to Scala package objects.

          – ollik1
          Mar 7 at 7:06













          0














          You need to include spark-sql-avro in your pom.xml which is available at



          https://mvnrepository.com/artifact/org.apache.spark/spark-sql-avro_2.11/2.4.0-palantir.28-1-gdf34e2d






          share|improve this answer























          • Thanks for your reply! That doesn't look like an official jar though?

            – Maciej C
            Mar 6 at 16:45















          0














          You need to include spark-sql-avro in your pom.xml which is available at



          https://mvnrepository.com/artifact/org.apache.spark/spark-sql-avro_2.11/2.4.0-palantir.28-1-gdf34e2d






          share|improve this answer























          • Thanks for your reply! That doesn't look like an official jar though?

            – Maciej C
            Mar 6 at 16:45













          0












          0








          0







          You need to include spark-sql-avro in your pom.xml which is available at



          https://mvnrepository.com/artifact/org.apache.spark/spark-sql-avro_2.11/2.4.0-palantir.28-1-gdf34e2d






          share|improve this answer













          You need to include spark-sql-avro in your pom.xml which is available at



          https://mvnrepository.com/artifact/org.apache.spark/spark-sql-avro_2.11/2.4.0-palantir.28-1-gdf34e2d







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 6 at 16:36









          Rohit YadavRohit Yadav

          14917




          14917












          • Thanks for your reply! That doesn't look like an official jar though?

            – Maciej C
            Mar 6 at 16:45

















          • Thanks for your reply! That doesn't look like an official jar though?

            – Maciej C
            Mar 6 at 16:45
















          Thanks for your reply! That doesn't look like an official jar though?

          – Maciej C
          Mar 6 at 16:45





          Thanks for your reply! That doesn't look like an official jar though?

          – Maciej C
          Mar 6 at 16:45










          Maciej C is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          Maciej C is a new contributor. Be nice, and check out our Code of Conduct.












          Maciej C is a new contributor. Be nice, and check out our Code of Conduct.











          Maciej C is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55026584%2fspark-2-4-0-avro-java-cannot-resolve-method-from-avro%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          1928 у кіно

          Захаров Федір Захарович

          Ель Греко