7171
7272
7373def test_pyarrow_binary_to_iceberg () -> None :
74- length = 23
75- pyarrow_type = pa .binary (length )
76- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
74+ length : int = 23
75+ pyarrow_type : pa . DataType = pa .binary (length )
76+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
7777 assert converted_iceberg_type == FixedType (length )
7878 assert visit (converted_iceberg_type , _ConvertToArrowSchema ()) == pyarrow_type
7979
8080
8181def test_pyarrow_decimal128_to_iceberg () -> None :
82- precision = 26
83- scale = 20
84- pyarrow_type = pa .decimal128 (precision , scale )
85- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
82+ precision : int = 26
83+ scale : int = 20
84+ pyarrow_type : pa . DataType = pa .decimal128 (precision , scale )
85+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
8686 assert converted_iceberg_type == DecimalType (precision , scale )
8787 assert visit (converted_iceberg_type , _ConvertToArrowSchema ()) == pyarrow_type
8888
8989
9090def test_pyarrow_decimal256_to_iceberg () -> None :
91- precision = 26
92- scale = 20
93- pyarrow_type = pa .decimal256 (precision , scale )
91+ precision : int = 26
92+ scale : int = 20
93+ pyarrow_type : pa . DataType = pa .decimal256 (precision , scale )
9494 with pytest .raises (TypeError , match = re .escape ("Unsupported type: decimal256(26, 20)" )):
9595 visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
9696
9797
9898def test_pyarrow_boolean_to_iceberg () -> None :
99- pyarrow_type = pa .bool_ ()
100- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
99+ pyarrow_type : pa . DataType = pa .bool_ ()
100+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
101101 assert converted_iceberg_type == BooleanType ()
102102 assert visit (converted_iceberg_type , _ConvertToArrowSchema ()) == pyarrow_type
103103
104104
105105def test_pyarrow_int8_to_iceberg () -> None :
106- pyarrow_type = pa .int8 ()
107- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
106+ pyarrow_type : pa . DataType = pa .int8 ()
107+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
108108 assert converted_iceberg_type == IntegerType ()
109109
110110
111111def test_pyarrow_int16_to_iceberg () -> None :
112- pyarrow_type = pa .int16 ()
113- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
112+ pyarrow_type : pa . DataType = pa .int16 ()
113+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
114114 assert converted_iceberg_type == IntegerType ()
115115
116116
117117def test_pyarrow_int32_to_iceberg () -> None :
118- pyarrow_type = pa .int32 ()
119- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
118+ pyarrow_type : pa . DataType = pa .int32 ()
119+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
120120 assert converted_iceberg_type == IntegerType ()
121121 assert visit (converted_iceberg_type , _ConvertToArrowSchema ()) == pyarrow_type
122122
123123
124124def test_pyarrow_int64_to_iceberg () -> None :
125- pyarrow_type = pa .int64 ()
126- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
125+ pyarrow_type : pa . DataType = pa .int64 ()
126+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
127127 assert converted_iceberg_type == LongType ()
128128 assert visit (converted_iceberg_type , _ConvertToArrowSchema ()) == pyarrow_type
129129
130130
131131def test_pyarrow_float32_to_iceberg () -> None :
132- pyarrow_type = pa .float32 ()
133- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
132+ pyarrow_type : pa . DataType = pa .float32 ()
133+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
134134 assert converted_iceberg_type == FloatType ()
135135 assert visit (converted_iceberg_type , _ConvertToArrowSchema ()) == pyarrow_type
136136
137137
138138def test_pyarrow_float64_to_iceberg () -> None :
139- pyarrow_type = pa .float64 ()
140- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
139+ pyarrow_type : pa . DataType = pa .float64 ()
140+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
141141 assert converted_iceberg_type == DoubleType ()
142142 assert visit (converted_iceberg_type , _ConvertToArrowSchema ()) == pyarrow_type
143143
144144
145145def test_pyarrow_date32_to_iceberg () -> None :
146- pyarrow_type = pa .date32 ()
147- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
146+ pyarrow_type : pa . DataType = pa .date32 ()
147+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
148148 assert converted_iceberg_type == DateType ()
149149 assert visit (converted_iceberg_type , _ConvertToArrowSchema ()) == pyarrow_type
150150
@@ -165,8 +165,8 @@ def test_pyarrow_time32_to_iceberg() -> None:
165165
166166
167167def test_pyarrow_time64_us_to_iceberg () -> None :
168- pyarrow_type = pa .time64 ("us" )
169- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
168+ pyarrow_type : pa . DataType = pa .time64 ("us" )
169+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
170170 assert converted_iceberg_type == TimeType ()
171171 assert visit (converted_iceberg_type , _ConvertToArrowSchema ()) == pyarrow_type
172172
@@ -179,8 +179,8 @@ def test_pyarrow_time64_ns_to_iceberg() -> None:
179179
180180@pytest .mark .parametrize ("precision" , ["s" , "ms" , "us" , "ns" ])
181181def test_pyarrow_timestamp_to_iceberg (precision : str ) -> None :
182- pyarrow_type = pa .timestamp (unit = precision )
183- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg (downcast_ns_timestamp_to_us = True ))
182+ pyarrow_type : pa . DataType = pa .timestamp (unit = precision )
183+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg (downcast_ns_timestamp_to_us = True ))
184184 assert converted_iceberg_type == TimestampType ()
185185 # all timestamp types are converted to 'us' precision
186186 assert visit (converted_iceberg_type , _ConvertToArrowSchema ()) == pa .timestamp (unit = "us" )
@@ -199,10 +199,10 @@ def test_pyarrow_timestamp_invalid_units() -> None:
199199
200200
201201def test_pyarrow_timestamp_tz_to_iceberg () -> None :
202- pyarrow_type = pa .timestamp (unit = "us" , tz = "UTC" )
203- pyarrow_type_zero_offset = pa .timestamp (unit = "us" , tz = "+00:00" )
204- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
205- converted_iceberg_type_zero_offset = visit_pyarrow (pyarrow_type_zero_offset , _ConvertToIceberg ())
202+ pyarrow_type : pa . DataType = pa .timestamp (unit = "us" , tz = "UTC" )
203+ pyarrow_type_zero_offset : pa . DataType = pa .timestamp (unit = "us" , tz = "+00:00" )
204+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
205+ converted_iceberg_type_zero_offset : IcebergType = visit_pyarrow (pyarrow_type_zero_offset , _ConvertToIceberg ())
206206 assert converted_iceberg_type == TimestamptzType ()
207207 assert converted_iceberg_type_zero_offset == TimestamptzType ()
208208 assert visit (converted_iceberg_type , _ConvertToArrowSchema ()) == pyarrow_type
@@ -234,21 +234,21 @@ def test_pyarrow_timestamp_ns_tz_invalid_tz() -> None:
234234
235235
236236def test_pyarrow_timestamp_ns_no_tz_accepted () -> None :
237- pyarrow_type = pa .timestamp (unit = "ns" )
238- converted = visit_pyarrow (pyarrow_type , _ConvertToIceberg (format_version = 3 ))
237+ pyarrow_type : pa . DataType = pa .timestamp (unit = "ns" )
238+ converted : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg (format_version = 3 ))
239239 assert converted == TimestampNanoType ()
240240
241241
242242@pytest .mark .parametrize ("pyarrow_type" , [pa .string (), pa .large_string (), pa .string_view ()])
243243def test_pyarrow_string_to_iceberg (pyarrow_type : pa .DataType ) -> None :
244- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
244+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
245245 assert converted_iceberg_type == StringType ()
246246 assert visit (converted_iceberg_type , _ConvertToArrowSchema ()) == pa .large_string ()
247247
248248
249249@pytest .mark .parametrize ("pyarrow_type" , [pa .binary (), pa .large_binary (), pa .binary_view ()])
250250def test_pyarrow_variable_binary_to_iceberg (pyarrow_type : pa .DataType ) -> None :
251- converted_iceberg_type = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
251+ converted_iceberg_type : IcebergType = visit_pyarrow (pyarrow_type , _ConvertToIceberg ())
252252 assert converted_iceberg_type == BinaryType ()
253253 assert visit (converted_iceberg_type , _ConvertToArrowSchema ()) == pa .large_binary ()
254254
0 commit comments