-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue referencing or using field value set with SetWindowFieldsOperation shift #4745
Comments
thank you @alex-ionescu-teamextension for getting in touch. Please do not use images but take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem. |
Of course @christophstrobl , Given the below documents in a collection named "telemetry-debug":
Then running the following aggregation should correctly populate the "timeDifference" field for the second document, given that both "timestamp" and "previous" are available:
Adding a dummy field with a value like "new Date()" works as expected and the $dateDiff operator populates the field correctly. However when running the above code the field reference for "previous" appears in the aggregation pipeline as "$_id.previous", so I am guessing it is something that happens when looking up the target field. Let me know if I can provide more details. |
Thank you @alex-ionescu-teamextension - I see the |
Hello,
I am using spring-data-mongodb-4.2.5.jar and I have the usecase where I am doing a shift to get the next or previous value of a timestamp field using $setWindowFields.
The problem with the Java approach is that the resulting field is not correctly referenced in the aggregation pipeline, resulting in a null value when doing a $dateDiff.
This is how I am doing the $setWindowFields / $dateDiff:
And this is how the operator ends up in the aggregation pipeline output:
Any ideea why the "endDate" field is referenced like this, is there a way to overcome this issue to get the correct result? How could I do a dateDiff between computed / shifted fields?
Thanks in advance,
Alex
The text was updated successfully, but these errors were encountered: