BOOLEAN
The BOOLEAN type represents logical truth values, with possible values of TRUE, FALSE, or NULL. Lakehouse uses three-valued logic: NULL means "unknown" and is not equivalent to FALSE.
Syntax
Literals: TRUE / FALSE (case-insensitive)
Examples
Literals and Basic Operations
| true | false | (NOT true) | (NOT false) |
|---|---|---|---|
| true | false | false | true |
Three-Valued Logic (NULL in Operations)
| t_and_null | f_and_null | t_or_null | f_or_null |
|---|---|---|---|
| null | false | true | null |
FALSE AND NULL→FALSE: regardless of what NULL represents, the result is always FALSETRUE OR NULL→TRUE: regardless of what NULL represents, the result is always TRUE- In other cases the result depends on the unknown value and returns NULL
Type Conversion
Numeric → BOOLEAN
| CAST(1 AS boolean) | CAST(0 AS boolean) | CAST(2 AS boolean) |
|---|---|---|
| true | false | true |
0 converts to FALSE; all other non-zero integers convert to TRUE.
String → BOOLEAN
| true | false | yes→true | no→false | t→true | f→false | 1→true |
|---|---|---|---|---|---|---|
| true | false | true | false | true | false | true |
Supported strings (case-insensitive): true/false, yes/no, t/f, 1/0. All other strings convert to NULL.
BOOLEAN → Other Types
| CAST(true AS int) | CAST(false AS int) | CAST(true AS string) | CAST(false AS string) |
|---|---|---|---|
| 1 | 0 | true | false |
Using BOOLEAN in a WHERE Clause
The WHERE clause returns only rows where the condition evaluates to TRUE; both FALSE and NULL are filtered out.
Notes
- BOOLEAN does not support comparison operators (
>,<); only=,!=,IS NULL, andIS NOT NULLare supported. - In a WHERE clause,
NULLrows are filtered out. UseIS NULLto handle them explicitly. - Converting BOOLEAN to DATE, TIMESTAMP, or other time types is not supported.
