heavydb icon indicating copy to clipboard operation
heavydb copied to clipboard

FLOOR() is an aggregate function?

Open pramsey opened this issue 9 years ago • 4 comments

Running this query:

select 
 avg(tip_amount) as tip_amount,
 avg(fare_amount) as fare_amount,
 avg(pickup_merc_x) as pickup_merc_x,
 avg(pickup_merc_y) as pickup_merc_y 
from taxi_weather_tracts_factual
group by
  floor(pickup_merc_x)

I get this response

Exception: Exception occurred: org.apache.calcite.runtime.CalciteContextException: From line 1, column 80 to line 1, column 99: Aggregate expression is illegal in GROUP BY clause

Which seems odd to me, as I expected FLOOR() to be an ordinary math function, not an aggregate.

The Server Version Number  : 3.3.1-20171108-32e7bcc
The Server Start Time      : 2017-12-04 : 17:4:19
The Server edition         : 3.3.1-20171108-32e7bcc

pramsey avatar Dec 04 '17 23:12 pramsey

Your sql is re-aliasing the column name pickup_merc_x and as we allow alias on group by it translates into something broken like

group by floor ( avg(pickup_merc_x) )

Don't re-alias to the same as the real column name you want to do the floor on, and you should be good.

That is a very specific data set, may I ask where you got it from?

dwayneberry avatar Dec 05 '17 00:12 dwayneberry

Thanks! The data set came packaged w/ the rpm I installed following your install directions.

pramsey avatar Dec 05 '17 01:12 pramsey

Oh this is aws instance?

dwayneberry avatar Dec 05 '17 01:12 dwayneberry

Yes.

On Mon, Dec 4, 2017 at 5:39 PM, Michael Thomson [email protected] wrote:

Oh this is aws instance?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/mapd/mapd-core/issues/136#issuecomment-349166986, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG827YrKL93IxTuDaIaU_vgf4o67oCbks5s9J7mgaJpZM4Q1fr5 .

pramsey avatar Dec 05 '17 02:12 pramsey