I am running sparklyr
in local mode from RStudio in Windows 10:
spark_version <- "2.1.0"
sc <- spark_connect(master = "local", version = spark_version)
df <- data.frame(id = c(1, 1, 2, 2), county_code = c(1, 20, 321, 2))
sprintf("%03d",as.numeric(df$county_code))
df_tbl = copy_to(sc,df, "df_tbl", overwrite = TRUE)
df_tbl %>% summarise(sum = sum(county_code)) %>% collect() ## this works
## this does not:
df_tbl %>%
spark_apply(function(e) data.frame(sprintf("%03d",as.numeric(e$county_code), e),
names = c('county_code_fips', colnames(e))))
The last line returns the following error:
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file 'C:\Users\janni\AppData\Local\Temp\RtmpELRVxu\file4ab817055ccc_spark.log': Permission denied
This happens on both my laptop and desktop. I tried running RStudio as an administrator, but it would not change anything.
It seems the problem comes from the way
names
specified for thespark_apply
.One option is that you can do without this without the
names
argument.Since
names
does not have access to thee
in the function inside thespark_apply
, you have to use the names from the tbl.