2017-07-13 27 views
1

我們試圖使用sparklyr中提供的spark_read_csv函數加載存儲在HDFS中的csv文件。 R代碼在Windows桌面上運行,並被配置爲以紗線客戶端模式連接到遠程紗線羣集以提交和執行作業。正在使用的火花版本是1.6.0。 我們已將com.databricks_spark-csv_2.10-1.0.3.jar和org.apache.commons_commons-csv-1.1.jar包含到spark類路徑中,因爲spark 1.6.0不支持CSV。 的問題:當我們調用使用本地桌面上的sparklyr讀取存儲在hdfs中的csv文件

spark_read_csv(sc=sc 
         ,path ="/user/xyz/adv.csv" 
         ,name ="FinStatement" 
         ,infer_schema = TRUE 
         ,header = TRUE 
         ) 

系統查找遠程HDFS文件它會預先考慮盤符「C」的路徑名之後。由代碼搜索的hdfs位置是hdfs:// machine-name/C:/user/user1/adv.csv,而不是查看hdfs://machine-name/user/user1/adv.csv,因此無法檢索文件。 任何幫助解決這個問題,非常感謝。

星火版本:1.6.0 Sparklyr版本:0.5.6 的Hadoop版本:2.6.0 異常跟蹤:

Error: java.lang.IllegalArgumentException: Pathname /C:/user/user1/adv.csv from hdfs://machine-name/C:/user/p587722/adv.csv is not a valid DFS filename. 
    at org.apache.hadoop.hdfs.DistributedFileSystem.getPathName(DistributedFileSystem.java:196) 
    at org.apache.hadoop.hdfs.DistributedFileSystem.access$000(DistributedFileSystem.java:105) 
    at org.apache.hadoop.hdfs.DistributedFileSystem$18.doCall(DistributedFileSystem.java:1118) 
    at org.apache.hadoop.hdfs.DistributedFileSystem$18.doCall(DistributedFileSystem.java:1114) 
    at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81) 
    at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:1114) 
    at org.apache.hadoop.fs.Globber.getFileStatus(Globber.java:57) 

Rstudio會議信息:

R version 3.3.2 (2016-10-31) 
Platform: x86_64-w64-mingw32/x64 (64-bit) 
Running under: Windows 7 x64 (build 7601) Service Pack 1 

locale: 
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 
[4] LC_NUMERIC=C       LC_TIME=English_United States.1252  

attached base packages: 
[1] stats  graphics grDevices utils  datasets methods base  

other attached packages: 
[1] stringr_1.2.0 rJava_0.9-8 dplyr_0.7.1 sparklyr_0.5.6 

loaded via a namespace (and not attached): 
[1] Rcpp_0.12.10  rstudioapi_0.6 bindr_0.1  magrittr_1.5  xtable_1.8-2  R6_2.2.0   rlang_0.1.1  
[8] httr_1.2.1  tools_3.3.2  DBI_0.7   withr_1.0.2  dbplyr_1.1.0  htmltools_0.3.6 assertthat_0.2.0 
[15] rprojroot_1.2 digest_0.6.12 tibble_1.3.3  bindrcpp_0.2  shiny_1.0.3  base64enc_0.1-3 glue_1.1.1  
[22] mime_0.5   stringi_1.1.3 backports_1.0.5 jsonlite_1.5  httpuv_1.3.3  pkgconfig_2.0.1 

回答

0

使用HDFS:/ //user/xyz/adv.csv代替使用/user/xyz/adv.csv做了訣竅。

感謝來自sparklyr的@javierluraschi。

相關問題