Repository: ToucanToco/fastexcel (language: python)

Issue:
use_columns is ignored when sheets are loaded eagerly
```
In [7]: reader.load_sheet_eager(0, use_columns=['Year'])
Out[7]: 
pyarrow.RecordBatch
Month: double not null
Year: double not null
----
Month: [1,2]
Year: [2019,2020]
```


Discussion / hints:

Fix patch:
diff --git a/src/types/python/excelreader.rs b/src/types/python/excelreader.rs
index 1837fd9..8e524a7 100644
--- a/src/types/python/excelreader.rs
+++ b/src/types/python/excelreader.rs
@@ -136,7 +136,9 @@ impl ExcelReader {
             dtype_coercion,
         )?;
 
-        let fields = available_columns
+        let final_columns = selected_columns.select_columns(&available_columns)?;
+
+        let fields = final_columns
             .iter()
             .map(Into::<Field>::into)
             .collect::<Vec<_>>();


Test patch:
diff --git a/python/tests/test_column_selection.py b/python/tests/test_column_selection.py
index 588d575..69c0108 100644
--- a/python/tests/test_column_selection.py
+++ b/python/tests/test_column_selection.py
@@ -477,3 +477,17 @@ def test_use_columns_with_bad_callable() -> None:
             2,
             use_columns=lambda _: 42,  # type: ignore
         )
+
+
+def test_use_columns_with_eager_loading() -> None:
+    excel_reader = fastexcel.read_excel(path_for_fixture("fixture-single-sheet.xlsx"))
+
+    # default
+    rb = excel_reader.load_sheet_eager(0)
+    assert rb.schema.names == ["Month", "Year"]
+    # changing order
+    rb = excel_reader.load_sheet_eager(0, use_columns=["Year", "Month"])
+    assert rb.schema.names == ["Year", "Month"]
+    # subset
+    rb = excel_reader.load_sheet_eager(0, use_columns=["Year"])
+    assert rb.schema.names == ["Year"]