@@ -45,6 +45,41 @@ def test_write_documents(self, document_store: SupabasePgvectorDocumentStore):
4545 with pytest .raises (DuplicateDocumentError ):
4646 document_store .write_documents (docs , DuplicatePolicy .FAIL )
4747
48+ def test_get_metadata_field_unique_values_distinct_types (self , document_store : SupabasePgvectorDocumentStore ):
49+ """
50+ Override: the base mixin test stores int, float, str and bool under the *same* metadata field
51+ name and expects all four back as distinct values. This store's ``meta`` column is JSONB, and
52+ PostgreSQL's JSONB equality treats a whole-number float (e.g. 1.0) and a numerically equal int
53+ (1) as the same value, so ``SELECT DISTINCT meta->'field'`` collapses them regardless of which
54+ other values share that field.
55+
56+ This adapts the same intent - int, float, str and bool must come back as distinct, unmangled
57+ types via get_metadata_field_unique_values() - using one field per type instead of one shared
58+ field, which is what this store can actually support.
59+
60+ The float value is a non-whole number (1.5, not 1.0): a whole-number float would still collapse
61+ with an int under PostgreSQL's JSONB numeric equality even in its own field, so a fractional
62+ value is used to sidestep that ambiguity entirely.
63+ """
64+ docs = [
65+ Document (content = "Doc 1" , meta = {"priority_int" : 1 }),
66+ Document (content = "Doc 2" , meta = {"priority_str" : "1" }),
67+ Document (content = "Doc 3" , meta = {"priority_float" : 1.5 }),
68+ Document (content = "Doc 4" , meta = {"priority_bool" : True }),
69+ ]
70+ document_store .write_documents (docs )
71+
72+ int_values , int_count = document_store .get_metadata_field_unique_values (metadata_field = "priority_int" )
73+ str_values , str_count = document_store .get_metadata_field_unique_values (metadata_field = "priority_str" )
74+ float_values , float_count = document_store .get_metadata_field_unique_values (metadata_field = "priority_float" )
75+ bool_values , bool_count = document_store .get_metadata_field_unique_values (metadata_field = "priority_bool" )
76+
77+ assert (int_count , str_count , float_count , bool_count ) == (1 , 1 , 1 , 1 )
78+ assert int_values == [1 ] and type (int_values [0 ]) is int
79+ assert str_values == ["1" ] and type (str_values [0 ]) is str
80+ assert float_values == [1.5 ] and type (float_values [0 ]) is float
81+ assert bool_values == [True ] and type (bool_values [0 ]) is bool
82+
4883 def test_write_blob (self , document_store : SupabasePgvectorDocumentStore ):
4984 bytestream = ByteStream (b"test" , meta = {"meta_key" : "meta_value" }, mime_type = "mime_type" )
5085 docs = [Document (id = "1" , blob = bytestream )]
0 commit comments