如何修复“错误:找不到:键入CosmosDBSourceProvider”在databricks scala中从cosmos db读取流

我正在尝试通过以下方式从数据源使用scala来从cosmos db读取流:https://docs.microsoft.com/bs-latn-ba/azure/cosmos-db/spark-connector 但是以某种方式,scala读取流代码的示例对我不起作用。

我一直在尝试导入更多的库,例如“ com.microsoft.azure.cosmosdb.spark.streaming._”,但是仍然无法正常工作。

这是我要使用的scala代码

import com.microsoft.azure.cosmosdb.spark.schema._
import com.microsoft.azure.cosmosdb.spark._
import com.microsoft.azure.cosmosdb.spark.config.Config

val readConfig = Config(Map(
  "Endpoint" -> cosmos_endpoint,"Masterkey" -> cosmos_masterkey,"Database" -> "abc","Collection" -> "123","ReadChangeFeed" -> "true","ChangeFeedQueryName" -> "Scala-Changefeed","ChangeFeedStartFromTheBeginning" -> "true","InferStreamSchema" -> "false","ChangeFeedCheckpointLocation" -> ".../ChagefeedCheckpoint"))

 val changeFeed = spark.readStream.format(classOf[CosmosDBSourceProvider].getName).options(readConfig).load()

我收到的错误消息是

command-2054522864350223:16: error: not found: type CosmosDBSourceProvider
val changeFeed = spark.readStream.format(classOf[CosmosDBSourceProvider].getName).options(readConfig).load()
                                                 ^
wan_XM 回答:如何修复“错误:找不到:键入CosmosDBSourceProvider”在databricks scala中从cosmos db读取流

也许您没有导入某些课程。 我认为您可以替换

.format(classOf[CosmosDBSourceProvider].getName)

作者

.format("com.microsoft.azure.cosmosdb.spark.streaming.CosmosDBSourceProvider")
本文链接:https://www.f2er.com/3125044.html

大家都在问