Skip to main content

parse_string_as_bool

Function parse_string_as_bool 

Source
pub fn parse_string_as_bool(s: &str) -> Option<bool>
Expand description

Parse a string as a boolean using the same acceptance set as Arrow’s cast_string_to_boolean kernel (arrow-cast/src/cast/string.rs). Case insensitive with leading/trailing whitespace trimmed; accepts true/false/yes/no/on/off/1/0 and their prefixes.

Trino’s native TRY_CAST(JSON AS BOOLEAN) is narrower (only true/false/1/0/t/f), so values like "yes"/"on" produce true on eval/DataFusion but null on Trino — that’s a backend-level divergence outside this function’s contract.

#[inline] so the per-row eval cast path can inline across the crate boundary without LTO.