Add, document and make sure conditional projection in aggregation is treated correctly. Original pull request: #540.