jtuglu1 commented on code in PR #18949:
URL: https://github.com/apache/druid/pull/18949#discussion_r2726822436
##########
extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/sql/DoublesSketchApproxQuantileSqlAggregator.java:
##########
@@ -98,7 +99,14 @@ public Aggregation toDruidAggregation(
return null;
}
- final float probability = ((Number)
RexLiteral.value(probabilityArg)).floatValue();
+ final Object probabilityValue = RexLiteral.value(probabilityArg);
+ if (!(probabilityValue instanceof Number)) {
+ throw InvalidSqlInput.exception(
+ "DS_QUANTILES_SKETCH probability parameter must be a numeric
literal, got %s",
Review Comment:
I wonder if we can template this error a bit better to make it uniform and
easier for callers to access (this should make it easier for new use-cases to
adopt it).
Maybe something like:
```java
public static DruidException parameterTypeException(String function,
String expectedType, Object... args)
{
return DruidException.fromFailure(new InvalidSqlInput("{function}
parameter `{parameter}` must be a {expectedType} literal, got `%s`", msg,
args));
}
```
--
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]