Commit bad9cda
authored
fix: Cast smaller integer types to int32/int64 on write for Spark compatibility (#2799)
## Summary
- Fixes #2791: Writing smaller integer types (uint8, int8, int16,
uint16) to Iceberg IntegerType columns now correctly casts to
int32/int64
- PyIceberg was preserving original Arrow types in Parquet files,
causing Spark to fail with `Unsupported logical type: UINT_8`
- Added integer type widening logic in
`ArrowProjectionVisitor._cast_if_needed()` following the same pattern as
existing timestamp handling
- Only widening conversions are allowed (e.g., uint8 → int32, int32 →
int64); narrowing conversions continue to be rejected via `promote()`
## Test plan
- [x] All 3041 unit tests pass
- [x] Lint passes
- [x] New parameterized test covers: uint8, int8, int16, uint16 → int32
and uint32, int32 → int64
- [x] Existing `test_projection_filter_add_column_demote` still works
(narrowing rejection)
- [x] Manual verification: uint8 data written to IntegerType column
produces int32 in Parquet file
Closes #2791
Co-authored-by: Somasundaram Sekar <somasundaramsekar.1986@gmail.com>1 parent a26fca7 commit bad9cda
2 files changed
+41
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1910 | 1910 | | |
1911 | 1911 | | |
1912 | 1912 | | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
1913 | 1922 | | |
1914 | 1923 | | |
1915 | 1924 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2752 | 2752 | | |
2753 | 2753 | | |
2754 | 2754 | | |
| 2755 | + | |
| 2756 | + | |
| 2757 | + | |
| 2758 | + | |
| 2759 | + | |
| 2760 | + | |
| 2761 | + | |
| 2762 | + | |
| 2763 | + | |
| 2764 | + | |
| 2765 | + | |
| 2766 | + | |
| 2767 | + | |
| 2768 | + | |
| 2769 | + | |
| 2770 | + | |
| 2771 | + | |
| 2772 | + | |
| 2773 | + | |
| 2774 | + | |
| 2775 | + | |
| 2776 | + | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
| 2780 | + | |
| 2781 | + | |
| 2782 | + | |
| 2783 | + | |
| 2784 | + | |
| 2785 | + | |
| 2786 | + | |
2755 | 2787 | | |
2756 | 2788 | | |
2757 | 2789 | | |
| |||
0 commit comments