@@ -23,47 +23,67 @@ def test_vector_sql_generation():
2323
2424def test_vector_type_parsing ():
2525 field = _type_str_to_arrow_field ("VECTOR(1024)" )
26- assert pa .types .is_fixed_size_list (field .type )
27- assert field .type .list_size == 1024
26+ # Should be List type with metadata, not FixedSizeList
27+ assert pa .types .is_list (field .type )
28+ assert field .metadata [b"Extension" ] == b"Vector"
29+ assert field .metadata [b"vector_size" ] == b"1024"
2830 assert pa .types .is_float32 (field .type .value_type )
31+ # Default is nullable
2932 assert field .nullable is True
3033
34+ # Test NOT NULL
35+ field_not_null = _type_str_to_arrow_field ("VECTOR(1024) NOT NULL" )
36+ assert field_not_null .nullable is False
37+
3138
3239def test_vector_type_formatting ():
40+ # Test that a List with VECTOR metadata is formatted as VECTOR(N)
3341 field = pa .field (
3442 "" ,
35- pa .list_ (pa .field ("item" , pa .float32 (), nullable = False ), 1024 ),
36- nullable = True ,
43+ pa .list_ (pa .field ("item" , pa .float32 (), nullable = False )),
44+ nullable = False ,
45+ metadata = {
46+ b"Extension" : b"Vector" ,
47+ b"vector_size" : b"1024" ,
48+ },
3749 )
3850 type_str = _field_type_to_string (field )
3951 assert type_str == "VECTOR(1024)"
4052
4153
4254def test_vector_input_processing ():
55+ # Input processing should handle List (which is what VECTOR is physically)
4356 field = pa .field (
44- "" , pa .list_ (pa .field ("item" , pa .float32 (), nullable = False ), 3 ), nullable = True
57+ "" ,
58+ pa .list_ (pa .field ("item" , pa .float32 (), nullable = False )),
59+ nullable = False ,
60+ metadata = {
61+ b"Extension" : b"Vector" ,
62+ b"vector_size" : b"3" ,
63+ },
4564 )
4665 func = _input_process_func (field )
4766
4867 # Input is a list of floats
49- input_data = [1.0 , 2.0 , 3.0 ]
50- result = func (input_data )
51- assert result == [1.0 , 2.0 , 3.0 ]
52-
53- # Input is None
54- assert func (None ) is None
68+ data = [[1.1 , 2.2 , 3.3 ], [4.4 , 5.5 , 6.6 ]]
69+ processed = func (data )
70+ assert processed == data
5571
5672
5773def test_vector_output_processing ():
74+ # Output processing should handle List
5875 field = pa .field (
59- "" , pa .list_ (pa .field ("item" , pa .float32 (), nullable = False ), 3 ), nullable = True
76+ "" ,
77+ pa .list_ (pa .field ("item" , pa .float32 (), nullable = False )),
78+ nullable = False ,
79+ metadata = {
80+ b"Extension" : b"Vector" ,
81+ b"vector_size" : b"3" ,
82+ },
6083 )
6184 func = _output_process_func (field )
6285
6386 # Output is a list of floats
64- output_data = [1.0 , 2.0 , 3.0 ]
65- result = func (output_data )
66- assert result == [1.0 , 2.0 , 3.0 ]
67-
68- # Output is None
69- assert func (None ) is None
87+ data = [[1.1 , 2.2 , 3.3 ], [4.4 , 5.5 , 6.6 ]]
88+ processed = func (data )
89+ assert processed == data
0 commit comments