Skip to content

Return f64 from pgvector scalar operations #59

Description

@alexeichhorn

Problem

pgvector distance and inner-product operations return PostgreSQL DOUBLE PRECISION, but dbkit models them as f32 / Option<f32>.

Affected helpers:

  • l2_distance
  • cosine_distance
  • inner_product
  • l1_distance
  • inner_product_distance

Filtering and ordering can appear to work because PostgreSQL coerces thresholds. Selecting a result into the advertised Rust f32 can fail SQLx decoding because the database returns DOUBLE PRECISION.

Expected behavior

  • Return Expr<f64> when both operands are required.
  • Return Expr<Option<f64>> when either operand is nullable.
  • Preserve vector dimension checking and current NULL propagation.
  • Update explicit f32 thresholds, API assertions, and documentation to f64 where they consume these scalar results.
  • Add required and nullable integration projections that decode the returned scalar.

pgvector vector function result types

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions