<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:23:39 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-10626] Support numeric arrays as input to $add in aggregation&apos;s $project</title>
                <link>https://jira.mongodb.org/browse/SERVER-10626</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;The $add expression (as used in $project aggregation operator) supports the ability to have an explicit array of numbers to sum be specified, such as:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;{$project: {total: {$add: [1, 2, 3]}}}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;However, when same array numeric value is provided as an input, the addition/summation does not occur:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;c.save({a: [1, 2, 3]});&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;assert.eq(c.aggregate({$project: {total: {$add: &quot;$a&quot;}}}).result[0].total, 6); // Fails&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;This summation is entirely contained within the document. Today, doing this requires an $unwind followed by a $group. However {$group: {_id: &quot;$_id&quot;}} does not stream and can easily hit the 16MB limit on large collections. Furthermore, it&apos;s a shame to use $unwind/{$group: {_id: &quot;$_id&quot;}}, as it&apos;s just a verbose projection.&lt;/p&gt;

&lt;p&gt;The proposal is to make the above the test case pass.&lt;/p&gt;

&lt;p&gt;This would need documentation updates.&lt;/p&gt;</description>
                <environment></environment>
        <key id="87455">SERVER-10626</key>
            <summary>Support numeric arrays as input to $add in aggregation&apos;s $project</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="3">Duplicate</resolution>
                                        <assignee username="james.cohan">James Cohan</assignee>
                                    <reporter username="oleg@evergage.com">Oleg Rekutin</reporter>
                        <labels>
                            <label>pull-request</label>
                    </labels>
                <created>Mon, 26 Aug 2013 21:05:08 +0000</created>
                <updated>Thu, 30 May 2019 16:45:19 +0000</updated>
                            <resolved>Thu, 23 Jul 2015 15:31:24 +0000</resolved>
                                    <version>2.4.6</version>
                                                    <component>Aggregation Framework</component>
                                        <votes>2</votes>
                                    <watches>11</watches>
                                                                                                                <comments>
                            <comment id="2225868" author="ian@10gen.com" created="Fri, 26 Apr 2019 13:32:52 +0000"  >&lt;p&gt;Switching &quot;Drivers Changes Needed&quot; from &quot;Maybe&quot; to &quot;Not Needed&quot; since this was closed as something other than Fixed.&lt;/p&gt;</comment>
                            <comment id="937864" author="xgen-internal-githook" created="Thu, 11 Jun 2015 16:51:46 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;cswanson310&apos;, u&apos;name&apos;: u&apos;Charlie Swanson&apos;, u&apos;email&apos;: u&apos;charlie.swanson@mongodb.com&apos;}
&lt;p&gt;Message: Prep for &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-10626&quot; title=&quot;Support numeric arrays as input to $add in aggregation&amp;#39;s $project&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-10626&quot;&gt;&lt;del&gt;SERVER-10626&lt;/del&gt;&lt;/a&gt;, Make constructors for accumulators public&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/1b4c02b090b9c2fc56beca3295cdd7d5db48cf89&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/1b4c02b090b9c2fc56beca3295cdd7d5db48cf89&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="817658" author="oleg@evergage.com" created="Fri, 30 Jan 2015 18:06:00 +0000"  >&lt;p&gt;Asya, I agree, I don&apos;t see syntactic ambiguity in $add: &quot;$arrayOfInts&quot;. I&apos;ll try to get a new pull request in against the latest code base.&lt;/p&gt;

&lt;p&gt;Andy, do you still think there is syntactic ambiguity here? It&apos;s been over a year since I filed this, and so it&apos;s possible that having worked a lot more in the aggregation pipeline since then will have given you new insight.&lt;/p&gt;</comment>
                            <comment id="553639" author="asya" created="Thu, 17 Apr 2014 20:34:10 +0000"  >&lt;p&gt;I would like to be able to do $add:&quot;$arrayOfInts&quot; (though $sum:&quot;$arrayOfInts&quot; would work also, but $add is available in $project).&lt;/p&gt;

