将大RDS文件写入sparklyr数据帧-数据块

问题描述 投票:1回答:1

我正在尝试将数据块中加载的R数据帧转换为Sparklyr数据帧,但我认为通常使用的copy_to函数无法应付文件大小。我需要转换的文件范围为780MB-4.7GB。

代码是:

chloedf<-copy_to(sc,Chloe)

并且返回错误:

Error in writeBin(utfVal, con, endian = "big", useBytes = TRUE) : Error in writeBin(utfVal, con, endian = "big", useBytes = TRUE) : 
  attempting to add too many elements to raw vector
Error in writeBin(utfVal, con, endian = "big", useBytes = TRUE) : 
  attempting to add too many elements to raw vector
In addition: Warning message:
closing unused connection 11 (raw()) 
r apache-spark-sql databricks sparklyr azure-databricks
1个回答
0
投票

看起来像copy_to() wasn't intended for large datasets

这里有两个选择。

  1. 代替rds格式,将原始R数据帧另存为CSV。然后,您可以使用spark_read_csv(sc, "/path/to/mycsv.csv")将其直接读取到Spark中。这是最简单的方法。

  2. 尝试改用SparkR::createDataFrame()

  3. 在您的Databricks群集上安装Apache Arrow,然后重试copy_to()命令。 Here是一些有关设置的说明。

© www.soinside.com 2019 - 2024. All rights reserved.