gpt4 book ai didi

从本地桌面使用 sparklyr 读取存储在 hdfs 上的 csv 文件

转载 作者:可可西里 更新时间:2023-11-01 15:10:06 27 4
gpt4 key购买 nike

我们正在尝试使用 sparklyr 中可用的 spark_read_csv 函数加载存储在 HDFS 中的 csv 文件。 R代码在windows桌面上运行,并配置为以yarn-client模式连接到远程yarn集群,提交和执行作业。使用的 spark 版本是 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。问题:当我们调用

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

系统在将驱动器号“C”添加到路径名后,在远程 hdfs 中查找文件。代码搜索的hdfs位置是hdfs://machine-name/C:/user/user1/adv.csv而不是看hdfs://machine-name/user/user1/adv.csv,因此检索失败文件。非常感谢任何解决问题的帮助。

星火版本:1.6.0 Spark 版本:0.5.6Hadoop 版本: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 session 信息:

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

最佳答案

使用 hdfs:///user/xyz/adv.csv 而不是使用/user/xyz/adv.csv 达到了目的。

感谢来自 sparklyr 的@javierluraschi。

关于从本地桌面使用 sparklyr 读取存储在 hdfs 上的 csv 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45088425/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com