Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
nameexhaustion committed Oct 17, 2024
1 parent 678d870 commit 0dd73cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
19 changes: 8 additions & 11 deletions crates/polars-plan/src/plans/hive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/io/test_hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down

0 comments on commit 0dd73cf

Please sign in to comment.