I am trying to run a truncate statement from a spark code(from dataproc cluster) using the google-cloud-bigquery library .
1)This is the code
import com.google.cloud.bigquery.{BigQueryException, BigQueryOptions, QueryJobConfiguration}
import com.google.cloud.http.BaseHttpServiceException
object BigQueryClient {
def truncateBigQueryTable(tableName: String): Unit = {
val bigquery = BigQueryOptions.getDefaultInstance.getService
try {
val truncQuery = s"TRUNCATE TABLE `$tableName`"
val truncQueryConfig = QueryJobConfiguration.newBuilder(truncQuery).build
bigquery.query(truncQueryConfig)
}
catch {
case e: BigQueryException =>println("Table truncation failed \n" + e.toString)
}
}
}
2)In build.gradle , I have added the dependency
implementation group: 'com.google.cloud', name: 'google-cloud-bigquery', version: '1.133.0'
3)In the Spark Job I have added the google-cloud-bigquery jar as a dependency as well.
--jars gs://bucket_name/google-cloud-bigquery-1.133.0.jar
But when I run the spark job , it fails with the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/cloud/http/BaseHttpServiceException
My question is what is it that I am missing ? Because I am already adding the jar as an argument in the spark job.