Repository: modin-project/modin

Issue:
`read_parquet` failed with Internal Error
Modin version: https://github.com/modin-project/modin/commit/45ad9deced24fa0e5c8e119b15fcec8bb95dbd8d

Reproducer:
```python
from time import time
import modin.pandas as pd
from modin.utils import execute
import numpy as np


df = pd.DataFrame(np.random.rand(10**5, 10**2))


df.to_parquet("test_parquet_usual.parquet")
df = pd.read_parquet("test_parquet_usual.parquet")
```

Traceback:
```bash
Traceback (most recent call last):
  File "C:\projects\modin\test_parquet_glob.py", line 11, in <module>
    df = pd.read_parquet("test_parquet_usual.parquet")
  File "C:\projects\modin\modin\utils.py", line 484, in wrapped
    return func(*params.args, **params.kwargs)
  File "C:\projects\modin\modin\logging\logger_decorator.py", line 129, in run_and_log
    return obj(*args, **kwargs)
  File "C:\projects\modin\modin\pandas\io.py", line 325, in read_parquet
    query_compiler=FactoryDispatcher.read_parquet(
  File "C:\projects\modin\modin\core\execution\dispatching\factories\dispatcher.py", line 187, in read_parquet
    return cls.get_factory()._read_parquet(**kwargs)
  File "C:\projects\modin\modin\core\execution\dispatching\factories\factories.py", line 212, in _read_parquet
    return cls.io_cls.read_parquet(**kwargs)
  File "C:\projects\modin\modin\logging\logger_decorator.py", line 129, in run_and_log
    return obj(*args, **kwargs)
  File "C:\projects\modin\modin\core\io\file_dispatcher.py", line 164, in read
    if not AsyncReadMode.get() and hasattr(query_compiler, "dtypes"):
  File "C:\projects\modin\modin\core\storage_formats\pandas\query_compiler.py", line 321, in dtypes
    return self._modin_frame.dtypes
  File "C:\projects\modin\modin\core\dataframe\pandas\dataframe\dataframe.py", line 383, in dtypes
    dtypes = self._dtypes.get()
  File "C:\projects\modin\modin\core\dataframe\pandas\metadata\dtypes.py", line 830, in get
    self._value = self._value.to_series()
  File "C:\projects\modin\modin\core\dataframe\pandas\metadata\dtypes.py", line 436, in to_series
    self.materialize()
  File "C:\projects\modin\modin\core\dataframe\pandas\metadata\dtypes.py", line 402, in materialize
    self._materialize_cols_with_unknown_dtypes()
  File "C:\projects\modin\modin\core\dataframe\pandas\metadata\dtypes.py", line 388, in _materialize_cols_with_unknown_dtypes
    self._known_dtypes.update(self._parent_df._compute_dtypes(subset))
  File "C:\projects\modin\modin\logging\logger_decorator.py", line 129, in run_and_log
    return obj(*args, **kwargs)
  File "C:\projects\modin\modin\core\dataframe\pandas\dataframe\dataframe.py", line 436, in _compute_dtypes
    obj.tree_reduce(0, lambda df: df.dtypes, dtype_builder)
  File "C:\projects\modin\modin\logging\logger_decorator.py", line 129, in run_and_log
    return obj(*args, **kwargs)
  File "C:\projects\modin\modin\core\dataframe\pandas\dataframe\utils.py", line 501, in run_f_on_minimally_updated_metadata
    result = f(self, *args, **kwargs)
  File "C:\projects\modin\modin\core\dataframe\pandas\dataframe\dataframe.py", line 4062, in to_pandas
    ErrorMessage.catch_bugs_and_request_email(
  File "C:\projects\modin\modin\error_message.py", line 81, in catch_bugs_and_request_email
    raise Exception(
Exception: Internal Error. Please visit https://github.com/modin-project/modin/issues to file an issue with the traceback and the command that caused this error. If you can't file a GitHub issue, please email bug_reports@modin.org.
Internal and external indices on axis 1 do not match.
```


Discussion:

Resolving patch:
diff --git a/modin/core/io/column_stores/parquet_dispatcher.py b/modin/core/io/column_stores/parquet_dispatcher.py
--- a/modin/core/io/column_stores/parquet_dispatcher.py
+++ b/modin/core/io/column_stores/parquet_dispatcher.py
@@ -686,6 +686,14 @@ def build_query_compiler(cls, dataset, columns, index_columns, **kwargs):
             row_lengths = [part.length() for part in remote_parts.T[0]]
         else:
             row_lengths = None
+
+        if (
+            dataset.pandas_metadata
+            and "column_indexes" in dataset.pandas_metadata
+            and dataset.pandas_metadata["column_indexes"][0]["numpy_type"] == "int64"
+        ):
+            columns = pandas.Index(columns).astype("int64").to_list()
+
         frame = cls.frame_cls(
             remote_parts,
             index,


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
@@ -2034,6 +2034,17 @@ def test_read_parquet_5767(self, tmp_path, engine):
         # both Modin and pandas read column "b" as a category
         df_equals(test_df, read_df.astype("int64"))
 
+    def test_read_parquet_6855(self, tmp_path, engine):
+        if engine == "fastparquet":
+            pytest.skip("integer columns aren't supported")
+        test_df = pandas.DataFrame(np.random.rand(10**2, 10))
+        path = tmp_path / "data"
+        path.mkdir()
+        file_name = "issue6855.parquet"
+        test_df.to_parquet(path / file_name, engine=engine)
+        read_df = pd.read_parquet(path / file_name, engine=engine)
+        df_equals(test_df, read_df)
+
     def test_read_parquet_s3_with_column_partitioning(
         self, s3_resource, engine, s3_storage_options
     ):