Skip to content

[BUG] Non-boolean operands to not / and / or / where return 500 #5986

Backlog

Description

@Swiddis

What is the bug?
Analysis accepts a non-boolean operand to a logical operator or a where condition, and the query then fails in codegen or on the shard with a 500, instead of a 400 naming the type.

How can one reproduce the bug?

  1. 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
  1. Run any of these:
for q in 'eval x = not n | fields x' 'eval x = b and n | fields x' 'where b or n' 'where n' 'where s'; do
  curl -s -X POST localhost:9200/_plugins/_ppl -H 'Content-Type: application/json' \
    -d "{\"query\":\"source=hdemo | $q\"}" | jq -c --arg q "$q" '{q: $q, status, type: .error.type, error: .error.details[0:90]}'
done
# {"q":"eval x = not n | fields x","status":500,"type":"SQLException","error":"Line 22, Column 72: No applicable constructor/method found for actual parameters \"java.lan"}
# {"q":"eval x = b and n | fields x","status":500,"type":"SQLException","error":"Line 27, Column 76: Not a boolean expression"}
# {"q":"where b or n","status":500,"type":"RuntimeException","error":"Line 7, Column 86: Not a boolean expression"}
# {"q":"where n","status":500,"type":"RuntimeException","error":"java.sql.SQLException: exception while executing query: Failed to fetch data from the inde"}
# {"q":"where s","status":500,"type":"RuntimeException","error":"java.sql.SQLException: exception while executing query: Failed to fetch data from the inde"}

The two where cases fail on the shard: all shards failed ... ClassCastException[class java.lang.Long cannot be cast to class java.lang.Boolean] (for n) and [class java.lang.String cannot be cast to class java.lang.Boolean] (for s).
3. With a literal on the other side, constant folding hides the error, and the query returns 200 with the wrong type:

curl -s -X POST localhost:9200/_plugins/_ppl -H 'Content-Type: application/json' \
  -d '{"query":"source=hdemo | eval x = true and n | fields x"}' | jq -c '{schema, datarows}'
# {"schema":[{"name":"x","type":"int"}],"datarows":[[7]]}

What is the expected behavior?
HTTP 400 naming the operand type, as other functions already return (e.g. upper(n) → UPPER function expects {[STRING]}, but got [INTEGER]).

What is your host/environment?

  • mainline (3.10.0-SNAPSHOT, c7e2cea), single node. With plugins.calcite.pushdown.enabled=false, where s still 500s, as a codegen Not a boolean expression.

Do you have any screenshots?
N/A

Do you have any additional context?

Activity

  1. added
    bug
    PPL
    on Nov 25, 2026
  2. added
    dynamic-test
    and removed on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    PPLbugdynamic-test

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions