@@ -589,7 +589,7 @@ def _initialize_gcs_fs(self) -> FileSystem:
589589 def _initialize_local_fs (self ) -> FileSystem :
590590 return PyArrowLocalFileSystem ()
591591
592- def _resolve_s3_access_point (self , scheme : str , netloc : str , path_suffix : str ) -> tuple [str , str ]:
592+ def _resolve_s3_access_point (self , scheme : str , netloc : str , path_suffix : str , original_path : str ) -> tuple [str , str ]:
593593 """Resolve S3 access point alias for a bucket if configured.
594594
595595 For cross-account access, S3 paths need to use access point aliases instead of bucket names.
@@ -600,12 +600,13 @@ def _resolve_s3_access_point(self, scheme: str, netloc: str, path_suffix: str) -
600600 scheme: The URI scheme (s3, s3a, s3n)
601601 netloc: The bucket name from the original URI
602602 path_suffix: The path within the bucket (without bucket name)
603+ original_path: The original path from parse_location (fallback for non-S3)
603604
604605 Returns:
605606 Tuple of (resolved_netloc, resolved_path) where netloc may be replaced with access point alias
606607 """
607608 if scheme not in {"s3" , "s3a" , "s3n" }:
608- return netloc , f" { netloc } { path_suffix } "
609+ return netloc , original_path
609610
610611 # Check for access point alias configuration for this bucket
611612 access_point_key = f"{ S3_ACCESS_POINT_PREFIX } { netloc } "
@@ -614,7 +615,7 @@ def _resolve_s3_access_point(self, scheme: str, netloc: str, path_suffix: str) -
614615 # Replace bucket with access point alias in the path
615616 return access_point_alias , f"{ access_point_alias } { path_suffix } "
616617
617- return netloc , f" { netloc } { path_suffix } "
618+ return netloc , original_path
618619
619620 def new_input (self , location : str ) -> PyArrowFile :
620621 """Get a PyArrowFile instance to read bytes from the file at the given location.
@@ -625,10 +626,10 @@ def new_input(self, location: str) -> PyArrowFile:
625626 Returns:
626627 PyArrowFile: A PyArrowFile instance for the given location.
627628 """
628- scheme , netloc , _ = self .parse_location (location , self .properties )
629- # For S3, resolve access point ARN if configured
629+ scheme , netloc , path = self .parse_location (location , self .properties )
630+ # For S3, resolve access point if configured
630631 uri = urlparse (location )
631- resolved_netloc , resolved_path = self ._resolve_s3_access_point (scheme , netloc , uri .path )
632+ resolved_netloc , resolved_path = self ._resolve_s3_access_point (scheme , netloc , uri .path , path )
632633 return PyArrowFile (
633634 fs = self .fs_by_scheme (scheme , resolved_netloc ),
634635 location = location ,
@@ -645,10 +646,10 @@ def new_output(self, location: str) -> PyArrowFile:
645646 Returns:
646647 PyArrowFile: A PyArrowFile instance for the given location.
647648 """
648- scheme , netloc , _ = self .parse_location (location , self .properties )
649- # For S3, resolve access point ARN if configured
649+ scheme , netloc , path = self .parse_location (location , self .properties )
650+ # For S3, resolve access point if configured
650651 uri = urlparse (location )
651- resolved_netloc , resolved_path = self ._resolve_s3_access_point (scheme , netloc , uri .path )
652+ resolved_netloc , resolved_path = self ._resolve_s3_access_point (scheme , netloc , uri .path , path )
652653 return PyArrowFile (
653654 fs = self .fs_by_scheme (scheme , resolved_netloc ),
654655 location = location ,
@@ -670,10 +671,10 @@ def delete(self, location: str | InputFile | OutputFile) -> None:
670671 an AWS error code 15.
671672 """
672673 str_location = location .location if isinstance (location , (InputFile , OutputFile )) else location
673- scheme , netloc , _ = self .parse_location (str_location , self .properties )
674- # For S3, resolve access point ARN if configured
674+ scheme , netloc , path = self .parse_location (str_location , self .properties )
675+ # For S3, resolve access point if configured
675676 uri = urlparse (str_location )
676- resolved_netloc , resolved_path = self ._resolve_s3_access_point (scheme , netloc , uri .path )
677+ resolved_netloc , resolved_path = self ._resolve_s3_access_point (scheme , netloc , uri .path , path )
677678 fs = self .fs_by_scheme (scheme , resolved_netloc )
678679
679680 try :
0 commit comments