本文介绍了Rstudio的SparkR-在invokeJava(isStatic = TRUE,className,methodName,...)中给出错误:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用RStudio.

I am using RStudio.

创建会话后,如果我尝试使用R数据创建数据框,则会出错.

After creating session if i try to create dataframe using R data it gives error.

Sys.setenv(SPARK_HOME = "E:/spark-2.0.0-bin-hadoop2.7/spark-2.0.0-bin-hadoop2.7")
Sys.setenv(HADOOP_HOME = "E:/winutils")
.libPaths(c(file.path(Sys.getenv("SPARK_HOME"), "R", "lib"), .libPaths()))
Sys.setenv('SPARKR_SUBMIT_ARGS'='"sparkr-shell"')

library(SparkR)

sparkR.session(sparkConfig = list(spark.sql.warehouse.dir="C:/Temp"))

localDF <- data.frame(name=c("John", "Smith", "Sarah"), age=c(19, 23, 18))
df <- createDataFrame(localDF)

错误:

Error in invokeJava(isStatic = TRUE, className, methodName, ...) : 
  java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.apache.spark.sql.hive.client.IsolatedClientLoader.createClient(IsolatedClientLoader.scala:258)
    at org.apache.spark.sql.hive.HiveUtils$.newClientForMetadata(HiveUtils.scala:359)
    at org.apache.spark.sql.hive.HiveUtils$.newClientForMetadata(HiveUtils.scala:263)
    at org.apache.spark.sql.hive.HiveSharedState.metadataHive$lzycompute(HiveSharedState.scala:39)
    at org.apache.spark.sql.hive.HiveSharedState.metadataHive(HiveSharedState.scala:38)
    at org.apache.spark.sql.hive.HiveSharedState.externalCatalog$lzycompute(HiveSharedState.scala:46)
    at org.apache.spark.sql.hive.HiveSharedState.externalCatalog(HiveSharedState.scala:45)
    at org.a
>

TIA.

推荐答案

如果您尚未使用SparkR库,但您正在使用Spark,我建议使用RStudio制作的"sparklyr"库.

If you have not used SparkR library but you're using Spark,I recommend 'sparklyr' library made by RStudio.

  1. 安装RStudio的预览版.

  1. Install the preview version of RStudio.

安装库:

install.packages("devtools")
devtools::install_github('rstudio/sparklyr')

  • 加载库并安装spark.

  • Load library and install spark.

    library(sparklyr)
    spark_install('1.6.2')
    

  • 您可以在 http://spark.rstudio.com/

    这篇关于Rstudio的SparkR-在invokeJava(isStatic = TRUE,className,methodName,...)中给出错误:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    10-23 01:06