&lt;p&gt;I guess I&apos;m confused how $add:&lt;span class=&quot;error&quot;&gt;&amp;#91;1,2,3,4&amp;#93;&lt;/span&gt; could be ambiguous language-wise.&lt;/p&gt;</comment>
                            <comment id="414446" author="oleg@evergage.com" created="Thu, 29 Aug 2013 22:46:14 +0000"  >&lt;p&gt;Would it be better to change my patch to add $sum support to avoid the syntactic ambiguity and rule out vector addition?&lt;/p&gt;

&lt;p&gt;Allowing existing reduction operations, such as $sum, would be ideal. I would love to be able to $sum values (this JIRA), count array sizes (&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-4899&quot; title=&quot;aggregation:  need an expression to give the size of an array in projections&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-4899&quot;&gt;&lt;del&gt;SERVER-4899&lt;/del&gt;&lt;/a&gt;), count unique values in arrays (TBD). Being able to do some restrictions ($match) on the items summed is also very important.&lt;/p&gt;

&lt;p&gt;Of course, this now starting to sound like, &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-4438&quot; title=&quot;aggregation:  support nested pipelines on array-valued fields&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-4438&quot;&gt;SERVER-4438&lt;/a&gt;, which is nested pipelines on arrays. But that sounds big and scary, as I haven&apos;t sat down to think about how that would look syntactically. It might be way overkill and difficult to use.&lt;/p&gt;

&lt;p&gt;What&apos;s hurting us right now is the inability to do any kinds of reductions on arrays within documents, without resorting to $unwind/$group({_id:&quot;$_id&quot;}). However, when you do that, you can very quickly hit the 16MB limit, making whole-collection aggregations infeasible. (Not to mention the sheer waste of unwinding potentially long arrays just to count the number of items or add the values).&lt;/p&gt;

&lt;p&gt;I strongly urge some kind of ability to do these reductions. This is severely limiting the power of the aggregation framework for documents in any collections that we know will keep growing (which, for us, is all of our collections). Aggregation becomes a toy feature after a few encounters with this limitation (which is unfair, given how fast and useful it can often be).&lt;/p&gt;</comment>
                            <comment id="414400" author="schwerin" created="Thu, 29 Aug 2013 21:52:21 +0000"  >&lt;p&gt;Reducing values in arrays within documents is a concept that the projection language of aggregation intentionally omits, for the time being.  The reason is that it introduces a lot of potential syntactic ambiguity (is it vector add or reduction, e.g.), and we&apos;re still working to resolve that.  The underlying goal here is good, but I&apos;m not convinced this is the way.  An alternative to this that I&apos;ve been idly considering is allowing the existing reduction operators (&lt;tt&gt;$sum&lt;/tt&gt; in this case) to be used in projections to do array reduction.&lt;/p&gt;</comment>
                            <comment id="411777" author="oleg@evergage.com" created="Mon, 26 Aug 2013 21:18:03 +0000"  >&lt;p&gt;The motivating use-case for this change is the following:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;c.save({a:[{b: 1}, {b: 2}, {b: 3}]});&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&amp;nbsp;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;assert.eq(c.aggregate({$project: {total: {$add: &quot;$a.b&quot;}}}).result[0].total, 6);&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;Here, a normal &quot;$a.b&quot; projection would&apos;ve provided a $total array with numbers. With $add, the total can be obtained without unwind/group.&lt;/p&gt;</comment>
                            <comment id="411773" author="oleg@evergage.com" created="Mon, 26 Aug 2013 21:11:27 +0000"  >&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo/pull/476&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/pull/476&lt;/a&gt; pull request&lt;/p&gt;

&lt;p&gt;Looking at v2.6, it&apos;s somewhat difficult to tell, but this &lt;b&gt;might&lt;/b&gt; be addressed with $let? Either way, I think this would still be valuable in 2.6 due to simplicity of syntax.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="74681">SERVER-9625</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="459495">SERVER-31991</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>8.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 29 Aug 2013 20:13:52 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 41 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>asya.kamsky@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            4 years, 41 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>schwerin@mongodb.com</customfieldvalue>
            <customfieldvalue>asya.kamsky@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>ian@mongodb.com</customfieldvalue>
            <customfieldvalue>james.cohan</customfieldvalue>
            <customfieldvalue>oleg@evergage.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrmief:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrek9b:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>7230</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="635">Quint Iteration 7</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_10166" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Tests Written</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10154"><![CDATA[Complete]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrj6tj:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>