raulcd commented on issue #46019:
URL: https://github.com/apache/arrow/issues/46019#issuecomment-2776096756

   In general we don't allow generators so I guess a quick check should do the 
trick. I am unsure whether we want this though:
   ```diff
   diff --git a/python/pyarrow/feather.py b/python/pyarrow/feather.py
   index fbd0602597..96449ff0b2 100644
   --- a/python/pyarrow/feather.py
   +++ b/python/pyarrow/feather.py
   @@ -255,6 +255,10 @@ def read_table(source, columns=None, memory_map=False, 
use_threads=True):
        if columns is None:
            return reader.read()
    
   +    if not hasattr(columns, '__len__'):
   +        raise TypeError("Columns must be a sequence but, got {}"
   +                        .format(type(columns).__name__))
   +
        column_types = [type(column) for column in columns]
        if all(map(lambda t: t == int, column_types)):
            table = reader.read_indices(columns)
   diff --git a/python/pyarrow/tests/test_feather.py 
b/python/pyarrow/tests/test_feather.py
   index 249fb62127..8d840dba8c 100644
   --- a/python/pyarrow/tests/test_feather.py
   +++ b/python/pyarrow/tests/test_feather.py
   @@ -805,6 +805,16 @@ def test_read_column_duplicated_in_file(tempdir):
            read_table(path, columns=['a', 'b'])
    
    
   +def test_read_column_wrong_column_type(tempdir, version):
   +    # duplicated columns in the column selection
   +    table = pa.table([[1, 2, 3], [4, 5, 6], [7, 8, 9]], names=['a', 'b', 
'c'])
   +    path = str(tempdir / "data.feather")
   +    write_feather(table, path, version=version)
   +    columns_gen = (x for x in ['a', 'b', 'c'])
   +    with pytest.raises(TypeError):
   +        read_table(path, columns=columns_gen)
   +
   +
    def test_nested_types(compression):
        # https://issues.apache.org/jira/browse/ARROW-8860
        table = pa.table({'col': pa.StructArray.from_arrays(
   ```
   @jorisvandenbossche @AlenkaF thoughts?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to