feat(spectypes): add support for PostGIS and pgvector types

* Implement custom types: SqlGeometry, SqlGeography, SqlHalfVector, SqlSparseVector, SqlBitVector
* Add spatial filter operators and vector similarity operators
* Include metadata and OpenAPI reporting for geometry/vector column types
* Create tests for EWKB and WKT conversions
This commit is contained in:
2026-08-29 21:27:42 +02:00
parent 798bb47e71
commit f259df1258
22 changed files with 2886 additions and 9 deletions
+15
View File
@@ -42,6 +42,10 @@ type RequestOptions struct {
CursorBackward string `json:"cursor_backward"`
FetchRowNumber *string `json:"fetch_row_number"`
// VectorSearch performs a pgvector nearest-neighbour ordering (KNN) and
// optionally returns the computed distance as an extra column.
VectorSearch *VectorSearchOption `json:"vector_search"`
// Join table aliases (used for validation of prefixed columns in filters/sorts)
// Not serialized to JSON as it's internal validation state
JoinAliases []string `json:"-"`
@@ -114,6 +118,17 @@ func ResolveSortColumns(sort []SortOption, pkName string) []SortOption {
return resolved
}
// VectorSearchOption describes a pgvector KNN search: order rows by the distance
// between Column and Vector using Metric, and (when As is set) select that
// distance as an additional result column.
type VectorSearchOption struct {
Column string `json:"column"`
Vector []float32 `json:"vector"`
Metric string `json:"metric"` // "l2" (default) | "cosine" | "ip"
As string `json:"as"` // distance column alias; default "_distance"
Direction string `json:"direction"` // "asc" (default) | "desc"
}
type CustomOperator struct {
Name string `json:"name"`
SQL string `json:"sql"`