您可以帮助我使用Spark Redshift 数据砖驱动程序,阅读数据。
目前iam for错误呼叫读方法。以下是我的代码。
df = spark.read.format("com.databricks.spark.redshift")
.option("url",redshifturl).option("dbtable", "PG_TABLE_DEF")
.option("tempdir","s3n://KEY_ID:SECRET_KEY_ID@/S2_BUCKET_NAME/TEMP_FOLDER_UNDER_S3_BUCKET/")
.option("aws_iam_role","AWS_IAM_ROLE").load()
以下是错误日志我正在获取
IllegalArgumentException: u"The bucket name parameter must be specified when requesting a bucket's location"
---------------------------------------------------------------------------
IllegalArgumentException Traceback (most recent call last)
<command-3255625043609925> in <module>()
----> 1 df = spark.read .format("com.databricks.spark.redshift") .option("url", redshifturl) .option("dbtable", "pg_table_def") .option("tempdir", "s3n://AKIAJXVW3IESJSQUTCUA:kLHR85WfcieNrd7B7Rm/1FK1JU4NeKTrpe8BkLbx@/weatherpattern/temp/") .option("aws_iam_role", "arn:aws:iam::190137980335:user/user1") .load()
/databricks/spark/python/pyspark/sql/readwriter.py in load(self, path, format, schema, **options)
163 return self._df(self._jreader.load(self._spark._sc._jvm.PythonUtils.toSeq(path)))
164 else:
--> 165 return self._df(self._jreader.load())
166
167 @since(1.4)
/databricks/spark/python/lib/py4j-0.10.4-src.zip/py4j/java_gateway.py in __call__(self, *args)
1131 answer = self.gateway_client.send_command(command)
1132 return_value = get_return_value(
-> 1133 answer, self.gateway_client, self.target_id, self.name)
1134
1135 for temp_arg in temp_args:
/databricks/spark/python/pyspark/sql/utils.py in deco(*a, **kw)
77 raise QueryExecutionException(s.split(': ', 1)[1], stackTrace)
78 if s.startswith('java.lang.IllegalArgumentException: '):
---> 79 raise IllegalArgumentException(s.split(': ', 1)[1], stackTrace)
80 raise
81 return deco
IllegalArgumentException: u"The bucket name parameter must be specified when requesting a bucket's location"
我认为S3N路径有一些问题,但是我在.option方法中给出的方式看起来很正确。
任何建议将不胜感激。
谢谢
imran:)
-
您的路径URL不正确,
格式应该是
s3n://accessKey:secretkey@bucket/path/to/temp/dir
df = spark.read.format("com.databricks.spark.redshift")
.option("url",redshifturl).option("dbtable", "PG_TABLE_DEF")
.option("tempdir","s3n://KEY_ID:SECRET_KEY_ID@S2_BUCKET_NAME/TEMP_FOLDER_UNDER_S3_BUCKET/")
.option("aws_iam_role","AWS_IAM_ROLE").load()
文档:
https://github.com/databricks/spark-redshift
希望它有帮助。