Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.
This repository was archived by the owner on Mar 10, 2025. It is now read-only.

Invalid resource id 'CollectionName' while using spark-docdb sample #84

@satlal

Description

@satlal

I am running into a “Invalid resource id ‘CollectionName’” exception when I try to execute a simple spark app with the spark-cosmosdb connector going against the local cosmosdb emulator -or- against azure instance of documentdb.
Is there something else I need to do other than what is mentioned in the documentation?
I am able to query the same db/collection using regular scala app (not via spark driver, but using DocumentClient).
My code reads as follows: (i have TestDb and TestCollection created)
val conf = new SparkConf().setAppName(this.getClass.getName).setMaster("local[*]")
val sc = new SparkContext(conf)
val sparkSession = SparkSession.builder().appName(this.getClass.getName).getOrCreate()
val readConfig2 = Config(Map("Endpoint" -> https://localhost:8081, "Masterkey" -> "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==", "Database" -> "TestDb", // “preferredRegions" -> "Central US;East US2;", "Collection" -> "TestCollection", "SamplingRatio" -> "1.0"))

// This line throws
val coll = sparkSession.sqlContext.read.cosmosDB(readConfig2)

Exception:

Java.lang.IllegalArgumentException: Invalid resource id TestCollection

            at com.microsoft.azure.documentdb.internal.ResourceId.parse(ResourceId.java:49)
            at com.microsoft.azure.documentdb.internal.PathsHelper.generatePath(PathsHelper.java:40)
            at com.microsoft.azure.documentdb.internal.routing.PartitionKeyRangeCache.getRoutingMapForCollection(PartitionKeyRangeCache.java:95)
            at com.microsoft.azure.documentdb.internal.routing.PartitionKeyRangeCache.access$000(PartitionKeyRangeCache.java:22)
            at com.microsoft.azure.documentdb.internal.routing.PartitionKeyRangeCache$1.call(PartitionKeyRangeCache.java:52)
            at com.microsoft.azure.documentdb.internal.routing.PartitionKeyRangeCache$1.call(PartitionKeyRangeCache.java:49)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:748)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions