Code Monkey home page Code Monkey logo

Struck with error py4j.protocol.Py4JJavaError: An error occurred while calling o39.saveAsBigQueryTable. : java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;) about spark-bigquery HOT 6 CLOSED

samelamin avatar samelamin commented on July 23, 2024
Struck with error py4j.protocol.Py4JJavaError: An error occurred while calling o39.saveAsBigQueryTable. : java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)

from spark-bigquery.

Comments (6)

kishore8714 avatar kishore8714 commented on July 23, 2024

Unable to import Module..
import com.samelamin.spark.bigquery._
Import ERROR
in python files..

from spark-bigquery.

samelamin avatar samelamin commented on July 23, 2024

This sounds like a bug that was fixed with the latest release, can you confirm what version you are using?

from spark-bigquery.

sunny1978 avatar sunny1978 commented on July 23, 2024

I picked 2.6.0 and built an uber jar. Still doesn't work. Read and Write, both throwing same error
My Jar size: 15710607 Apr 29 15:49 sparkbigquery-0.0.1-SNAPSHOT.jar (this is a wrapper jar. I built it so that I can have a big uber jar & incl all)

Read:
scala> val df = spark.sqlContext.read.format("com.samelamin.spark.bigquery").option("tableReferenceSource","projectid:schema.table").load()
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V
at com.google.cloud.hadoop.io.bigquery.BigQueryStrings.parseTableReference(BigQueryStrings.java:68)
at com.samelamin.spark.bigquery.BigQueryRelation.getConvertedSchema(BigQueryRelation.scala:19)
at com.samelamin.spark.bigquery.BigQueryRelation.schema(BigQueryRelation.scala:13)
at org.apache.spark.sql.execution.datasources.LogicalRelation.(LogicalRelation.scala:40)
at org.apache.spark.sql.SparkSession.baseRelationToDataFrame(SparkSession.scala:389)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:146)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:125)

Write:
scala> avrodf.saveAsBigQueryTable("projectid:schema.table")
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V
at com.google.cloud.hadoop.io.bigquery.BigQueryStrings.parseTableReference(BigQueryStrings.java:68)
at com.samelamin.spark.bigquery.BigQueryDataFrame.saveAsBigQueryTable(BigQueryDataFrame.scala:40)
... 50 elided

guava: 26.0

jdk1.8

Please help us. This seems to be a great api. very promising to use and easiness.

from spark-bigquery.

sunny1978 avatar sunny1978 commented on July 23, 2024

This sounds like a bug that was fixed with the latest release, can you confirm what version you are using?

2.6.0 also has this error. ShowStopper.

from spark-bigquery.

ameyamahajan avatar ameyamahajan commented on July 23, 2024

I was able to get this resolved by shading the google libraries.

 <configuration>
   <relocations>
     <relocation>
       <pattern>com.google</pattern>               
         <shadedPattern>shaded.guava</shadedPattern>
           <includes>
             <include>com.google.**</include>
           </includes>
           <excludes>
             <exclude>com.google.common.base.Optional</exclude>
             <exclude>com.google.common.base.Absent</exclude>
             <exclude>com.google.common.base.Present</exclude>
             <exclude>com.google.cloud.**</exclude>
           </excludes>
     </relocation>
   </relocations>
 </configuration>

from spark-bigquery.

samelamin avatar samelamin commented on July 23, 2024

Cheers for adding the example @ameyamahajan I would really appreciate it if you add a ToDo section in the readme :)

from spark-bigquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.