| 2277 | |
| 2278 | @pytest.mark.parametrize('value_type', numerical_arrow_types) |
| 2279 | def test_fsl_to_fsl_cast(value_type): |
| 2280 | # Different field name and different type. |
| 2281 | cast_type = pa.list_(pa.field("element", value_type), 2) |
| 2282 | |
| 2283 | dtype = pa.int32() |
| 2284 | type = pa.list_(pa.field("values", dtype), 2) |
| 2285 | |
| 2286 | fsl = pa.FixedSizeListArray.from_arrays( |
| 2287 | pa.array([1, 2, 3, 4, 5, 6], type=dtype), type=type) |
| 2288 | assert cast_type == fsl.cast(cast_type).type |
| 2289 | |
| 2290 | # Different field name and different type (with null values). |
| 2291 | fsl = pa.FixedSizeListArray.from_arrays( |
| 2292 | pa.array([1, None, None, 4, 5, 6], type=dtype), type=type) |
| 2293 | assert cast_type == fsl.cast(cast_type).type |
| 2294 | |
| 2295 | # Null FSL type. |
| 2296 | dtype = pa.null() |
| 2297 | type = pa.list_(pa.field("values", dtype), 2) |
| 2298 | fsl = pa.FixedSizeListArray.from_arrays( |
| 2299 | pa.array([None, None, None, None, None, None], type=dtype), type=type) |
| 2300 | assert cast_type == fsl.cast(cast_type).type |
| 2301 | |
| 2302 | # Different sized FSL |
| 2303 | cast_type = pa.list_(pa.field("element", value_type), 3) |
| 2304 | err_msg = 'Size of FixedSizeList is not the same.' |
| 2305 | with pytest.raises(pa.lib.ArrowTypeError, match=err_msg): |
| 2306 | fsl.cast(cast_type) |
| 2307 | |
| 2308 | |
| 2309 | DecimalTypeTraits = namedtuple('DecimalTypeTraits', |