spark.read not working on Synapse to Cosmos link

Sumit Kumar 96 Reputation points
2021-09-21T18:58:34.523+00:00

The code below worked always. However today I tried it with a Container Name of length 34 characters.

df = spark.read\
.format("cosmos.olap")\
.option("spark.synapse.linkedService", <Linked Service Name>)\
.option("spark.cosmos.container", <Container Name>)\
.load()\

Since then I keep getting this error on executing the code above with any new containers created from that point on -
ParseException:
mismatched input '<EOF>' expecting {'SELECT', 'FROM', 'ADD'..............

I've already tried switching over to a new Database, a new Cosmos SQL account, a new Synapse workspace, but the error doesn't go away for new containers. Containers created before trying out the 34 character length container name, continue to work fine.

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,405 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,452 questions
{count} votes

2 answers

Sort by: Most helpful
  1. PRADEEPCHEEKATLA-MSFT 77,901 Reputation points Microsoft Employee
    2021-09-22T10:02:54.747+00:00

    Hello @Sumit Kumar ,

    Thanks for the question and using MS Q&A platform.

    We haven't see this kind of the behaviour before, as per the repro I had tried with a container name of length 34 & 45 characters and able to run without any issues.

    You can try to below steps to connect Azure Cosmos DB using Apache Spark 2 in Azure Synapse Link:

    Step1: Go to Linked and select the Azure Cosmos DB linked service and test the connection.

    134293-image.png

    Step2: Select the container and click on actions => New Notebook => Load to DataFrame.

    134294-image.png

    Step3: Select the Spark pool and run the code to load the dataframe from container name of length 34.

    134160-image.png

    Step4: Select the Spark pool and run the code to load the dataframe from container name of length 45.

    134210-image.png

    For more details, refer to Interact with Azure Cosmos DB using Apache Spark 2 in Azure Synapse Link.

    After trying the above steps, if you still get the error message, please do let us know.

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

  2. Dan Dennett 1 Reputation point
    2022-04-11T11:26:36.493+00:00

    I get that error for any container which is empty. Once it has items, it works.

    0 comments No comments