cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to read data from S3 Access Point by pyspark?

yutaro_ono1_558
New Contributor II

I want to read data from s3 access point.

I successfully accessed using boto3 client to data through s3 access point.

s3 = boto3.resource('s3')ap = s3.Bucket('arn:aws:s3:[region]:[aws account id]:accesspoint/[S3 Access Point name]')for obj in ap.objects.all():  print(obj.key)  print(obj.get()['Body'].read())

I tried read access through s3 access point by pyspark.

But, I dose not access to s3 access point with error of " java.lang.NullPointerException: null uri host. This can be caused by unencoded / in the password string".

# Can't access to data
# https://[s3-accesspoint-name]-[accountid].s3-accesspoint.[region].amazonaws.com/[file path]
df = spark.read.csv('s3a://arn:aws:s3:[region]:[aws account id]:accesspoint/[S3 access point name]/[data file path]')
df.show()

How to access through the S3 Access Point to data?

S3 Access Point

https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html

2 REPLIES 2

Niclas
New Contributor II

Did you get to following up on this issue, Kaniz?

shrestha-rj
New Contributor II

I'm reaching out to seek assistance as I navigate an issue. Currently, I'm trying to read JSON files from an S3 Multi-Region Access Point using a Databricks notebook. While reading directly from the S3 bucket presents no challenges, I encounter an "java.nio.file.AccessDeniedException" error when attempting to read from the Multi-Region Access Point. Any guidance or support you can provide would be greatly appreciated.

 
spark.read.json("s3://<bucket-name>/").display(). --- No issue
 
spark.read.json("s3://accesspoint/<ap-name>.mrap").display() -- java.nio.file.AccessDeniedException

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group