[英]py4j.Py4JException: Method set([class java.lang.String, class java.util.ArrayList]) does not exist in Databricks
I am trying to access a remote S3 bucket using Databricks.我正在尝试使用 Databricks 访问远程 S3 存储桶。
From what I have understood, this is what my code should look like,据我了解,这就是我的代码应该是什么样子,
sc._jsc.hadoopConfiguration().set("fs.s3a.access.key", access_key)
sc._jsc.hadoopConfiguration().set("fs.s3a.secret.key", secret_access_key)
sc._jsc.hadoopConfiguration().set("fs.s3a.endpoint", "s3.amazonaws.com")
df = spark.read.format("csv").option("header",True).load('s3a://bucket/path/to/file.csv')
df.show()
I seem to be getting the following error when trying to set the Spark configurations,尝试设置 Spark 配置时,我似乎遇到了以下错误,
Py4JError: An error occurred while calling o371.set. Trace:
py4j.Py4JException: Method set([class java.lang.String, class java.util.ArrayList]) does not exist
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:341)
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:349)
at py4j.Gateway.invoke(Gateway.java:286)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:251)
at java.lang.Thread.run(Thread.java:750)
What am I doing wrong?我究竟做错了什么?
Check your configuration with S3 as per the official document :根据官方文档使用 S3 检查您的配置:
Access_key = dbutils.secrets.get(scope = "Scope_name", key = "aws_access_key")
Secret_key = dbutils.secrets.get(scope = "Scope_name", key = "aws_secret_key")
sc._jsc.hadoopConfiguration().set("fs.s3a.access.key", Access_key)
sc._jsc.hadoopConfiguration().set("fs.s3a.secret.key", Secret_key)
region = "aws-region-id"
sc._jsc.hadoopConfiguration().set("fs.s3a.endpoint", "s3." + region + ".amazonaws.com")
conn = sc.textFile("s3a://%s/.../..." % aws_bucket_name)
conn.count()
Or或者
You can try this alternative approach Mounting AWS S3 buckets on Databricks by Deepak Rajak您可以尝试这种替代方法,Deepak Rajak 在 Databricks 上安装 AWS S3 存储桶
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.