pinot icon indicating copy to clipboard operation
pinot copied to clipboard

The aggregation functions EXPR_MIN/MAX do not seem to work.

Open mayankshriv opened this issue 1 year ago • 4 comments

It seems that the EXPR_MIN/MAX functions do not work in both v1 and v2 query engines.

Running a simple query like below errors out, even though there is no alias in the query. On debugging, I see that the query never gets rewritten as ExprMinMaxRewriter is not hooked up. I could also not find any config where the rewriter could be configured.

  • Any reason to not hookup the rewriter by default so the query can work?
  • If there's one, how does one hook that rewriter up, is there a config?
SELECT
  EXPR_MAX(balance,block_number) 
FROM org_2dYiMRMfas142XRKQ3bJIqmN3V6_base_erc20_balance_changes_block_v2_edea23a753f94dceae4c2b6d3fff50bd
WHERE token_address = lower('0x4200000000000000000000000000000000000006')

Query execution error on: Server_pinot-server-5.pinot-server-headless.pinot.svc.cluster.local_8098 org.apache.pinot.spi.exception.BadQueryRequestException: Invalid aggregation function: exprmax(balance,block_number); Reason: Aggregation function: EXPRMAX is only supported in selection without alias.

cc: @jasperjiaguo @siddharthteotia @Jackie-Jiang

mayankshriv avatar Jun 21 '24 05:06 mayankshriv

We ae using this function in our production, and it needs some special configuration https://app.gitbook.com/o/-LtRX9NwSr7Ga7zA4piL/s/-LtH6nl58DdnZnelPdTc-887967055/configuration-reference/functions/arg_min-arg_max#prerequisite

jasperjiaguo avatar Jun 21 '24 19:06 jasperjiaguo

@jasperjiaguo Screenshot 2024-06-21 at 3 35 43 PM

dorlevi avatar Jun 21 '24 19:06 dorlevi

Here is the public accessible doc: https://docs.pinot.apache.org/configuration-reference/functions/arg_min-arg_max

Jackie-Jiang avatar Jun 21 '24 20:06 Jackie-Jiang

@jasperjiaguo recently fixed a bug in this functionality that we had discovered from an internally deployed use case.

Jia - is this a different problem ?

siddharthteotia avatar Jun 28 '24 23:06 siddharthteotia

EXPRMAX is only supported in selection without alias is a know limitation and is called out in the design/user guide. Because this feature relies on query result rewriting to work, we could not use alias with it...

jasperjiaguo avatar Aug 16 '24 00:08 jasperjiaguo