bigquery-emulator icon indicating copy to clipboard operation
bigquery-emulator copied to clipboard

MAX_BY is not supported

Open Gekko0114 opened this issue 10 months ago • 4 comments

What would you like to be added?

Hi,

Thanks for maintaining this awesome library.

I tried using it, but MAX_BY function hasn't been supported yet. It would be helpful if you could implement this function as well.

Gekko0114 avatar Feb 17 '25 07:02 Gekko0114

Or is this issue related to go-zetasql ?

Gekko0114 avatar Feb 17 '25 07:02 Gekko0114

Hi, last I checked it was not supported by google/zetasql.

MAX_BY and MIN_BY functions are synonymous with ANY_VALUE(x HAVING MAX y) or ANY_VALUE(x HAVING MIN y), you can use those as a workaround.

It'd be possible to register these functions in the goccy/go-zetasqlite source to fix this issue. Here's an example of how we did it for CONTAINS_SUBSTR which is missing from google/zetasql. https://github.com/goccy/go-zetasqlite/pull/209

ohaibbq avatar Feb 18 '25 17:02 ohaibbq

Thanks, I didn't know ANY_VALUE. I will try using it !

Gekko0114 avatar Feb 19 '25 04:02 Gekko0114

I've released a fix for this in the Recidiviz fork of the emulator - version v0.6.6-recdiviz.2 https://github.com/Recidiviz/bigquery-emulator/releases/tag/v0.6.6-recidiviz.2

ohaibbq avatar Nov 21 '25 03:11 ohaibbq