<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:11:14 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-6275] $avg assume 0 for undefined</title>
                <link>https://jira.mongodb.org/browse/SERVER-6275</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;$avg assumes 0 for undefined $avg should behave like $push and $addToSet and return nothing for undefined&lt;/p&gt;</description>
                <environment>Macbook Pro (early 2011) OSX 10.7.4</environment>
        <key id="43131">SERVER-6275</key>
            <summary>$avg assume 0 for undefined</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</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="9">Done</resolution>
                                        <assignee username="matt.dannenberg">Matt Dannenberg</assignee>
                                    <reporter username="adam.bell.p">Adam Bell</reporter>
                        <labels>
                            <label>$avg</label>
                            <label>aggregation</label>
                    </labels>
                <created>Mon, 2 Jul 2012 13:08:12 +0000</created>
                <updated>Mon, 11 Jul 2016 18:32:17 +0000</updated>
                            <resolved>Fri, 27 Jul 2012 20:00:12 +0000</resolved>
                                    <version>2.1.2</version>
                                    <fixVersion>2.2.0-rc1</fixVersion>
                                    <component>Aggregation Framework</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="149331" author="auto" created="Wed, 1 Aug 2012 03:37:11 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2012-07-27T15:11:03-07:00&apos;, u&apos;email&apos;: u&apos;aaron@10gen.com&apos;, u&apos;name&apos;: u&apos;Aaron&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-6551&quot; title=&quot;$avg can miss results from shards that return double values&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-6551&quot;&gt;&lt;del&gt;SERVER-6551&lt;/del&gt;&lt;/a&gt; was fixed by &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-6275&quot; title=&quot;$avg assume 0 for undefined&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-6275&quot;&gt;&lt;del&gt;SERVER-6275&lt;/del&gt;&lt;/a&gt; changes.  Update tests to reflect new behavior.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/ac2f2b228f12a3a541639e34cd4d8df62bf31351&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/ac2f2b228f12a3a541639e34cd4d8df62bf31351&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="148260" author="auto" created="Fri, 27 Jul 2012 19:52:44 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2012-07-23T14:27:55-07:00&apos;, u&apos;email&apos;: u&apos;dannenberg.matt@gmail.com&apos;, u&apos;name&apos;: u&apos;Matt Dannenberg&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-6275&quot; title=&quot;$avg assume 0 for undefined&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-6275&quot;&gt;&lt;del&gt;SERVER-6275&lt;/del&gt;&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-6197&quot; title=&quot;$avg is calculated using integer math for integers even though result value is of type double&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-6197&quot;&gt;&lt;del&gt;SERVER-6197&lt;/del&gt;&lt;/a&gt; use double for $avg&lt;/p&gt;

&lt;p&gt;also do not count non-numeric types in $avg&lt;br/&gt;
also part of &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-6166&quot; title=&quot;consider expanding to wider data type on math overflow&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-6166&quot;&gt;&lt;del&gt;SERVER-6166&lt;/del&gt;&lt;/a&gt; up convert from int to long on $sum&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/186c5a411c3a1e616f7e876820a13af46d6faa4c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/186c5a411c3a1e616f7e876820a13af46d6faa4c&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="146420" author="adam.bell.p" created="Tue, 24 Jul 2012 02:51:33 +0000"  >&lt;p&gt;You are correct. Missing values should not affect average however in the version I have listed below they do affect the average.&lt;/p&gt;

&lt;p&gt;Here is a test. Based on the functionality you described below the average here should be 10 not 7.5&lt;/p&gt;

&lt;p&gt;db.avgtest.find()&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;500e09d68df5ba3913f3f8f0&quot;), &quot;value&quot; : 10 }
{ &quot;_id&quot; : ObjectId(&quot;500e09d98df5ba3913f3f8f1&quot;), &quot;value&quot; : 10 }
{ &quot;_id&quot; : ObjectId(&quot;500e09db8df5ba3913f3f8f2&quot;), &quot;value&quot; : 10 }
{ &quot;_id&quot; : ObjectId(&quot;500e09e48df5ba3913f3f8f3&quot;), &quot;name&quot; : &quot;No Value&quot; }
&lt;p&gt;&amp;gt; db.avgtest.aggregate({$project:{value:1}}, {$group:{_id:&lt;/p&gt;
{&quot;key&quot;:1}
&lt;p&gt;, avg:{$avg:&quot;$value&quot;}}})&lt;br/&gt;
{ &quot;result&quot; : [ { &quot;_id&quot; : { }, &quot;avg&quot; : 7.5 } ], &quot;ok&quot; : 1 }&lt;br/&gt;
&amp;gt; version()&lt;br/&gt;
version: 2.1.2 &lt;/p&gt;

&lt;p&gt;mongod --version&lt;br/&gt;
db version v2.1.2, pdfile version 4.5&lt;br/&gt;
Mon Jul 23 22:49:06 git version: 927beb54fb5ec38ccd0ca5fa712564a0696c9003&lt;/p&gt;


&lt;p&gt;Let me know if there is any additional information I can provide or perhaps I am looking at this incorrectly.&lt;/p&gt;</comment>
                            <comment id="146272" author="redbeard0531" created="Mon, 23 Jul 2012 20:09:21 +0000"  >&lt;p&gt;missing values shouldn&apos;t effect average. If you want missing treated as 0 you can always do {avg: {$avg:{$ifNull:&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;$field&amp;#39;, 0&amp;#93;&lt;/span&gt;}}}&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>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Mon, 23 Jul 2012 20:09:21 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            11 years, 29 weeks 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_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>adam.bell.p</customfieldvalue>
            <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>mathias@mongodb.com</customfieldvalue>
            <customfieldvalue>matt.dannenberg</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrnxs7:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>8714</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_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|hs9zxb:</customfieldvalue>

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