BITWISE_XOR()

All functions > BITWISE > BITWISE_XOR()

Returns the bitwise XOR (exclusive OR) of two bitstrings.

Signatures

Returns: Result bitstring, or NULL if either operand is NULL

BITWISE_XOR(left: BITSTRING, right: BITSTRING) → BITSTRING
sql
ParameterTypeRequiredDescription
leftBITSTRINGYesLeft operand
rightBITSTRINGYesRight operand

Notes

  • Both operands must have the same length
  • Each bit position is XORed independently: different bits = 1, same bits = 0
  • XOR is its own inverse: BITWISE_XOR(BITWISE_XOR(a, b), b) = a for the same-length bitstrings a, b
  • Returns NULL if either input is NULL
  • The ^ token is numeric exponentiation in FeatureQL, not bitstring XOR—use BITWISE_XOR

Availability

Available on DuckDB. Not available on Trino, Serving.

Related operators

Examples

FeatureQL
SELECT
    -- Different bits become 1
    f1 := BITWISE_XOR('1010'::BITSTRING, '0110'::BITSTRING)::VARCHAR
;
Result
f1 VARCHAR
1100