FrankChen021 commented on issue #18010:
URL: https://github.com/apache/druid/issues/18010#issuecomment-6473402231
> The test also shows that SUM('abc') and AVG('abc') return null instead of
failing.
I checked the impl to see how SUM/AVG plans the literal `abc` into
`null:DECIMAL(38, 19)` while MAX/MIN/quantile aggregator does not.
SUM/AVG declares the operand type as NUMERIC(see `DRUID_SUM` in
`SumSqlAggregator`) , MIN/MAX declares the operand type as `COMPARABLE_ORDERED`
and quantile declares the operand type to be `ANY`. This allows the quantile
functions accept any type, not only string, but also array because
`DefaultOperandTypeChecker` does nothing for `ANY` type.
So fixing the string literal only fixes part of the problem. To fix this
completely, we may need to:
1. update the `QuantileSqlAggregator` to define the 1st operand type to be
numeric or any
2. update `DefaultOperandTypeChecker` so that it checks:
2.1. if the operand is ComplexSqlType, check against if it's defined in
the operand allowed complex type
2.2. If the operand is a character literal that won’t parse, reject it
with the friendly InvalidSqlInput.
2.3. if the operand is coerciable, try coercion
This is a little complicated than a simple change in
`toDruidExpressionForNumericAggregator`.
For `null:DECIMAL(38, 19)` problem of SUM/AVG, we may need to update
`DruidTypeCoercion#builtinFunctionCoercion ` to check if the literal is
parsable. This can be done in a separate PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]