Repository: modin-project/modin

Issue:
BUG: Modin fails to read a feather file if it contains index metadata
### Modin version checks

- [X] I have checked that this issue has not already been reported.

- [X] I have confirmed this bug exists on the latest released version of Modin.

- [X] I have confirmed this bug exists on the main branch of Modin. (In order to do this you can follow [this guide](https://modin.readthedocs.io/en/stable/getting_started/installation.html#installing-from-the-github-master-branch).)


### Reproducible Example

```python
import tempfile
import pandas
import modin.pandas as pd

with tempfile.NamedTemporaryFile() as fl:
    pandas.DataFrame({"a": [1, 2, 3]}, index=pandas.Index([0, 1, 2])).to_feather(fl.name)

    pandas.read_feather(fl.name) # reads okay
    pd.read_feather(fl.name) # ValueError
```


### Issue Description

Feather format actually should only allow writing dataframes with default RangeIndexes as [other indices are considered to be unsupported so far](https://github.com/pandas-dev/pandas/issues/28208#issuecomment-526002530), however, it appears that a dataframe can also be written if its index <i>matches</i> the values of default index, [there are no requirements in the writer's code for this to be an actual RangeIndex.](https://github.com/pandas-dev/pandas/blob/37ea63d540fd27274cad6585082c91b1283f963d/pandas/io/feather_format.py#L75-L79) This extra index metadata confuses modin and makes its `.read_feather()` to fail on such fails.

### Expected Behavior

We should filter out the index columns here: https://github.com/modin-project/modin/blob/d14abf463548dff147a12cd59727cbf0dbee7721/modin/core/io/column_stores/feather_dispatcher.py#L65

### Error Logs

<details>

```python-traceback

Traceback (most recent call last):
  File "srt.py", line 9, in <module>
    pd.read_feather(fl.name) # Error
  File "repos/modin/modin/logging/logger_decorator.py", line 128, in run_and_log
    return obj(*args, **kwargs)
  File "repos/modin/modin/pandas/io.py", line 509, in read_feather
    return DataFrame(query_compiler=FactoryDispatcher.read_feather(**kwargs))
  File "repos/modin/modin/core/execution/dispatching/factories/dispatcher.py", line 235, in read_feather
    return cls.get_factory()._read_feather(**kwargs)
  File "repos/modin/modin/core/execution/dispatching/factories/factories.py", line 293, in _read_feather
    return cls.io_cls.read_feather(**kwargs)
  File "repos/modin/modin/logging/logger_decorator.py", line 128, in run_and_log
    return obj(*args, **kwargs)
  File "repos/modin/modin/core/io/file_dispatcher.py", line 157, in read
    query_compiler = cls._read(*args, **kwargs)
  File "repos/modin/modin/logging/logger_decorator.py", line 128, in run_and_log
    return obj(*args, **kwargs)
  File "repos/modin/modin/core/io/column_stores/feather_dispatcher.py", line 66, in _read
    return cls.build_query_compiler(path, columns, use_threads=False)
  File "repos/modin/modin/logging/logger_decorator.py", line 128, in run_and_log
    return obj(*args, **kwargs)
  File "repos/modin/modin/core/io/column_stores/column_store_dispatcher.py", line 224, in build_query_compiler
    cls.build_dtypes(partition_ids[-1], columns)
  File "repos/modin/modin/logging/logger_decorator.py", line 128, in run_and_log
    return obj(*args, **kwargs)
  File "repos/modin/modin/core/io/column_stores/column_store_dispatcher.py", line 197, in build_dtypes
    dtypes.index = columns
  File "miniconda3/envs/modinc/lib/python3.8/site-packages/pandas/core/generic.py", line 5915, in __setattr__
    return object.__setattr__(self, name, value)
  File "pandas/_libs/properties.pyx", line 69, in pandas._libs.properties.AxisProperty.__set__
  File "miniconda3/envs/modinc/lib/python3.8/site-packages/pandas/core/series.py", line 593, in _set_axis
    self._mgr.set_axis(axis, labels)
  File "miniconda3/envs/modinc/lib/python3.8/site-packages/pandas/core/internals/managers.py", line 230, in set_axis
    self._validate_set_axis(axis, new_labels)
  File "miniconda3/envs/modinc/lib/python3.8/site-packages/pandas/core/internals/base.py", line 70, in _validate_set_axis
    raise ValueError(
ValueError: Length mismatch: Expected axis has 1 elements, new values have 2 elements


```

</details>


### Installed Versions

<details>

Replace this line with the output of pd.show_versions()

</details>



Discussion:

Resolving patch:
diff --git a/modin/core/io/column_stores/feather_dispatcher.py b/modin/core/io/column_stores/feather_dispatcher.py
--- a/modin/core/io/column_stores/feather_dispatcher.py
+++ b/modin/core/io/column_stores/feather_dispatcher.py
@@ -62,5 +62,13 @@ def _read(cls, path, columns=None, **kwargs):
                 reader = ipc.open_file(file)
             # TODO: pyarrow's schema contains much more metadata than just column names, it also
             # has dtypes and index information that we could use when building a dataframe
-            columns = reader.schema.names
+            index_cols = frozenset(
+                col
+                for col in reader.schema.pandas_metadata["index_columns"]
+                # 'index_columns' field may also contain dictionary fields describing actual
+                # RangeIndices, so we're only filtering here for string column names
+                if isinstance(col, str)
+            )
+            # Filtering out the columns that describe the frame's index
+            columns = [col for col in reader.schema.names if col not in index_cols]
         return cls.build_query_compiler(path, columns, use_threads=False)


Test patch:
diff --git a/modin/pandas/test/test_io.py b/modin/pandas/test/test_io.py
--- a/modin/pandas/test/test_io.py
+++ b/modin/pandas/test/test_io.py
@@ -2634,6 +2634,18 @@ def test_to_feather(self, tmp_path):
             extension="feather",
         )
 
+    def test_read_feather_with_index_metadata(self, tmp_path):
+        # see: https://github.com/modin-project/modin/issues/6212
+        df = pandas.DataFrame({"a": [1, 2, 3]}, index=[0, 1, 2])
+        assert not isinstance(df.index, pandas.RangeIndex)
+
+        path = get_unique_filename(extension=".feather", data_dir=tmp_path)
+        df.to_feather(path)
+        eval_io(
+            fn_name="read_feather",
+            path=path,
+        )
+
 
 class TestClipboard:
     @pytest.mark.skip(reason="No clipboard in CI")