BINARY_QUANTIZE

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Encodes each array element into a single bit, compressing the vector by approximately 32x.

Syntax 

1BINARY_QUANTIZE(<array>)

Arguments 

Required 

  • <array>: The vector to quantize (array(real) or array(double-precision)).

Returns 

Returns a bytea value where each bit represents whether the corresponding array element is greater than 0 (1) or not (0).

Considerations 

  • Elements greater than 0 are encoded as 1, all others (including 0 and negative values) as 0.
  • The compression ratio is approximately 32x.

Examples 

Quantize a Vector 

Convert a numeric vector to binary representation.

1SELECT BINARY_QUANTIZE(ARRAY[-5, -3, 2, 6]) AS result;

Returns '0011', where negative values become 0 and positive values become 1.

Related Documentation 

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!