Repository navigation
Done
Labels
PPLPiped processing languagebugSomething isn't workingdynamic-testIssues found by or related to Dynamic Testing
Description
What is the bug?
Casting a boolean field to double or float fails in codegen with a 500. Casting it to int or long works.
How can one reproduce the bug?
- Create the index and doc:
curl -s -X PUT localhost:9200/hdemo -H 'Content-Type: application/json' \
-d '{"mappings":{"properties":{"s":{"type":"keyword"},"n":{"type":"integer"},"d":{"type":"double"},"b":{"type":"boolean"},"ts":{"type":"date"}}}}' | jq .acknowledged
curl -s -X POST 'localhost:9200/hdemo/_doc?refresh=true' -H 'Content-Type: application/json' \
-d '{"s":"abc","n":7,"d":1.5,"b":true,"ts":"2026-01-02T03:04:05Z"}' | jq .result- Cast to
int/long. This works:
curl -s -X POST localhost:9200/_plugins/_ppl -H 'Content-Type: application/json' \
-d '{"query":"source=hdemo | eval x = cast(b as int), y = cast(b as long) | fields x, y"}' | jq -c .datarows
# [[1,1]]- Cast to
double. This fails, andfloatfails the same way:
curl -s -X POST localhost:9200/_plugins/_ppl -H 'Content-Type: application/json' \
-d '{"query":"source=hdemo | eval x = cast(b as double) | fields x"}' | jq -c '{status, error: .error.details[0:160]}'
# {"status":500,"error":"Line 25, Column 97: No applicable constructor/method found for actual parameters \"boolean\"; candidates are: \"public java.lang.Object org.apache.calcite.linq4j.t"}What is the expected behavior?
[[1.0]], matching the integer casts. A 400 would also be acceptable if boolean → floating point is meant to be unsupported, but not a 500.
What is your host/environment?
- mainline (3.10.0-SNAPSHOT, c7e2cea), single node
Do you have any screenshots?
N/A
Do you have any additional context?
- The generated code seems to call
Primitive.numberValueRoundDown(Number)on aboolean. The int/long path presumably converts boolean → number first, and the double/float path doesn't. - Found by a property-based type checker (hegel).
Metadata
Metadata
Assignees
Labels
PPLPiped processing languagebugSomething isn't workingdynamic-testIssues found by or related to Dynamic Testing
Type
Projects
- StatusShow more project fieldsDone
Activity
shuseng8 commentedon Nov 26, 2026
Hi @Swiddis, I'd like to take this one. Calcite rewrites boolean→int/long casts into
CASE(b, 1, 0)but has no equivalent for double/float, so codegen ends up callingnumberValueRoundDownon a boolean. I have a fix that maps true/false/null to 1.0/0.0/null (matching the int casts and the v2 engine), with unit, IT and YAML tests, and can open a PR if that sounds good.[BugFix] Support cast of boolean to double and float in Calcite (#5987)…