You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/02/15 16:47:40 UTC

[GitHub] [superset] pavlozt commented on a change in pull request #13122: fix: TimeTable average with nulls calculations

pavlozt commented on a change in pull request #13122:
URL: https://github.com/apache/superset/pull/13122#discussion_r576318976



##########
File path: superset-frontend/src/visualizations/TimeTable/TimeTable.jsx
##########
@@ -209,10 +209,20 @@ const TimeTable = ({
             .reduce((a, b) => a + b);
       } else if (column.colType === 'avg') {
         // Average over the last {timeLag}
-        v =
-          reversedEntries
-            .map((k, i) => (i < column.timeLag ? k[valueField] : 0))
-            .reduce((a, b) => a + b) / column.timeLag;
+        v = null;
+        if (reversedEntries.length > 0) {
+          const stats = reversedEntries.slice(undefined, column.timeLag).reduce(
+            function ({ count, sum }, entry) {
+              return entry[valueField] != null

Review comment:
       Thank you for rating.
   This piece is specially written to check only nulls to maintain speed.  I thought that there was no need for extra checks on a large tables.  In practice, it seems to work . 
   
   Do we really need to do this? 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org