【问题标题】:write a large RDS file to a sparklyr dataframe- databricks将大型 RDS 文件写入 sparklyr 数据框-databricks
【发布时间】:2020-02-05 23:38:12
【问题描述】:

我正在尝试将加载在 databricks 中的 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】:

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

    这里有几个选项。

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

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

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

    【讨论】:

      猜你喜欢
      • 2020-05-01
      • 1970-01-01
      • 2020-03-25
      • 1970-01-01
      • 2017-12-01
      • 1970-01-01
      • 2020-04-12
      • 1970-01-01
      • 2019-02-07
      相关资源
      最近更新 更多