DP-300 · Question #464
Hotspot Question You have an app that distributes users geographically by using sharding. You need to identify which users where active during the last 50 days. The solution must include users…
The correct answer is EXEC stored procedure name: sp_execute_remote; Parameter for ShardPoolName: data_source_name. This question tests knowledge of Azure Cosmos DB cross-partition (cross-shard) queries using the VALUE keyword and UNION ALL to aggregate data across geographic shards, filtering users active in the last 50 days.
Question
Exhibit
Answer Area
- EXEC stored procedure namesp_execute_remotesp_batch_paramssp_execute_remotesp_execute_sql
- Parameter for ShardPoolNamedata_source_namedata_source_nameparamstsql
Explanation
This question tests knowledge of Azure Cosmos DB cross-partition (cross-shard) queries using the VALUE keyword and UNION ALL to aggregate data across geographic shards, filtering users active in the last 50 days.
Approach. To query across all shards in a geographically distributed (sharded) database like Azure Cosmos DB, you use a cross-partition query. The correct approach involves using 'SELECT VALUE' to extract scalar values from each shard's collection, combined with 'UNION ALL' to merge results across all shards into a single result set. The date filter should use a function like DateTimeAdd or date arithmetic to calculate the threshold date 50 days prior to today (e.g., DateTimeAdd('dd', -50, GetCurrentDateTime())), and the WHERE clause filters records where the user's last active date is greater than or equal to that computed date. The 'VALUE' keyword in Cosmos DB SQL unwraps the JSON object to return scalar or array values directly, and 'UNION ALL' ensures all matching records across partitions/shards are included without deduplication overhead.
Concept tested. Azure Cosmos DB cross-partition queries using SELECT VALUE and UNION ALL across geographic shards, with date-based filtering using built-in date functions to identify recently active users within a specified time window.
Reference. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/union
Topics
Community Discussion
No community discussion yet for this question.
