Skip to main content

Module declared_vector_coerce

Module declared_vector_coerce 

Source
Expand description

Coerce an array literal bound for a declared VECTOR(dim) column into an array of floats.

A fractional literal resolves to SqlValue::Decimal, and the Origin planner serializes a non-integer decimal as a msgpack string. Left as is, ARRAY[0.1, 0.2] reaches every engine as an array of strings. The strict and columnar encoders refuse each string element, and the schemaless engine stores the strings. Converting each element here gives every engine and every write path the same array of floats.

An integer, float, or decimal element becomes an f64. Any other element is refused with SqlError::VectorElementNotNumeric. A string element is refused even when its text spells a number, because the client wrote text. A number outside the f32 range a vector element holds is refused with SqlError::FloatOutOfRange.

A value that is not an array passes through. The engines read a vector text literal or raw vector bytes by their own rule. The element count is checked by the engines, which own that error.