Bitwise OR
All functions > BITWISE > Bitwise OR
Returns the bitwise OR of two bitstrings or two integers.
Syntax
left | right · BITWISE_OR(left, right)
Function form
Returns: Result bitstring, or NULL if either operand is NULL
BITWISE_OR(left: BITSTRING, right: BITSTRING) → BITSTRING sql
| Parameter | Type | Required | Description |
|---|---|---|---|
left | BITSTRING | Yes | Left operand |
right | BITSTRING | Yes | Right operand |
Returns: Result integer, or NULL if either operand is NULL
BITWISE_OR(left: BIGINT, right: BIGINT) → BIGINT sql
| Parameter | Type | Required | Description |
|---|---|---|---|
left | BIGINT | Yes | Left operand (any integer type, read as 64 bits) |
right | BIGINT | Yes | Right operand (any integer type, read as 64 bits) |
Notes
- Bitstring operands must have the same length; bitstrings exist on DuckDB and Postgres only
- Integers are 64-bit two's complement and the result is a BIGINT, on every backend
- Each bit position is ORed independently: 0 OR 0 = 0, all other combinations = 1
- Returns NULL if either input is NULL
Examples
BITWISE_OR(...)
FeatureQL
RETURN
-- Complementary bits produce all 1s
f1 := BITWISE_OR('1010'::BITSTRING, '0101'::BITSTRING)::VARCHAR,
-- Non-overlapping bits
f2 := BITWISE_OR('1100'::BITSTRING, '0011'::BITSTRING)::VARCHAR,
-- OR with zero preserves bits
f3 := BITWISE_OR('1000'::BITSTRING, '0000'::BITSTRING)::VARCHAR
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR |
|---|---|---|
| 1111 | 1111 | 1000 |
Operator |
FeatureQL
RETURN
-- Integers: 1100 OR 1010
f1 := BITWISE_OR(12, 10)
;Result
| f1 BIGINT |
|---|
| 14 |
BITWISE_OR()
FeatureQL
RETURN
-- Complementary bits produce all 1s
f1 := BITWISE_OR('1010'::BITSTRING, '0101'::BITSTRING)::VARCHAR
;Result
| f1 VARCHAR |
|---|
| 1111 |