@@ -25,12 +25,12 @@ def module_setup_and_checks(test_client: Client, test_config: TestConfig):
2525 if not test_client .min_version ("25.10" ):
2626 pytest .skip ("QBit type requires ClickHouse 25.10+" , allow_module_level = True )
2727
28+ test_client .command ("SET allow_experimental_qbit_type = 1" )
29+
2830
2931def test_qbit_roundtrip_float64 (test_client : Client , table_context : Callable ):
3032 """Test QBit(Float64) round-trip accuracy with fruit_animal example data"""
3133
32- test_client .command ("SET allow_experimental_qbit_type = 1" )
33-
3434 with table_context ("fruit_animal" , ["word String" , "vec QBit(Float64, 5)" ]):
3535 test_data = [
3636 ("apple" , [- 0.99105519 , 1.28887844 , - 0.43526649 , - 0.98520696 , 0.66154391 ]),
@@ -55,8 +55,6 @@ def test_qbit_roundtrip_float64(test_client: Client, table_context: Callable):
5555def test_qbit_roundtrip_float32 (test_client : Client , table_context : Callable ):
5656 """Test QBit(Float32) round-trip accuracy"""
5757
58- test_client .command ("SET allow_experimental_qbit_type = 1" )
59-
6058 with table_context ("vectors_f32" , ["id Int32" , "vec QBit(Float32, 8)" ]):
6159 test_data = [
6260 (1 , [1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ]),
@@ -78,8 +76,6 @@ def test_qbit_roundtrip_float32(test_client: Client, table_context: Callable):
7876def test_qbit_roundtrip_bfloat16 (test_client : Client , table_context : Callable ):
7977 """Test QBit(BFloat16) round-trip with appropriate tolerance"""
8078
81- test_client .command ("SET allow_experimental_qbit_type = 1" )
82-
8379 with table_context ("vectors_bf16" , ["id Int32" , "vec QBit(BFloat16, 8)" ]):
8480 test_data = [
8581 (1 , [1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ]),
@@ -100,8 +96,6 @@ def test_qbit_roundtrip_bfloat16(test_client: Client, table_context: Callable):
10096def test_qbit_distance_search (test_client : Client , table_context : Callable ):
10197 """Test L2DistanceTransposed with different precision levels"""
10298
103- test_client .command ("SET allow_experimental_qbit_type = 1" )
104-
10599 with table_context ("fruit_animal" , ["word String" , "vec QBit(Float64, 5)" ]):
106100 test_data = [
107101 ("apple" , [- 0.99105519 , 1.28887844 , - 0.43526649 , - 0.98520696 , 0.66154391 ]),
@@ -148,7 +142,6 @@ def test_qbit_distance_search(test_client: Client, table_context: Callable):
148142def test_qbit_batch_insert (test_client : Client , table_context : Callable ):
149143 """Test batch insert with multiple vectors"""
150144
151- test_client .command ("SET allow_experimental_qbit_type = 1" )
152145 dimension = 16
153146
154147 with table_context ("embeddings" , ["id Int32" , f"embedding QBit(Float32, { dimension } )" ]):
@@ -177,8 +170,6 @@ def test_qbit_batch_insert(test_client: Client, table_context: Callable):
177170def test_qbit_null_handling (test_client : Client , table_context : Callable ):
178171 """Test QBit with NULL values using Nullable wrapper"""
179172
180- test_client .command ("SET allow_experimental_qbit_type = 1" )
181-
182173 with table_context ("nullable_vecs" , ["id Int32" , "vec Nullable(QBit(Float32, 4))" ]):
183174 test_data = [
184175 (1 , [1.0 , 2.0 , 3.0 , 4.0 ]),
@@ -197,8 +188,6 @@ def test_qbit_null_handling(test_client: Client, table_context: Callable):
197188def test_qbit_dimension_mismatch_error (test_client : Client , table_context : Callable ):
198189 """Test that inserting vectors with wrong dimensions raises an error"""
199190
200- test_client .command ("SET allow_experimental_qbit_type = 1" )
201-
202191 with table_context ("dim_test" , ["id Int32" , "vec QBit(Float32, 8)" ]):
203192 wrong_data = [(1 , [1.0 , 2.0 , 3.0 , 4.0 , 5.0 ])]
204193
@@ -211,8 +200,6 @@ def test_qbit_dimension_mismatch_error(test_client: Client, table_context: Calla
211200def test_qbit_empty_insert (test_client : Client , table_context : Callable ):
212201 """Test inserting an empty list (no rows)"""
213202
214- test_client .command ("SET allow_experimental_qbit_type = 1" )
215-
216203 with table_context ("empty_test" , ["id Int32" , "vec QBit(Float32, 4)" ]):
217204 test_client .insert ("empty_test" , [])
218205 result = test_client .query ("SELECT COUNT(*) FROM empty_test" )
@@ -222,8 +209,6 @@ def test_qbit_empty_insert(test_client: Client, table_context: Callable):
222209def test_qbit_single_row (test_client : Client , table_context : Callable ):
223210 """Test inserting a single row"""
224211
225- test_client .command ("SET allow_experimental_qbit_type = 1" )
226-
227212 with table_context ("single_row" , ["id Int32" , "vec QBit(Float32, 4)" ]):
228213 single_data = [(1 , [1.0 , 2.0 , 3.0 , 4.0 ])]
229214 test_client .insert ("single_row" , single_data )
@@ -237,8 +222,6 @@ def test_qbit_single_row(test_client: Client, table_context: Callable):
237222def test_qbit_special_float_values (test_client : Client , table_context : Callable ):
238223 """Test QBit with special float values (inf, -inf, nan)"""
239224
240- test_client .command ("SET allow_experimental_qbit_type = 1" )
241-
242225 with table_context ("special_floats" , ["id Int32" , "vec QBit(Float64, 4)" ]):
243226 test_data = [
244227 (1 , [float ("inf" ), 1.0 , 2.0 , 3.0 ]),
@@ -266,8 +249,6 @@ def test_qbit_special_float_values(test_client: Client, table_context: Callable)
266249def test_qbit_edge_case_dimensions (test_client : Client , table_context : Callable ):
267250 """Test QBit with edge case dimensions (1, not multiple of 8)"""
268251
269- test_client .command ("SET allow_experimental_qbit_type = 1" )
270-
271252 with table_context ("dim_one" , ["id Int32" , "vec QBit(Float32, 1)" ]):
272253 test_data = [(1 , [1.0 ]), (2 , [3.14 ])]
273254 test_client .insert ("dim_one" , test_data )
@@ -287,8 +268,6 @@ def test_qbit_edge_case_dimensions(test_client: Client, table_context: Callable)
287268def test_qbit_very_large_batch (test_client : Client , table_context : Callable ):
288269 """Test inserting a very large batch of vectors (1000 rows)"""
289270
290- test_client .command ("SET allow_experimental_qbit_type = 1" )
291-
292271 with table_context ("large_batch" , ["id Int32" , "vec QBit(Float32, 8)" ]):
293272 random .seed (1 )
294273 large_batch = [(i , [random .uniform (- 10 , 10 ) for _ in range (8 )]) for i in range (1000 )]
@@ -308,8 +287,6 @@ def test_qbit_very_large_batch(test_client: Client, table_context: Callable):
308287def test_qbit_all_nulls (test_client : Client , table_context : Callable ):
309288 """Test QBit nullable column with all NULL values"""
310289
311- test_client .command ("SET allow_experimental_qbit_type = 1" )
312-
313290 with table_context ("all_nulls" , ["id Int32" , "vec Nullable(QBit(Float32, 4))" ]):
314291 test_data = [(1 , None ), (2 , None ), (3 , None )]
315292 test_client .insert ("all_nulls" , test_data )
@@ -321,8 +298,6 @@ def test_qbit_all_nulls(test_client: Client, table_context: Callable):
321298def test_qbit_all_zeros (test_client : Client , table_context : Callable ):
322299 """Test QBit with all zero vectors"""
323300
324- test_client .command ("SET allow_experimental_qbit_type = 1" )
325-
326301 with table_context ("all_zeros" , ["id Int32" , "vec QBit(Float32, 4)" ]):
327302 test_data = [(1 , [0.0 , 0.0 , 0.0 , 0.0 ]), (2 , [0.0 , 0.0 , 0.0 , 0.0 ])]
328303 test_client .insert ("all_zeros" , test_data )
@@ -335,8 +310,6 @@ def test_qbit_all_zeros(test_client: Client, table_context: Callable):
335310def test_invalid_dimension (test_client : Client , table_context : Callable ):
336311 """Try creating a column with a negative dimension."""
337312
338- test_client .command ("SET allow_experimental_qbit_type = 1" )
339-
340313 with pytest .raises (DatabaseError ):
341314 with table_context ("bad_dim" , ["id Int32" , "vec QBit(Float32, -8)" ]):
342315 pass
@@ -345,8 +318,6 @@ def test_invalid_dimension(test_client: Client, table_context: Callable):
345318def test_invalid_element_type (test_client : Client , table_context : Callable ):
346319 """Try creating a column with an invalid element type."""
347320
348- test_client .command ("SET allow_experimental_qbit_type = 1" )
349-
350321 with pytest .raises (DatabaseError ):
351322 with table_context ("bad_el_type" , ["id Int32" , "vec QBit(Int32, 8)" ]):
352323 pass
0 commit comments