diff --git a/crates/polars-plan/src/plans/hive.rs b/crates/polars-plan/src/plans/hive.rs index a711aeb11848..d99054cb405c 100644 --- a/crates/polars-plan/src/plans/hive.rs +++ b/crates/polars-plan/src/plans/hive.rs @@ -231,21 +231,18 @@ pub fn hive_partitions_from_paths( } /// Determine the path separator for identifying Hive partitions. -#[cfg(target_os = "windows")] -fn separator(url: &Path) -> char { - if polars_io::path_utils::is_cloud_url(url) { - '/' +fn separator(url: &Path) -> &[char] { + if cfg!(target_family = "windows") { + if polars_io::path_utils::is_cloud_url(url) { + &['/'] + } else { + &['/', '\\'] + } } else { - '\\' + &['/'] } } -/// Determine the path separator for identifying Hive partitions. -#[cfg(not(target_os = "windows"))] -fn separator(_url: &Path) -> char { - '/' -} - /// Parse a Hive partition string (e.g. "column=1.5") into a name and value part. /// /// Returns `None` if the string is not a Hive partition string. diff --git a/py-polars/tests/unit/io/test_hive.py b/py-polars/tests/unit/io/test_hive.py index 87275279db4a..2b0cf5bb7847 100644 --- a/py-polars/tests/unit/io/test_hive.py +++ b/py-polars/tests/unit/io/test_hive.py @@ -785,7 +785,7 @@ def test_hive_predicate_dates_14712( @pytest.mark.write_disk def test_hive_windows_path_separator(tmp_path: Path) -> None: tmp_path = tmp_path.resolve() - path = f"{tmp_path}/a=1/b=1\\c=1\\d=1/e=1" + path = f"{tmp_path}/a=1/b=1/c=1/d=1/e=1" Path(path).mkdir(exist_ok=True, parents=True) df = pl.DataFrame({"x": "x"})