In the case that a pipeline is being used for an update, ensure that FLE passes the pipeline to the aggregation machinery encapsulated by class FLEPipeline.
Given the output schema returned from aggregate_expression_intender::getOutputSchema for the last stage which should be present in FLEPipeline's _finalSchema field, compare it to the the schema for the collection being written to and produce an error message if there is a mismatch.
This ticket does not include the work to mark literals for encryption for the sake of writing to the database which is covered in SERVER-41485. So this work assumes that the schema output from the last Stage is already desirable.
Without SERVER-41485 The following should work and be tested:
- writing to unencrypted fields with a pipeline that does not source from encrypted fields
- writing from encrypted fields to other encrypted fields of the same type
The following is not expected to work:
- writing a literal or conditional expression containing literals into an encrypted field