Windows 中创建的 Parquet 文件无法在 Ubuntu 中打开

Parquet file created in Windows cannot be opened in Ubuntu

所以我在我的 Windows 10 计算机上使用以下行创建了一个镶木地板文件

# pandas and pyarrow installed using pip on Python 3.9
# pip install pandas==1.4.2
# pip install pyarrow==7.0.0

import pandas as pd

df = pd.DataFrame(dict(x=[0, 1, 2], y=[3, 4, 5]))
df.to_parquet('some/path/to/my/windows_parquet_file.parquet')

现在我在 Azure Pipelines 中创建一个管道,我想通过执行 Python 脚本加载到同一个文件中。执行python脚本的代理OS是Ubuntu20.04.4。该脚本的内容:

# pandas and pyarrow installed using pip on Python 3.9
# pip install pandas==1.4.2
# pip install pyarrow==7.0.0

import pandas as pd

parquet_file_path = 'some/path/to/my/windows_parquet_file.parquet'
df = pd.read_parquet(parquet_file_path)

但是,最后一行给我一个错误

Traceback (most recent call last):
  File "/home/vsts/work/_temp/ec5ac2c3-4983-41d5-abe4-cd532dafb5af.py", line 4, in <module>
    df = pd.read_parquet(parquet_file_path)
  File "/opt/hostedtoolcache/Python/3.9.12/x64/lib/python3.9/site-packages/pandas/io/parquet.py", line 493, in read_parquet
    return impl.read(
  File "/opt/hostedtoolcache/Python/3.9.12/x64/lib/python3.9/site-packages/pandas/io/parquet.py", line 240, in read
    result = self.api.parquet.read_table(
  File "/opt/hostedtoolcache/Python/3.9.12/x64/lib/python3.9/site-packages/pyarrow/parquet.py", line 1960, in read_table
    dataset = _ParquetDatasetV2(
  File "/opt/hostedtoolcache/Python/3.9.12/x64/lib/python3.9/site-packages/pyarrow/parquet.py", line 1766, in __init__
    [fragment], schema=fragment.physical_schema,
  File "pyarrow/_dataset.pyx", line 797, in pyarrow._dataset.Fragment.physical_schema.__get__
  File "pyarrow/error.pxi", line 143, in pyarrow.lib.pyarrow_internal_check_status
  File "pyarrow/error.pxi", line 99, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.

有谁知道为什么会出现这个问题以及如何解决? 我一直在网上浏览,但我找不到任何指出 writing/reading 实木复合地板文件在不同 OS.

上的差异的内容

Python 我的 PC 和代理 VM 上的版本都是 3.9。

所以在花了更多时间解决这个问题之后,我找到了这个错误的原因和解决方案。 该问题与不同的 OS 或包版本或任何其他无关。

我引用的文件是 GITlfs 的一部分。因此,该文件不再是镶木地板文件,而是此类文件的 link。 解决方案是确保在尝试访问之前下载所有相关文件。 在我使用 Azure Pipelines 的特定案例中,我在这里找到了解决方案: