<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:02:02 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>[DOCS-11089] $sum aggregation operator may accept multiple expressions when nested in $group stage</title>
                <link>https://jira.mongodb.org/browse/DOCS-11089</link>
                <project id="10380" key="DOCS">Documentation</project>
                    <description>&lt;p&gt;Documentation for the &lt;a href=&quot;https://docs.mongodb.com/manual/reference/operator/aggregation/sum/index.html#grp._S_sum&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;$sum&lt;/tt&gt;&lt;/a&gt; aggregation operator discusses two modes:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;In a &lt;tt&gt;$group&lt;/tt&gt; pipeline stage, &lt;tt&gt;$sum&lt;/tt&gt; takes a single expression argument&lt;/li&gt;
	&lt;li&gt;In a &lt;tt&gt;$project&lt;/tt&gt; pipeline stage, &lt;tt&gt;$sum&lt;/tt&gt; accepts either a single expression or an array of expressions&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;In &lt;a href=&quot;https://github.com/doctrine/mongodb-odm/issues/1678&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;doctrine/mongodb-odm#1678&lt;/a&gt; (and a Stack Overflow thread linked therein), we see that the server accepts 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;[{&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;&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;    &quot;$group&quot;: {&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;&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;        &quot;_id&quot;: null,&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;&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;        &quot;games&quot;: { &quot;$sum&quot;: { &quot;$sum&quot;: [ &quot;$wins&quot;, &quot;$losses&quot;, &quot;$ties&quot; ] } }&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;&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;    }&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;}]&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;Since &lt;tt&gt;$sum&lt;/tt&gt; isn&apos;t being used in a &lt;tt&gt;$project&lt;/tt&gt; stage, I would not expect it to accept multiple arguments. I&apos;m therefore wondering if the server is being lax in what it accepts, or if the documentation is missing some nuance. It would be good to ask a server engineer to chime in on this to clarify.&lt;/p&gt;

&lt;p&gt;Comment from &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=kay.kim&quot; class=&quot;user-hover&quot; rel=&quot;kay.kim&quot;&gt;kay.kim&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I guess we could clarify that if your &amp;lt;expression&amp;gt; is itself a $sum expression, then, the nested $sum expression syntax can be stuff.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;As an aside, I&apos;m not sure why &lt;tt&gt;$sum&lt;/tt&gt; was overloaded to be used in &lt;tt&gt;$project&lt;/tt&gt; when we already had a &lt;a href=&quot;https://docs.mongodb.com/manual/reference/operator/aggregation/add/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;$add&lt;/tt&gt;&lt;/a&gt; operator. &lt;/p&gt;</description>
                <environment></environment>
        <key id="468834">DOCS-11089</key>
            <summary>$sum aggregation operator may accept multiple expressions when nested in $group stage</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="jmikola@mongodb.com">Jeremy Mikola</reporter>
                        <labels>
                            <label>backlog</label>
                            <label>reopened</label>
                            <label>request</label>
                            <label>server-docs-bug-bash</label>
                            <label>triage</label>
                    </labels>
                <created>Wed, 6 Dec 2017 18:10:55 +0000</created>
                <updated>Mon, 22 Jan 2024 16:15:11 +0000</updated>
                                                                            <component>manual</component>
                        <due></due>
                            <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="4947948" author="JIRAUSER1264463" created="Wed, 2 Nov 2022 13:54:34 +0000"  >&lt;p&gt;Thanks &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jmikola%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;jmikola@mongodb.com&quot;&gt;jmikola@mongodb.com&lt;/a&gt;, &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=asya.kamsky%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;asya.kamsky@mongodb.com&quot;&gt;asya.kamsky@mongodb.com&lt;/a&gt;. Appreciate the feedback.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=asya.kamsky%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;asya.kamsky@mongodb.com&quot;&gt;asya.kamsky@mongodb.com&lt;/a&gt;: Definitely not expecting you to ping the ticket to keep it from being closed. On the Server docs team, we&apos;re trying really hard to address the large documentation ticket backlog and then implement a prioritization strategy to keep it from getting so large in the future. This way we&apos;ll be able to triage and groom our backlog periodically and efficiently, going forward. Please bear with us as we work through this very old backlog, and of course let us know if tickets have been closed that shouldn&apos;t have been!&lt;/p&gt;</comment>
                            <comment id="4946412" author="asya" created="Wed, 2 Nov 2022 00:06:18 +0000"  >&lt;p&gt;I&apos;m not sure what &quot;due to inactivity&quot; means - are we supposed to periodically ping the ticket to keep it from being closed?&lt;/p&gt;

&lt;p&gt;This is related to accumulators and expressions and how they are documented.  It should be considered together with DOCSP-14384&lt;/p&gt;</comment>
                            <comment id="4942827" author="jmikola@gmail.com" created="Tue, 1 Nov 2022 02:03:10 +0000"  >&lt;p&gt;The &lt;a href=&quot;https://www.mongodb.com/docs/v6.0/reference/operator/aggregation/sum/#syntax&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;current syntax documentation&lt;/a&gt; seems more clear than when I originally opened this issue, so I&apos;m fine with leaving this closed.&lt;/p&gt;

&lt;p&gt;cc: &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=asya.kamsky%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;asya.kamsky@mongodb.com&quot;&gt;asya.kamsky@mongodb.com&lt;/a&gt; in case your previous comment warrants some action (although it seems beyond the scope of just docs)&lt;/p&gt;</comment>
                            <comment id="4940644" author="edu.bot" created="Mon, 31 Oct 2022 16:08:34 +0000"  >&lt;p&gt;Hello! This ticket has been closed due to inactivity. If you believe this ticket is still important, please reopen it and leave a comment to explain why. Thank you!&lt;/p&gt;</comment>
                            <comment id="2442955" author="asya" created="Tue, 1 Oct 2019 15:01:24 +0000"  >&lt;p&gt;The real issue is that we try to enumerate stages where &quot;$sum&quot; is available.&lt;/p&gt;

&lt;p&gt;Possibly a better structure for agg would be to get rid of the enumeration everywhere and just have expressions (which can be used &lt;b&gt;everywhere&lt;/b&gt;) and accumulators which can be used in grouping stages).&lt;/p&gt;

&lt;p&gt;Most accumulators can be used as expressions - they take one argument as accumulator, but an array of arguments as an expression.&lt;/p&gt;</comment>
                            <comment id="2442945" author="asya" created="Tue, 1 Oct 2019 14:59:26 +0000"  >&lt;p&gt;&amp;gt; I&apos;m not sure why $sum was overloaded to be used in $project when we already had a $add operator.&lt;/p&gt;

&lt;p&gt;$sum as expression acts the same as accumulator $sum in that it &lt;b&gt;ignores all non-numeric arguments&lt;/b&gt;.   $add will error on non-numeric (and non-dates in some cases).&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 6 Dec 2017 20:25:53 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 14 weeks 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>emet.ozar@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            1 year, 14 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>asya.kamsky@mongodb.com</customfieldvalue>
            <customfieldvalue>edu.bot</customfieldvalue>
            <customfieldvalue>jmikola@mongodb.com</customfieldvalue>
            <customfieldvalue>sarah.olson@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htlpdz:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10555" key="com.atlassian.jira.plugin.system.customfieldtypes:float">
                        <customfieldname>Story Points</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0.5</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htlbhz:</customfieldvalue>

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