[SERVER-41991] [FLE] $$REMOVE should not add a NotEncryptedNode to the schema tree. Created: 27/Jun/19  Updated: 05/Dec/22

Status: Backlog
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Davis Haupt (Inactive) Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Optimization
Participants:

 Description   

Currently, $$REMOVE is treated like a $let variable by the expression schema walker, and so is represented by an NotEncryptedNode in the schema tree. However, this means that aggregations cannot conditionally include or exclude encrypted fields with matching encryption in a $project stage, and then later match or group on that field, since the combination of $$REMOVE with the encrypted field will result in a MixedStateNode. Instead, $$REMOVE should just not result in the addition/reconciliation of any schema nodes.



 Comments   
Comment by David Storch [ 27/Jun/19 ]

I changed this from "Bug" to "Improvement", which hides the "Steps to Reproduce" field. Recording the helpful example from davis.haupt here:

Sending this pipeline to mongocryptd

 
[ 
{ 
$project: { 
'secret': {$cond: {if: '$isAdmin', then: '$secret', else: '$$REMOVE'}} 
} 
}, 
{ 
$group: { 
_id: '$secret', 
count: {$sum: 1} 
} 
} 
] 

Will result in the error "Cannot get metadata for path whose encryption properties are not known until runtime."

Generated at Thu Feb 08 04:59:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.