InfluxQL subquery not working as expected

Steps to reproduce:

  1. Run the following query:

    SELECT time, non_negative_derivative(bytes_sent) * 8 / (1024 * 1024) as "upload" FROM net WHERE deviceid = 'foo' AND ( interface = 'bar' ) AND time > 1602059405000000000 and time < 1602145805000000000;
    

    Output:

    name: net
    time			upload
    ----			------
    1602059762520982000	0.4219110297831778
    1602059942991442000	0.14064201490912454
    1602060120863627000	1.458414518004178
    1602060303108739000	0.07219379998013849
    1602060480010492000	0.06825290494840287
    1602060660448318000	1.4276837200836174
    1602060840407426000	0.052335845500822924
    1602061023772444000	0.06821147792188544
    1602061202014961000	0.018908723331938847
    1602061384209996000	0.0783028359661564
    1602061564084698000	0.04997642372038769
    ...
    

    Here, upload lies between 0 and 2.

  2. Modify the query like so:

    SELECT mean(upload) FROM (SELECT time, non_negative_derivative(bytes_sent) * 8 / (1024 * 1024) as "upload" FROM net WHERE deviceid = 'foo' AND ( interface = 'bar' ) AND time > 1602059405000000000 and time < 1602145805000000000) group by time(1d);
    

    Output:

    name: net
    time			mean
    ----			----
    1601942400000000000	6258.406305771333
    1602028800000000000	6356.274824691786
    1602115200000000000	3719.288451901718
    

Expected behavior:
mean should be between 0 and 2

Actual behavior:
mean is much bigger than 2.

Environment info:

  • System info:
$ uname -srm 
Linux 5.4.0-1025-gcp x86_64
  • InfluxDB version:
$ influxd version
InfluxDB v1.7.9 (git: 1.7 23bc63d43a8dc05f53afa46e3526ebb5578f3d88)

Hello @rak16,
Thank you for your detailed question. I’m not sure what’s happening. I’m sharing this with the team. Thank you.