`collect()`ing Large Datasets in R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 11:37 AM
Background: I'm working on a pilot project to assess the pros and cons of using DataBricks to train models using R. I am using a dataset that occupies about 5.7GB of memory when loaded into a pandas dataframe. The data are stored in a delta table in Unity Catalog.
Problem: I can `collect()` the data using python (pyspark) in about 2 minutes. However, when I tried to use sparklyr to collect the same dataset in R the command was still running after ~2.5 days. I can't load the dataset into DBFS first because we need stricter data-access controls than DBFS will allow. Below are screenshots of the cells that I ran to `collect()` the data in Python and R.
I'm hoping that I'm just missing something about how sparklyr loads data.
Here is the cell that loads the data using pyspark, you can see that it took 2.04 minutes to complete:
Here is the cell that loads the data using sparklyr, you can see that I cancelled it after 2.84 days:
I also tried using the `sparklyr::spark_read_table` function but I got an error that `Table or view not found: main.databricks_...` which I think must be because the table is in a metastore managed by Unity Catalog.
Environment Info:
Databricks Runtime: 10.4 LTS
Driver Node Size: 140GB memory and 20 cores
Worker Nodes: 1 worker node with 56GB of memory and 8 cores.
R libraries installed: arrow, sparklyr, SparkR, dplyr