azure-cosmosdb-spark icon indicating copy to clipboard operation
azure-cosmosdb-spark copied to clipboard

Unable to write data to cosmos db.

Open fayzii opened this issue 5 years ago • 3 comments

Hi everyone i am unable to write data to cosmos db using databricks spark cluster however i have tried all the links and solutions in stackoverflow and github and tried all the possible jars with about every version. the error stack is: java.lang.NoSuchMethodError: com.microsoft.azure.documentdb.Offer.getContent()Lorg/json/JSONObject; at com.microsoft.azure.cosmosdb.spark.CosmosDBConnection.getCollectionThroughput(CosmosDBConnection.scala:163) at com.microsoft.azure.cosmosdb.spark.CosmosDBSpark$.save(CosmosDBSpark.scala:173) at com.microsoft.azure.cosmosdb.spark.CosmosDBSpark$.save(CosmosDBSpark.scala:501) at com.microsoft.azure.cosmosdb.spark.DefaultSource.createRelation(DefaultSource.scala:74) at org.apache.spark.sql.execution.datasources.SaveIntoDataSourceCommand.run(SaveIntoDataSourceCommand.scala:45) at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:72) at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:70) at org.apache.spark.sql.execution.command.ExecutedCommandExec.doExecute(commands.scala:88) at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:143) at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:131) at org.apache.spark.sql.execution.SparkPlan$$anonfun$executeQuery$5.apply(SparkPlan.scala:183) at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151) at org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:180) at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:131) at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:114) at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:114) at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:690) at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:690) at org.apache.spark.sql.execution.SQLExecution$$anonfun$withCustomExecutionEnv$1.apply(SQLExecution.scala:99) at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:228) at org.apache.spark.sql.execution.SQLExecution$.withCustomExecutionEnv(SQLExecution.scala:85)

fayzii avatar Apr 11 '19 12:04 fayzii

Hi, I am getting same issue, how did you resolve this issue?

rajendrakumarbadi avatar May 22 '20 18:05 rajendrakumarbadi

Have you tried this with the lasts version of the Spark connector? Note that it usually helps to use the uber-jar (which can be downloaded here: https://search.maven.org/remotecontent?filepath=com/microsoft/azure/azure-cosmosdb-spark_2.4.0_2.11/3.0.1/azure-cosmosdb-spark_2.4.0_2.11-3.0.1-uber.jar ) - When just resolving maven coordinates in Databricks it would install the normal jar - which has higher risk of dependency conflicts etc. When manually downloading the uber-jar and uploading it these conflicts are fixed.

FabianMeiswinkel avatar May 25 '20 07:05 FabianMeiswinkel

@rajendrakumarbadi let me know if any solution works for you i have left this issue opened a year ago.

fayzii avatar May 25 '20 08:05 fayzii