Skip to content

Commit d2384d3

Browse files
authored
(fix) Allow read partitions with extra = in the value (#1779)
* Allow read partitions with extra = in the value * fix num of ='s and apply same fix for metadata calss
1 parent f1a8c17 commit d2384d3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

awswrangler/s3/_read.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def _extract_partitions_metadata_from_paths(
4444
raise exceptions.InvalidArgumentValue(f"Object {p} is not under the root path ({path}).")
4545
path_wo_filename: str = p.rpartition("/")[0] + "/"
4646
if path_wo_filename not in partitions_values:
47-
path_wo_prefix: str = path_wo_filename.replace(f"{path}/", "")
48-
dirs: Tuple[str, ...] = tuple(x for x in path_wo_prefix.split("/") if (x != "") and (x.count("=") == 1))
47+
path_wo_prefix: str = path_wo_filename.replace(f"{path}", "")
48+
dirs: Tuple[str, ...] = tuple(x for x in path_wo_prefix.split("/") if (x != "") and (x.count("=") > 0))
4949
if dirs:
50-
values_tups = cast(Tuple[Tuple[str, str]], tuple(tuple(x.split("=")[:2]) for x in dirs))
50+
values_tups = cast(Tuple[Tuple[str, str]], tuple(tuple(x.split("=", maxsplit=1)[:2]) for x in dirs))
5151
values_dics: Dict[str, str] = dict(values_tups)
5252
p_values: List[str] = list(values_dics.values())
5353
p_types: Dict[str, str] = {x: "string" for x in values_dics.keys()}
@@ -71,11 +71,11 @@ def _extract_partitions_from_path(path_root: str, path: str) -> Dict[str, str]:
7171
if path_root not in path:
7272
raise exceptions.InvalidArgumentValue(f"Object {path} is not under the root path ({path_root}).")
7373
path_wo_filename: str = path.rpartition("/")[0] + "/"
74-
path_wo_prefix: str = path_wo_filename.replace(f"{path_root}/", "")
75-
dirs: Tuple[str, ...] = tuple(x for x in path_wo_prefix.split("/") if (x != "") and (x.count("=") == 1))
74+
path_wo_prefix: str = path_wo_filename.replace(f"{path_root}", "")
75+
dirs: Tuple[str, ...] = tuple(x for x in path_wo_prefix.split("/") if (x != "") and (x.count("=") > 0))
7676
if not dirs:
7777
return {}
78-
values_tups = cast(Tuple[Tuple[str, str]], tuple(tuple(x.split("=")[:2]) for x in dirs))
78+
values_tups = cast(Tuple[Tuple[str, str]], tuple(tuple(x.split("=", maxsplit=1)[:2]) for x in dirs))
7979
values_dics: Dict[str, str] = dict(values_tups)
8080
return values_dics
8181

0 commit comments

Comments
 (0)