<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:15:08 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-27422] Agg Pipeline return none type on from AVG func - is it working differently in 3.08 v 3.2.11</title>
                <link>https://jira.mongodb.org/browse/SERVER-27422</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Same exact code run from Python IDE and same data (copy) in Mongo 3.08 v 3.2.11 is yielding different results.  The agg pipeline has an AVG function and the results are feed into a round function.  When I run v. the upgraded database (same exact python code), I get none type from the agg pipeline.  When I run v. legacy, I don&apos;t -&amp;gt; I get float types.&lt;/p&gt;

</description>
                <environment>3.2.11</environment>
        <key id="338851">SERVER-27422</key>
            <summary>Agg Pipeline return none type on from AVG func - is it working differently in 3.08 v 3.2.11</summary>
                <type id="6" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14720&amp;avatarType=issuetype">Question</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="13202">Works as Designed</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="bowyerr">Richard Bowyer</reporter>
                        <labels>
                    </labels>
                <created>Wed, 14 Dec 2016 16:55:40 +0000</created>
                <updated>Fri, 27 Oct 2023 13:54:38 +0000</updated>
                            <resolved>Wed, 14 Dec 2016 19:41:14 +0000</resolved>
                                                                    <component>Aggregation Framework</component>
                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="1458345" author="thomas.schubert" created="Wed, 14 Dec 2016 20:41:18 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=bowyerr&quot; class=&quot;user-hover&quot; rel=&quot;bowyerr&quot;&gt;bowyerr&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;As Bernie described, this is the expected behavior resulting from the change in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-14691&quot; title=&quot;$avg aggregation operator should return null instead of 0&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-14691&quot;&gt;&lt;del&gt;SERVER-14691&lt;/del&gt;&lt;/a&gt;. In MongoDB 3.2, if all values are are missing, null, or non-numeric, the $avg will return null instead of 0. Please take a look at the test cases that were introduced in &lt;a href=&quot;https://github.com/mongodb/mongo/commit/84699e46bf32a2c9a17e85526bcc9c8395f64ac6&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;commit&lt;/a&gt; under &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-14691&quot; title=&quot;$avg aggregation operator should return null instead of 0&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-14691&quot;&gt;&lt;del&gt;SERVER-14691&lt;/del&gt;&lt;/a&gt; for examples of this behavior&lt;/p&gt;

&lt;p&gt;We understand that this was a backwards breaking change, but believe that the improvements were worthwhile. Previously, you could not determine if an average was 0 because there were nonnumeric fields or because the the numeric average of the fields was 0.&lt;/p&gt;

&lt;p&gt;If you are seeing null values being returned to your application, and would like to be seeing 0 instead, please append the following stage following the $avg stage in your aggregation where average the field containing your commuted average:&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;	$project: {&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;	            average: { $ifNull: [ &quot;$average&quot;, 0 ] }&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;This workaround should restore the previous behavior.&lt;/p&gt;

&lt;p&gt;Kind regards,&lt;br/&gt;
Thomas&lt;/p&gt;</comment>
                            <comment id="1458285" author="bowyerr" created="Wed, 14 Dec 2016 19:53:06 +0000"  >&lt;p&gt;I need to know what changed in which function(s) and the recommend remediation.&lt;/p&gt;</comment>
                            <comment id="1458284" author="bowyerr" created="Wed, 14 Dec 2016 19:52:09 +0000"  >&lt;p&gt;Wait a minute.  Worked in old, but not in new.  That is NOT worked as designed as a resolution.  Please reopen and try again.&lt;/p&gt;</comment>
                            <comment id="1458275" author="behackett" created="Wed, 14 Dec 2016 19:40:45 +0000"  >&lt;p&gt;It looks like the behavior change is a result of &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-14691&quot; title=&quot;$avg aggregation operator should return null instead of 0&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-14691&quot;&gt;&lt;del&gt;SERVER-14691&lt;/del&gt;&lt;/a&gt;. Note that $sum was not changed.&lt;/p&gt;</comment>
                            <comment id="1458259" author="bowyerr" created="Wed, 14 Dec 2016 19:27:02 +0000"  >&lt;p&gt;File attached&lt;/p&gt;</comment>
                            <comment id="1458209" author="behackett" created="Wed, 14 Dec 2016 18:54:45 +0000"  >&lt;p&gt;If you can send an example agg pipeline that reproduces the problem I would be happy to debug this further with the server team. Otherwise I&apos;ll close this ticket Won&apos;t Fix, since there is no way to fix this in PyMongo.&lt;/p&gt;</comment>
                            <comment id="1458174" author="bowyerr" created="Wed, 14 Dec 2016 18:29:06 +0000"  >&lt;p&gt;Agree.  I believe that this had nothing to do with Pymongo and everything to do with a change in behavior with the Agg Pipeline between the versions.&lt;/p&gt;</comment>
                            <comment id="1458156" author="behackett" created="Wed, 14 Dec 2016 18:17:22 +0000"  >&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;Can you send an example pipeline? I doubt this has anything to do with PyMongo. It sounds like a change in server behavior between 3.0 and 3.2.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="338925">SERVER-27423</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="149221">SERVER-14691</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="146028" name="slocIntToHour.py" size="46416" author="bowyerr" created="Wed, 14 Dec 2016 19:26:56 +0000"/>
                    </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_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 14 Dec 2016 18:17:22 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        7 years, 9 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>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            7 years, 9 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>bernie@mongodb.com</customfieldvalue>
            <customfieldvalue>kelsey.schubert@mongodb.com</customfieldvalue>
            <customfieldvalue>bowyerr</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrjom7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hssvx3:</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_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </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|hs4lo7:</customfieldvalue>

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