hellobabygogo opened a new issue #6085: SQL bug of avg function
URL: https://github.com/apache/incubator-druid/issues/6085
 
 
   `{
        "query":"explain plan for select  AVG(queryTime) from druid_request_log 
where __time >= timestamp '2018-08-01 16:19:09' group by dataSource ",
        "context":{"sqlTimeZone":"Asia/Shanghai"}
   }`
   
   `[
       {
           "PLAN": "DruidQueryRel(dataSource=[druid_request_log], 
intervals=[[2018-08-01T08:19:09.000Z/146140482-04-24T15:36:27.903Z]], 
dimensions=[[DefaultDimensionSpec{dimension='dataSource', outputName='d0', 
outputType='STRING'}]], 
aggregations=[[Aggregation{aggregatorFactories=[LongSumAggregatorFactory{fieldName='queryTime',
 expression='null', name='A0:sum'}, CountAggregatorFactory{name='A0:count'}], 
postAggregator=ArithmeticPostAggregator{name='a0', fnName='quotient', 
fields=[FieldAccessPostAggregator{name='null', fieldName='A0:sum'}, 
FieldAccessPostAggregator{name='null', fieldName='A0:count'}], op=QUOTIENT}, 
finalizingPostAggregatorFactory=null}]])\n"
       }
   ]`
   
   the avg fucntion defined in calcite avg(x) = sum(x) / count(X). but if the 
metric x is longSum aggregator
   the avg(x) = sum(x) / sum('"count"). 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to