exam questions

Exam AZ-303 All Questions

View all questions & answers for the AZ-303 exam

Exam AZ-303 topic 1 question 29 discussion

Actual exam question from Microsoft's AZ-303
Question #: 29
Topic #: 1
[All AZ-303 Questions]

Note: This question is part of a series of questions that present the same scenario. Each question in the series contains a unique solution that might meet the stated goals. Some question sets might have more than one correct solution, while others might not have a correct solution.
After you answer a question in this section, you will NOT be able to return to it. As a result, these questions will not appear in the review screen.
You have an Azure Cosmos DB database that contains a container named Container1. The partition key for Container1 is set to /day. Container1 contains the items shown in the following table.

You need to programmatically query Azure Cosmos DB and retrieve Item1 and Item2 only.
Solution: You run the following query.

SELECT id FROM c -
WHERE c.day = "Mon" OR c.day = "Tue"
You set the EnableCrossPartitionQuery property to False.
Does this meet the goal?

  • A. Yes
  • B. No
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️
Returns Item1 only as EnableCrossPartitionQuery property to False. If EnableCrossPartitionQuery property is set to true, it will return Item1, Item2, and Item3.
Reference:
https://docs.microsoft.com/en-us/azure/cosmos-db/sql-query-where https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.documents.client.feedoptions.enablecrosspartitionquery?view=azure-dotnet

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Kasurot
Highly Voted 4 years, 3 months ago
I think the answer is B but for a different reason than stated. It looks like if EnableCrossPartitionQuery is disabled and you try to query two partitions - Mon and Tue - then it would throw an exception and wouldn't return anything.
upvoted 44 times
malyaban
4 years, 1 month ago
This is absolutely true because if not then it should have returned item 1 and 2 not just item 1.
upvoted 11 times
...
...
Jinder
Highly Voted 4 years, 3 months ago
Was in today's exam. Given answer is correct.
upvoted 12 times
...
justfordevelopment
Most Recent 3 years, 1 month ago
In the exam on 12-03-2022. Total 50 questions including case study. "Litware Acquired Fabricam" case study.
upvoted 1 times
...
jadepe
3 years, 4 months ago
On exam13dic2021
upvoted 1 times
...
syu31svc
3 years, 8 months ago
Answer is No The query will look for day as Monday or Tuesday. Due to OR condition on day, query will span out to multiple partitions. Therefore, This query will return Item1, Item2 and Item3.
upvoted 2 times
Beuz
3 years, 1 month ago
Cross partitions queries are disabled, so no you won't get anything because it states you need to do it programmatically and that will throw an exception when your result contains documents from multiple partitions.
upvoted 2 times
...
...
tteesstt
3 years, 8 months ago
Something to note - CosmosDB SDK v3 (Microsoft.Azure.Cosmos) Cross Partition Queries are enabled by default and there is no option to enable/disable it with EnableCrossPartitionQuery. Instead you specify Partition Key - if partition key is provided, it will scan just 1 partition, if no partition key is provided it will scan all partitions.
upvoted 4 times
...
kkstays
3 years, 8 months ago
9th Aug 21 - Was in today's exam. 54 Questions in total (4 Case study), No Lab
upvoted 3 times
...
network_zeal
3 years, 8 months ago
typo in query , select query needs to be c.id not id.
upvoted 4 times
...
leo_az300
3 years, 8 months ago
If the query includes a filter against the partition key, like SELECT * FROM c WHERE c.city = "Seattle", it is routed to a single partition this query has two filters in partition key day, which will require for execution in 2 partitions at least. so EnableCrossPartitionQuery should be true
upvoted 2 times
...
pentium75
3 years, 9 months ago
Since I didn't fully understand it myself, and the comments here also give mixed answers, I tested it myself. Created database exactly specified here and ran query with EnableCrossPartitionQuery disabled. The query as stated in the question returns an error "Identifier 'id' could not be resolved". After changing "id" to "c.id" in the query it works, but returns three results (as would be expected with EnableCrossPartitionQuery turned on). I would guess that Cosmos DB creates partitions only when data exceeds a certain size? And despite the partition key here, Cosmos DB would use a single partition for these 4 small records?
upvoted 5 times
...
MatiUllah
3 years, 9 months ago
Was on exam 3 July 2021 and correct
upvoted 2 times
...
akp1000
3 years, 10 months ago
The answer is No because the query will throw an exception. It should be Select c.id.... not Select id.
upvoted 2 times
...
AravindITGuy
3 years, 10 months ago
Took exam today passed this morning was on there 6/21/2021
upvoted 1 times
...
nfett
3 years, 11 months ago
answer is B. for me its based on the query i would look for the item and not the day.
upvoted 1 times
...
azurellc
3 years, 11 months ago
On exam 5/15/2021
upvoted 4 times
...
skr123
4 years ago
answer suppose to be B because Key is Day and query is requesting for Iteam1/Item2 data with Enablecrosspratition is disabled hence it won't get Iteam 3. was in exam last week.
upvoted 2 times
...
AustinY
4 years, 1 month ago
was in today's exam
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago