ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 8.0.13, 9.0.4
    • Component/s: None
    • Query Execution
    • ALL
    • Hide
      1. Install the MongoDB Node.js driver: npm install mongodb
      1. Run the attached reproduce-densify-duplicates.mjs script against a MongoDB server.
      1. The script uses an in-memory $documents source containing five documents across three partitions.
      1. The aggregation uses $densify with field: "date", partitionByFields: ["company", "department"], step: 1, unit: "month" and bounds: "full".
      1. Observe the duplicate partition/date combinations in the output.
      1. Replace bounds: "full" with bounds: [date(1), date(4)] and run the script again.
      1. The duplicates disappear, and the aggregation returns the expected 9 documents.
      Show
      Install the MongoDB Node.js driver: npm install mongodb Run the attached reproduce-densify-duplicates.mjs script against a MongoDB server. The script uses an in-memory $documents source containing five documents across three partitions. The aggregation uses $densify with field: "date" , partitionByFields: ["company", "department"] , step: 1 , unit: "month" and bounds: "full" . Observe the duplicate partition/date combinations in the output. Replace bounds: "full" with bounds: [date(1), date(4)] and run the script again. The duplicates disappear, and the aggregation returns the expected 9 documents.
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Description

      When usingĀ $densify with bounds: "full" and partitionByFields, MongoDB generates duplicate documents for dates that already exist in the input.

      The issue occurs when the first document of a partition is exactly one step after the global minimum date.

      Replacing bounds: "full" with explicit date bounds covering the same period resolves the issue.

      Expected Behavior

      The global date range spans January through March 2011.

      Each of the three partitions should contain exactly one document per month, resulting in 9 documents.

      Existing documents should be preserved, and only missing dates should be generated.

      Actual Behavior

      With bounds: "full", MongoDB produces duplicate partition/date combinations.

      In particular, the Acme/Sales partition already contains a document for February 1, 2011, but $densify also generates a document for that same date.

      With explicit bounds [2011-01-01T00:00:00Z, 2011-04-01T00:00:00Z], the aggregation returns the expected 9 documents without duplicates.

        1. output.txt
          4 kB
        2. reproduce-densify-duplicates.mjs
          3 kB

            Assignee:
            Unassigned
            Reporter:
            German PEDROSA LOUREIRO (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: