25
25
- The type implementation might want to be accompanied by corresponding support
26
26
for the `KNN_MATCH` function, similar to what the dialect already offers for
27
27
fulltext search through its `Match` predicate.
28
+ - After dropping support for SQLAlchemy 1.3, use
29
+ `class FloatVector(sa.TypeDecorator[t.Sequence[float]]):`
28
30
29
31
## Origin
30
32
This module is based on the corresponding pgvector implementation
49
51
]
50
52
51
53
52
- def from_db (value : t .Iterable ) -> t .Optional [npt .ArrayLike ]:
54
+ def from_db (value : t .Iterable ) -> t .Optional [" npt.ArrayLike" ]:
53
55
import numpy as np
54
56
55
57
# from `pgvector.utils`
@@ -82,8 +84,7 @@ def to_db(value: t.Any, dim: t.Optional[int] = None) -> t.Optional[t.List]:
82
84
return value
83
85
84
86
85
- class FloatVector (sa .TypeDecorator [t .Sequence [float ]]):
86
-
87
+ class FloatVector (sa .TypeDecorator ):
87
88
"""
88
89
SQLAlchemy `FloatVector` data type for CrateDB.
89
90
"""
@@ -108,14 +109,14 @@ def as_generic(self, allow_nulltype=False):
108
109
def python_type (self ):
109
110
return list
110
111
111
- def bind_processor (self , dialect : sa .Dialect ) -> t .Callable :
112
+ def bind_processor (self , dialect : sa .engine . Dialect ) -> t .Callable :
112
113
def process (value : t .Iterable ) -> t .Optional [t .List ]:
113
114
return to_db (value , self .dimensions )
114
115
115
116
return process
116
117
117
- def result_processor (self , dialect : sa .Dialect , coltype : t .Any ) -> t .Callable :
118
- def process (value : t .Any ) -> t .Optional [npt .ArrayLike ]:
118
+ def result_processor (self , dialect : sa .engine . Dialect , coltype : t .Any ) -> t .Callable :
119
+ def process (value : t .Any ) -> t .Optional [" npt.ArrayLike" ]:
119
120
return from_db (value )
120
121
121
122
return process
0 commit comments