FrankChen021 commented on code in PR #20628:
URL: https://github.com/apache/druid/pull/20628#discussion_r4313934227
##########
processing/src/main/java/org/apache/druid/query/context/QueryContextParameters.java:
##########
@@ -2508,11 +2508,28 @@ static QueryContextParameter.Builder<Boolean>
booleanParameter(final String name
name,
Boolean.class,
value -> {
- if (value instanceof String) {
- // Matches the established QueryContexts coercion: any string
other than "true" (ignoring case) is false.
- return Boolean.parseBoolean((String) value);
+ if (value instanceof String string) {
+ if ("true".equalsIgnoreCase(string) || "1".equals(string)) {
+ return true;
+ } else if ("false".equalsIgnoreCase(string) || "0".equals(string))
{
+ return false;
+ }
+ } else if (value instanceof Integer || value instanceof Long ||
value instanceof Short || value instanceof Byte) {
Review Comment:
[P2] Integral BigInteger values are rejected
**Finding:** The new numeric branch accepts only Integer, Long, Short, and
Byte, so QueryContextParameter.parse rejects java.math.BigInteger.ONE and ZERO.
A query context built by a Java caller or by a mapper configured to retain
integral values as BigInteger therefore fails with the boolean-only error even
though the documented accepted numeric values are integer 1/0; the existing
integer parameter parser explicitly handles BigInteger.
**Suggestion:** Accept BigInteger or other non-floating integral Number
forms while continuing to reject floating-point values such as 1.0, and add
regression cases for BigInteger.ZERO and BigInteger.ONE.
--
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]