manticoresoftware / manticoresearch

Easy to use open source fast database for search | Good alternative to Elasticsearch now | Drop-in replacement for E in the ELK soon
https://manticoresearch.com
GNU General Public License v3.0
9.05k stars 509 forks source link

incorrect calculations in select section #949

Open vorslov opened 1 year ago

vorslov commented 1 year ago

Describe the bug
in the select section, the math calculations are correct

To Reproduce
Steps to reproduce the behavior:

drop table if exists t1;   
drop table if exists t2;   
drop table if exists t;   
create table t1(i int, b bool);   
create table t2 like t1;   
create table t type='distributed' local='t1' local='t2';   
insert into t1 values(1,2,0);   
insert into t2 values(2,2,0);   
select sum(i) si, sum(b) sb, si-sb delta from t;  

 ------ ------ -------   
| si   | sb   | delta |  
 ------ ------ -------   
|    4 |    0 |     2 |  
 ------ ------ -------   

Expected behavior
delta = 4

Describe the environment:

Messages from log files:

Additional context

tomatolog commented 1 year ago

operation on aggregates at the distributed index need complete new stage as distributed index does not calculate any expressions it just merges results sets and also could recalculate aggregates by the sorter \ grouper but at that stage (at distributed index at master or on agent) is hard

that seems a bug but the new feature similar to having statement (filter after aggregates got calculated) should be implemented