TO_BOOLEAN¶
TO_BOOLEAN(COLUMN_EXPRESSION)
Casts the input to a boolean value. If the input is a string, it will be cast to true
if it is
'true'
, 't'
, 'yes'
, 'y'
, '1'
, cast to false
if it is 'false'
, 'f'
, 'no'
, 'n'
, '0'
,
and throw an error otherwise.
If the input is an integer, it will be cast to true
if it is non-zero and false
if it is zero.
If the input is a float, it will be cast to true
if it is non-zero, false
if it is zero, and throw an error on other inputs (e.g. inf
) input. If the input is NULL
, the output will be NULL
.
Example:
We are given table1
with columns a
and b
and c
ValueError: invalid value for boolean conversion: string must be one of {'true', 't', 'yes', 'y', 'on', '1'} or {'false', 'f', 'no', 'n', 'off', '0'}
Note
BodoSQL will read NaN
s as NULL
and thus will not produce errors on NaN
input.