dateAdd(date, 0) does not return the original input for some dates

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Execution
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The dateAdd() function defined in date_time_support does not always return the original date when it is given the value 0 to add. This affects results of the $dateAdd expression and can cause $setWindowFields failures due to bounds being computed incorrectly using the dateAdd helper function when a window function has bounds [0,0].

      Original ticket description:

      See discussion here and in the other comments on the ticket.

      When running a $setWindowFields (regardless of window function), with a range-based upper bound of 0, we exclude the current document. We should be including it. When running a $setWindowFields with a range-based upper bound of "current", we correctly include the current document.

      I have attached a js test file that can be used to reproduce this.

      After fixing this bug, we should also add tests to jstests/aggregation/sources/setWindowFields/min_max_scaler_parsing.js for range-based boundaries with 0 and "current" as the upper bound.

            Assignee:
            Foteini Alvanaki
            Reporter:
            Finley Lau
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: