[SERVER-85298] distinct command with a winning plan of DISTINCT_SCAN returns null values, whereas COLLSCAN does not Created: 17/Jan/24  Updated: 24/Jan/24  Resolved: 24/Jan/24

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Alex Bevilacqua Assignee: Chris Kelly
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-14832 Distinct command result set may inclu... Needs Scheduling
Operating System: ALL
Steps To Reproduce:

db.foo.drop()
db.foo.insertMany([ { a: 1 }, { a: 1 }, { }, { a: 2 } ])
db.runCommand({ distinct: "foo", key: "a" }).values
// [ 1, 2 ]
db.foo.createIndex({ a: 1 })
db.runCommand({ distinct: "foo", key: "a" }).values
// [ null, 1, 2 ]

Participants:

 Description   

When executing a distinct command to identify distinct values within a collection, if the winning plan is a COLLSCAN the result set will exclude null values. If the winning plan is an IXSCAN (or a PROJECTION_COVERED/DISTINCT_SCAN) the result set will include the null values.

I'm assuming this is by design, so if that's the case perhaps there's a documentation gap here.



 Comments   
Comment by Chris Kelly [ 24/Jan/24 ]

This looks like a duplicate of SERVER-85229 / SERVER-14832 (backlogged)

Generated at Thu Feb 08 06:57:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.