Apache Spark 2.0 parquet 文件是否与 Apache Arrow 不兼容?

Are Apache Spark 2.0 parquet files incompatible with Apache Arrow?

问题

我已经为 Python 环境中的深度学习应用程序编写了一个 Apache Spark DataFrame 作为 parquet 文件;我目前在实现两个 petastorm 的基本示例时遇到问题(遵循 this notebook) and horovod 框架,即读取上述文件。DataFrame 具有以下类型:DataFrame[features: array<float>, next: int, weight: int](很像在 DataBricks 的笔记本中,我有features 是 VectorUDT,我将其转换为数组)。
在这两种情况下,Apache Arrow 都会抛出 ArrowIOError : Invalid parquet file. Corrupt footer. 错误。

到目前为止我发现了什么

我在 and in this PR 中发现,从 2.0 版开始,Spark 不会写入 _metadata_common_metadata 文件,除非 spark.hadoop.parquet.enable.summary-metadata 设置为 true 在 Spark 的配置中;这些文件确实丢失了。
因此,我尝试用这个环境重写我的 DataFrame,仍然没有 _common_metadata 文件。同样有效的是在构建 reader 时明确地将模式传递给 petastorm(例如将 schema_fields 传递给 make_batch_reader ;这是 horovod 的问题,因为 horovod.spark.keras.KerasEstimator 的构造函数)。

如果可能的话,我怎样才能让 Spark 输出这些文件,或者在 Arrow 中推断模式,就像 Spark 似乎在做的那样?

horovod 的最小示例

# Saving df
print(spark.config.get('spark.hadoop.parquet.enable.summary-metadata')) # outputs 'true'
df.repartition(10).write.mode('overwrite').parquet(path)

# ...

# Training
import horovod.spark.keras as hvd
from horovod.spark.common.store import Store

model = build_model()
opti = Adadelta(learning_rate=0.015)
loss='sparse_categorical_crossentropy'
store = Store().create(prefix_path=prefix_path,
                       train_path=train_path,
                       val_path=val_path)
keras_estimator = hvd.KerasEstimator(
    num_proc=16,
    store=store,
    model=model,
    optimizer=opti,
    loss=loss,
    feature_cols=['features'],
    label_cols=['next'],
    batch_size=auto_steps_per_epoch,
    epochs=auto_nb_epochs,
    sample_weight_col='weight'
)

keras_model = keras_estimator.fit_on_parquet() # Fails here with ArrowIOError

问题已在pyarrow 0.14+ (issues.apache.org/jira/browse/ARROW-4723)中解决,请务必使用pip安装更新版本(直到Databricks Runtime 6.5,包含的版本为0.13)。
感谢 @joris' 指出这一点的评论。